Hello, I want to use integrate control of PID when the copter fly away from the ground, thus I need to subscribe vehicle_local_position in mc_att_control.c, I have done it by referencing how mc_pos_control do, but it is confusing because any change of the subscribe code will not report errors, even I delete the header “#include <uORB/topics/vehicle_local_position.h>”. Can anyone tell me how to validate whether I have done the right subscribe?
Then try to just add some outputs, just like a in this example code, to see if something gets published:
struct vehicle_local_position_s raw_position;
orb_copy(ORB_ID(att_pos_mocap), position_sub_fd, &raw_position);
// printing the position data into the terminal
PX4_INFO("Local Position:\t%8.4f\t%8.4f\t%8.4f",
(double)raw_position.x,
(double)raw_position.y,
(double)raw_position.z);
Since it seems to work I am not sure why the header is not necessary in your case. Normally you need to include it that the compiler know the uORB function for the vehicle_local_position topic.