Hi there!
Well, i’m following the PX4 Dev Guide and i’m trying to complete the step 5 of the writing an application tutorial, which is subscribing my sensor data, the problem is that when i want to compile my code using make it gives me this error:
– Build files have been written to: /home/gesem/Firmware/build_posix_sitl_default
[503/520] Building C object src/examples/px4_s…xamples__px4_simple_app.dir/px4_simple_app.c.o
FAILED: /usr/bin/cc -DBUILD_URI=localhost -DCONFIG_ARCH_BOARD_SITL -DMODULE_NAME="px4_simple_app" -DPX4_MAIN=px4_simple_app_app_main -D__DF_LINUX -D__PX4_LINUX -D__PX4_POSIX -D__STDC_FORMAT_MACROS -Dnoreturn_function=“attribute((noreturn))” -I. -Isrc -Isrc/modules -Isrc/modules/px4_messages -I…/mavlink/include/mavlink -I…/src -I…/src/drivers/boards/sitl -I…/src/include -I…/src/lib -I…/src/lib/DriverFramework/framework/include -I…/src/modules -I…/src/platforms -I…/src/lib/matrix -I…/src/modules/systemlib -I…/src/platforms/posix/include -Iexternal/Install/include -g -std=gnu99 -fno-common -Wall -Werror -Wextra -Wno-sign-compare -Wshadow -Wfloat-equal -Wpointer-arith -Wmissing-declarations -Wno-unused-parameter -Werror=format-security -Werror=array-bounds -Wfatal-errors -Werror=unused-variable -Werror=reorder -Werror=uninitialized -Werror=init-self -Werror=unused-but-set-variable -Wformat=1 -Wdouble-promotion -Werror=double-promotion -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -fvisibility=hidden -include visibility.h -O2 -fno-strict-aliasing -fomit-frame-pointer -funsafe-math-optimizations -ffunction-sections -fdata-sections -fno-strength-reduce -fno-builtin-printf -O2 -fno-strict-aliasing -fomit-frame-pointer -funsafe-math-optimizations -ffunction-sections -fdata-sections -fno-strength-reduce -fno-builtin-printf -std=gnu99 -MMD -MT src/examples/px4_simple_app/CMakeFiles/examples__px4_simple_app.dir/px4_simple_app.c.o -MF src/examples/px4_simple_app/CMakeFiles/examples__px4_simple_app.dir/px4_simple_app.c.o.d -o src/examples/px4_simple_app/CMakeFiles/examples__px4_simple_app.dir/px4_simple_app.c.o -c …/src/examples/px4_simple_app/px4_simple_app.c
…/src/examples/px4_simple_app/px4_simple_app.c: In function ‘px4_simple_app_main’:
…/src/examples/px4_simple_app/px4_simple_app.c:65:11: error: unused variable ‘poll_ret’ [-Werror=unused-variable]
int poll_ret = px4_poll(fds, 1, 1000);
^
compilation terminated due to -Wfatal-errors.
cc1: all warnings being treated as errors
[503/520] Building CXX object src/modules/bott…les/modules__bottle_drop.dir/bottle_drop.cpp.o
ninja: build stopped: subcommand failed.
Makefile:155: recipe for target ‘posix_sitl_default’ failed
make: *** [posix_sitl_default] Error 1
the code that now i have in my px4_simple_app.c is this:
__EXPORT int px4_simple_app_main(int argc, char *argv);
int px4_simple_app_main(int argc, char *argv){
PX4_INFO(“HOLA MUNDO”);int sensor_sub_fd = orb_subscribe(ORB_ID(sensor_combined));
px4_pollfd_struct_t fds = {
{ .fd = sensor_sub_fd, .events = POLLIN },
};
while (true) {
/* wait for sensor update of 1 file descriptor for 1000 ms (1 second) /
int poll_ret = px4_poll(fds, 1, 1000);
if (fds[0].revents & POLLIN) {
/ obtained data for the first file descriptor /
struct sensor_combined_s raw;
/ copy sensors raw data into local buffer */
orb_copy(ORB_ID(sensor_combined), sensor_sub_fd, &raw);
PX4_INFO(“Accelerometer:\t%8.4f\t%8.4f\t%8.4f”,
(double)raw.accelerometer_m_s2[0],
(double)raw.accelerometer_m_s2[1],
(double)raw.accelerometer_m_s2[2]);
}
}
return 0;
}
I’m really new at this, so will really appreciate if anyone can explain me what do i’m doing wrong, and how can i solve it, also if anyone can help me to understand in better way how does it work the uORB publish() / subscribe() messaging it will be fantastic!
I’ve already read the uORB Messaging · PX4 Developer Guide and for the error I’ve already tried to erase the unused variable int poll_ret = px4_poll(fds, 1, 1000); but when i try to test the uORB subscription it tells me: px4_simple_app: command not found .
Thank you !