Help with uORB and the mc_att_control_main.cpp

Hi everybody i have some doubts in the code mc_att_control_main.cpp, first in the code there is a section in which the author “declares” the subscription of many topics as you can see in the next image

After that in the constructor code there a -1, 1 or 0 in parenthesis, as you can see in the next figure

Do you know the meaning of that, please help me, i’m really new in this kind of things. Thanks

1 Like

The subscription variables are file descriptors for uOrb topics (integers), which are marked as invalid in the constructor initializer list by setting them -1.

They are then initialized here:

_gyro_count and _selected_gyro are variables used to choose which gyro topic to use. There may be multiple gyros on a flight controller, each being published on their own sensor_gyro uOrb topic.
Note that int _sensor_gyro_sub[MAX_GYRO_COUNT] is an array of uOrb subscription handles.

_selected_gyro is used to get the data from the appropriate topic here:

Hope that helps.

1 Like

Thanks, it has been helpful. Thanks