本文整理汇总了C++中PX4_INFO函数的典型用法代码示例。如果您正苦于以下问题:C++ PX4_INFO函数的具体用法?C++ PX4_INFO怎么用?C++ PX4_INFO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PX4_INFO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: usage
static void usage()
{
PX4_INFO("usage: navigator {start|stop|status|fencefile}");
}
示例2: PX4_INFO
void OutputMavlink::print_status()
{
PX4_INFO("Output: Mavlink");
}
示例3: test
/**
* Perform some basic functional tests on the driver;
* make sure we can collect data from the sensor in polled
* and automatic modes.
*/
void
test(enum IST8310_BUS busid)
{
struct ist8310_bus_option &bus = find_bus(busid);
struct mag_report report;
ssize_t sz;
int ret;
const char *path = bus.devpath;
int fd = open(path, O_RDONLY);
if (fd < 0) {
err(1, "%s open failed (try 'ist8310 start')", path);
}
/* do a simple demand read */
sz = read(fd, &report, sizeof(report));
if (sz != sizeof(report)) {
err(1, "immediate read failed");
}
print_message(report);
/* check if mag is onboard or external */
if ((ret = ioctl(fd, MAGIOCGEXTERNAL, 0)) < 0) {
errx(1, "failed to get if mag is onboard or external");
}
/* set the queue depth to 5 */
if (OK != ioctl(fd, SENSORIOCSQUEUEDEPTH, 10)) {
errx(1, "failed to set queue depth");
}
/* start the sensor polling at 2Hz */
if (OK != ioctl(fd, SENSORIOCSPOLLRATE, 2)) {
errx(1, "failed to set 2Hz poll rate");
}
/* read the sensor 5x and report each value */
for (unsigned i = 0; i < 5; i++) {
struct pollfd fds;
/* wait for data to be ready */
fds.fd = fd;
fds.events = POLLIN;
ret = poll(&fds, 1, 2000);
if (ret != 1) {
errx(1, "timed out waiting for sensor data");
}
/* now go get it */
sz = read(fd, &report, sizeof(report));
if (sz != sizeof(report)) {
err(1, "periodic read failed");
}
print_message(report);
}
PX4_INFO("PASS");
exit(0);
}
示例4: start
/**
* @brief Starts the driver.
*/
void start(enum LL40LS_BUS busid, uint8_t rotation)
{
int fd, ret;
if (instance) {
PX4_INFO("driver already started");
return;
}
if (busid == LL40LS_BUS_PWM) {
instance = new LidarLitePWM(LL40LS_DEVICE_PATH_PWM, rotation);
if (!instance) {
PX4_ERR("Failed to instantiate LidarLitePWM");
return;
}
if (instance->init() != PX4_OK) {
PX4_ERR("failed to initialize LidarLitePWM");
stop();
return;
}
} else {
for (uint8_t i = 0; i < (sizeof(bus_options) / sizeof(bus_options[0])); i++) {
if (busid != LL40LS_BUS_I2C_ALL && busid != bus_options[i].busid) {
continue;
}
instance = new LidarLiteI2C(bus_options[i].busnum, bus_options[i].devname, rotation);
if (!instance) {
PX4_ERR("Failed to instantiate LidarLiteI2C");
return;
}
if (instance->init() == PX4_OK) {
break;
}
PX4_ERR("failed to initialize LidarLiteI2C on busnum=%u", bus_options[i].busnum);
stop();
}
}
if (!instance) {
PX4_WARN("No LidarLite found");
return;
}
fd = px4_open(instance->get_dev_name(), O_RDONLY);
if (fd == -1) {
PX4_ERR("Error opening fd");
stop();
return;
}
ret = px4_ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT);
px4_close(fd);
if (ret < 0) {
PX4_ERR("pollrate fail");
stop();
return;
}
}
示例5: navio_sysfs_rc_in_main
int navio_sysfs_rc_in_main(int argc, char *argv[])
{
if (argc < 2) {
usage("missing command");
return 1;
}
if (!strcmp(argv[1], "start")) {
if (rc_input != nullptr && rc_input->isRunning()) {
PX4_WARN("already running");
/* this is not an error */
return 0;
}
rc_input = new RcInput();
// Check if alloc worked.
if (rc_input == nullptr) {
PX4_ERR("alloc failed");
return -1;
}
int ret = rc_input->start();
if (ret != 0) {
PX4_ERR("start failed");
}
return 0;
}
if (!strcmp(argv[1], "stop")) {
if (rc_input == nullptr || !rc_input->isRunning()) {
PX4_WARN("not running");
/* this is not an error */
return 0;
}
rc_input->stop();
// Wait for task to die
int i = 0;
do {
/* wait up to 3s */
usleep(100000);
} while (rc_input->isRunning() && ++i < 30);
delete rc_input;
rc_input = nullptr;
return 0;
}
if (!strcmp(argv[1], "status")) {
if (rc_input != nullptr && rc_input->isRunning()) {
PX4_INFO("running");
} else {
PX4_INFO("not running\n");
}
return 0;
}
usage("unrecognized command");
return 1;
}
示例6: sf0x_main
int
sf0x_main(int argc, char *argv[])
{
// check for optional arguments
int ch;
uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
int myoptind = 1;
const char *myoptarg = NULL;
while ((ch = px4_getopt(argc, argv, "R:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'R':
rotation = (uint8_t)atoi(myoptarg);
PX4_INFO("Setting distance sensor orientation to %d", (int)rotation);
break;
default:
PX4_WARN("Unknown option!");
}
}
/*
* Start/load the driver.
*/
if (!strcmp(argv[myoptind], "start")) {
if (argc > myoptind + 1) {
sf0x::start(argv[myoptind + 1], rotation);
} else {
sf0x::start(SF0X_DEFAULT_PORT, rotation);
}
}
/*
* Stop the driver
*/
if (!strcmp(argv[myoptind], "stop")) {
sf0x::stop();
}
/*
* Test the driver/device.
*/
if (!strcmp(argv[myoptind], "test")) {
sf0x::test();
}
/*
* Reset the driver.
*/
if (!strcmp(argv[myoptind], "reset")) {
sf0x::reset();
}
/*
* Print driver information.
*/
if (!strcmp(argv[myoptind], "info") || !strcmp(argv[1], "status")) {
sf0x::info();
}
errx(1, "unrecognized command, try 'start', 'test', 'reset' or 'info'");
}
示例7: ver_main
int ver_main(int argc, char *argv[])
{
/* defaults to an error */
int ret = 1;
/* first check if there are at least 2 params */
if (argc >= 2) {
if (argv[1] != NULL) {
if (!strncmp(argv[1], sz_ver_hwcmp_str, sizeof(sz_ver_hwcmp_str))) {
if (argc >= 3 && argv[2] != NULL) {
/* compare 3rd parameter with HW_ARCH string, in case of match, return 0 */
ret = strncmp(HW_ARCH, argv[2], strlen(HW_ARCH));
if (ret == 0) {
PX4_INFO("match: %s", HW_ARCH);
}
return ret;
} else {
warn("Not enough arguments, try 'ver hwcmp PX4FMU_V2'");
return 1;
}
}
/* check if we want to show all */
bool show_all = !strncmp(argv[1], sz_ver_all_str, sizeof(sz_ver_all_str));
if (show_all || !strncmp(argv[1], sz_ver_hw_str, sizeof(sz_ver_hw_str))) {
printf("HW arch: %s\n", HW_ARCH);
ret = 0;
}
if (show_all || !strncmp(argv[1], sz_ver_git_str, sizeof(sz_ver_git_str))) {
printf("FW git-hash: %s\n", px4_git_version);
unsigned fwver = version_tag_to_number(px4_git_tag);
unsigned major = (fwver >> (8 * 3)) & 0xFF;
unsigned minor = (fwver >> (8 * 2)) & 0xFF;
unsigned patch = (fwver >> (8 * 1)) & 0xFF;
unsigned type = (fwver >> (8 * 0)) & 0xFF;
printf("FW version: %s (%u.%u.%u %u), %u\n", px4_git_tag, major, minor, patch,
type, fwver);
/* middleware is currently the same thing as firmware, so not printing yet */
printf("OS version: %s (%u)\n", os_git_tag, version_tag_to_number(os_git_tag));
ret = 0;
}
if (show_all || !strncmp(argv[1], sz_ver_bdate_str, sizeof(sz_ver_bdate_str))) {
printf("Build datetime: %s %s\n", __DATE__, __TIME__);
ret = 0;
}
if (show_all || !strncmp(argv[1], sz_ver_gcc_str, sizeof(sz_ver_gcc_str))) {
printf("Toolchain: %s\n", __VERSION__);
ret = 0;
}
if (show_all || !strncmp(argv[1], mcu_ver_str, sizeof(mcu_ver_str))) {
char rev;
char *revstr;
int chip_version = mcu_version(&rev, &revstr);
if (chip_version < 0) {
printf("UNKNOWN MCU\n");
} else {
printf("MCU: %s, rev. %c\n", revstr, rev);
if (chip_version < MCU_REV_STM32F4_REV_3) {
printf("\nWARNING WARNING WARNING!\n"
"Revision %c has a silicon errata\n"
"This device can only utilize a maximum of 1MB flash safely!\n"
"https://pixhawk.org/help/errata\n\n", rev);
}
}
ret = 0;
}
if (show_all || !strncmp(argv[1], mcu_uid_str, sizeof(mcu_uid_str))) {
uint32_t uid[3];
mcu_unique_id(uid);
printf("UID: %X:%X:%X \n", uid[0], uid[1], uid[2]);
ret = 0;
}
if (ret == 1) {
warn("unknown command.\n");
return 1;
//.........这里部分代码省略.........
示例8: PX4_INFO
void
Syslink::handle_raw_other(syslink_message_t *sys)
{
// This function doesn't actually do anything
// It is just here to return null responses to most standard messages
crtp_message_t *c = (crtp_message_t *) &sys->length;
if (c->port == CRTP_PORT_LOG) {
PX4_INFO("Log: %d %d", c->channel, c->data[0]);
if (c->channel == 0) { // Table of Contents Access
uint8_t cmd = c->data[0];
if (cmd == 0) { // GET_ITEM
//int id = c->data[1];
memset(&c->data[2], 0, 3);
c->data[2] = 1; // type
c->size = 1 + 5;
send_message(sys);
} else if (cmd == 1) { // GET_INFO
memset(&c->data[1], 0, 7);
c->size = 1 + 8;
send_message(sys);
}
} else if (c->channel == 1) { // Log control
uint8_t cmd = c->data[0];
PX4_INFO("Responding to cmd: %d", cmd);
c->data[2] = 0; // Success
c->size = 3 + 1;
// resend message
send_message(sys);
} else if (c->channel == 2) { // Log data
}
} else if (c->port == CRTP_PORT_MEM) {
if (c->channel == 0) { // Info
int cmd = c->data[0];
if (cmd == 1) { // GET_NBR_OF_MEMS
c->data[1] = 0;
c->size = 2 + 1;
// resend message
send_message(sys);
}
}
} else if (c->port == CRTP_PORT_PARAM) {
if (c->channel == 0) { // TOC Access
// uint8_t msgId = c->data[0];
c->data[1] = 0; // Last parameter (id = 0)
memset(&c->data[2], 0, 10);
c->size = 1 + 8;
send_message(sys);
}
else if (c->channel == 1) { // Param read
// 0 is ok
c->data[1] = 0; // value
c->size = 1 + 2;
send_message(sys);
}
} else {
PX4_INFO("Got raw: %d", c->port);
}
}
示例9: _x
void BlockLocalPositionEstimator::gpsInit()
{
// check for good gps signal
uint8_t nSat = _sub_gps.get().satellites_used;
float eph = _sub_gps.get().eph;
float epv = _sub_gps.get().epv;
uint8_t fix_type = _sub_gps.get().fix_type;
if (
nSat < 6 ||
eph > _gps_eph_max.get() ||
epv > _gps_epv_max.get() ||
fix_type < 3
) {
_gpsStats.reset();
return;
}
// measure
Vector<double, n_y_gps> y;
if (gpsMeasure(y) != OK) {
_gpsStats.reset();
return;
}
// if finished
if (_gpsStats.getCount() > REQ_GPS_INIT_COUNT) {
// get mean gps values
double gpsLat = _gpsStats.getMean()(0);
double gpsLon = _gpsStats.getMean()(1);
float gpsAlt = _gpsStats.getMean()(2);
_sensorTimeout &= ~SENSOR_GPS;
_sensorFault &= ~SENSOR_GPS;
_gpsStats.reset();
if (!_receivedGps) {
// this is the first time we have received gps
_receivedGps = true;
// note we subtract X_z which is in down directon so it is
// an addition
_gpsAltOrigin = gpsAlt + _x(X_z);
// find lat, lon of current origin by subtracting x and y
// if not using vision position since vision will
// have it's own origin, not necessarily where vehicle starts
if (!(_fusion.get() & FUSE_VIS_POS)) {
double gpsLatOrigin = 0;
double gpsLonOrigin = 0;
// reproject at current coordinates
map_projection_init(&_map_ref, gpsLat, gpsLon);
// find origin
map_projection_reproject(&_map_ref, -_x(X_x), -_x(X_y), &gpsLatOrigin, &gpsLonOrigin);
// reinit origin
map_projection_init(&_map_ref, gpsLatOrigin, gpsLonOrigin);
// always override alt origin on first GPS to fix
// possible baro offset in global altitude at init
_altOrigin = _gpsAltOrigin;
_altOriginInitialized = true;
}
PX4_INFO("[lpe] gps init "
"lat %6.2f lon %6.2f alt %5.1f m",
gpsLat,
gpsLon,
double(gpsAlt));
}
}
}
示例10: test
/**
* Perform some basic functional tests on the driver;
* make sure we can collect data from the sensor in polled
* and automatic modes.
*/
void
test()
{
PX4_INFO("PASS");
}
示例11: hrt_absolute_time
void
Syslink::handle_message(syslink_message_t *msg)
{
hrt_abstime t = hrt_absolute_time();
if (t - _lasttime > 1000000) {
pktrate = _count;
rxrate = _count_in;
txrate = _count_out;
nullrate = _null_count;
_lasttime = t;
_count = 0;
_null_count = 0;
_count_in = 0;
_count_out = 0;
}
_count++;
if (msg->type == SYSLINK_PM_ONOFF_SWITCHOFF) {
// When the power button is hit
} else if (msg->type == SYSLINK_PM_BATTERY_STATE) {
if (msg->length != 9) {
return;
}
uint8_t flags = msg->data[0];
int charging = flags & 1;
int powered = flags & 2;
float vbat; //, iset;
memcpy(&vbat, &msg->data[1], sizeof(float));
//memcpy(&iset, &msg->data[5], sizeof(float));
_battery.updateBatteryStatus(t, vbat, -1, true, true, 0, 0, false, &_battery_status);
// Update battery charge state
if (charging) {
_bstate = BAT_CHARGING;
}
/* With the usb plugged in and battery disconnected, it appears to be charged. The voltage check ensures that a battery is connected */
else if (powered && !charging && _battery_status.voltage_filtered_v > 3.7f) {
_bstate = BAT_CHARGED;
} else {
_bstate = BAT_DISCHARGING;
}
// announce the battery status if needed, just publish else
if (_battery_pub != nullptr) {
orb_publish(ORB_ID(battery_status), _battery_pub, &_battery_status);
} else {
_battery_pub = orb_advertise(ORB_ID(battery_status), &_battery_status);
}
} else if (msg->type == SYSLINK_RADIO_RSSI) {
uint8_t rssi = msg->data[0]; // Between 40 and 100 meaning -40 dBm to -100 dBm
_rssi = 140 - rssi * 100 / (100 - 40);
} else if (msg->type == SYSLINK_RADIO_RAW) {
handle_raw(msg);
_lastrxtime = t;
} else if ((msg->type & SYSLINK_GROUP) == SYSLINK_RADIO) {
handle_radio(msg);
} else if ((msg->type & SYSLINK_GROUP) == SYSLINK_OW) {
memcpy(&_memory->msgbuf, msg, sizeof(syslink_message_t));
px4_sem_post(&memory_sem);
} else {
PX4_INFO("GOT %d", msg->type);
}
//Send queued messages
if (!_queue.empty()) {
_queue.get(msg, sizeof(syslink_message_t));
send_message(msg);
}
float p = (t % 500000) / 500000.0f;
/* Use LED_GREEN for charging indicator */
if (_bstate == BAT_CHARGED) {
led_on(LED_GREEN);
} else if (_bstate == BAT_CHARGING && p < 0.25f) {
led_on(LED_GREEN);
} else {
led_off(LED_GREEN);
}
//.........这里部分代码省略.........
示例12: tfmini_main
int
tfmini_main(int argc, char *argv[])
{
// check for optional arguments
int ch;
uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
const char *device_path = "";
int myoptind = 1;
const char *myoptarg = nullptr;
while ((ch = px4_getopt(argc, argv, "R:d:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'R':
rotation = (uint8_t)atoi(myoptarg);
PX4_INFO("Setting distance sensor orientation to %d", (int)rotation);
break;
case 'd':
device_path = myoptarg;
PX4_INFO("Using device path '%s'", device_path);
break;
default:
PX4_WARN("Unknown option!");
}
}
/*
* Start/load the driver.
*/
if (!strcmp(argv[myoptind], "start")) {
if (strcmp(device_path, "") != 0) {
tfmini::start(device_path, rotation);
} else {
PX4_WARN("Please specify device path!");
tfmini::usage();
return PX4_ERROR;
}
}
/*
* Stop the driver
*/
if (!strcmp(argv[myoptind], "stop")) {
tfmini::stop();
}
/*
* Test the driver/device.
*/
if (!strcmp(argv[myoptind], "test")) {
tfmini::test();
}
/*
* Reset the driver.
*/
if (!strcmp(argv[myoptind], "reset")) {
tfmini::reset();
}
/*
* Print driver information.
*/
if (!strcmp(argv[myoptind], "info") || !strcmp(argv[1], "status")) {
tfmini::info();
}
PX4_ERR("unrecognized command, try 'start', 'test', 'reset' or 'info'");
return PX4_ERROR;
}
示例13: usage
static int usage()
{
PX4_INFO("usage: camera_trigger {start|stop|status|test}\n");
return 1;
}
示例14: PX4_INFO
void
Navigator::task_main()
{
bool have_geofence_position_data = false;
/* Try to load the geofence:
* if /fs/microsd/etc/geofence.txt load from this file */
struct stat buffer;
if (stat(GEOFENCE_FILENAME, &buffer) == 0) {
PX4_INFO("Loading geofence from %s", GEOFENCE_FILENAME);
_geofence.loadFromFile(GEOFENCE_FILENAME);
}
/* do subscriptions */
_global_pos_sub = orb_subscribe(ORB_ID(vehicle_global_position));
_local_pos_sub = orb_subscribe(ORB_ID(vehicle_local_position));
_gps_pos_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
_sensor_combined_sub = orb_subscribe(ORB_ID(sensor_combined));
_fw_pos_ctrl_status_sub = orb_subscribe(ORB_ID(fw_pos_ctrl_status));
_vstatus_sub = orb_subscribe(ORB_ID(vehicle_status));
_land_detected_sub = orb_subscribe(ORB_ID(vehicle_land_detected));
_home_pos_sub = orb_subscribe(ORB_ID(home_position));
_offboard_mission_sub = orb_subscribe(ORB_ID(mission));
_param_update_sub = orb_subscribe(ORB_ID(parameter_update));
_vehicle_command_sub = orb_subscribe(ORB_ID(vehicle_command));
_traffic_sub = orb_subscribe(ORB_ID(transponder_report));
/* copy all topics first time */
vehicle_status_update();
vehicle_land_detected_update();
global_position_update();
local_position_update();
gps_position_update();
sensor_combined_update();
home_position_update(true);
fw_pos_ctrl_status_update(true);
params_update();
/* wakeup source(s) */
px4_pollfd_struct_t fds[1] = {};
/* Setup of loop */
fds[0].fd = _local_pos_sub;
fds[0].events = POLLIN;
/* rate-limit position subscription to 20 Hz / 50 ms */
orb_set_interval(_local_pos_sub, 50);
while (!_task_should_exit) {
/* wait for up to 1000ms for data */
int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 1000);
if (pret == 0) {
/* Let the loop run anyway, don't do `continue` here. */
} else if (pret < 0) {
/* this is undesirable but not much we can do - might want to flag unhappy status */
PX4_ERR("poll error %d, %d", pret, errno);
usleep(10000);
continue;
} else {
if (fds[0].revents & POLLIN) {
/* success, local pos is available */
local_position_update();
}
}
perf_begin(_loop_perf);
bool updated;
/* gps updated */
orb_check(_gps_pos_sub, &updated);
if (updated) {
gps_position_update();
if (_geofence.getSource() == Geofence::GF_SOURCE_GPS) {
have_geofence_position_data = true;
}
}
/* global position updated */
orb_check(_global_pos_sub, &updated);
if (updated) {
global_position_update();
if (_geofence.getSource() == Geofence::GF_SOURCE_GLOBALPOS) {
have_geofence_position_data = true;
}
}
/* sensors combined updated */
orb_check(_sensor_combined_sub, &updated);
if (updated) {
//.........这里部分代码省略.........
示例15: usage
void usage()
{
PX4_INFO("usage: uart_esc start -d /dev/tty-3");
PX4_INFO(" uart_esc stop");
PX4_INFO(" uart_esc status");
}