Hello everybody
I am modifying the PX4 code to create a new module, and in order to do that I am studying the code.
I am looking at commader.cpp V1.10 and there is something that I did not understand.
When the function below is called:

send_vehicle_command(vehicle_command_s::VEHICLE_CMD_DO_SET_MODE, 1, PX4_CUSTOM_MAIN_MODE_MANUAL);

the function below is also called:

**handle_command(vehicle_status_s status_local, const vehicle_command_s &cmd, actuator_armed_s armed_local, uORB::PublicationQueued<vehicle_command_ack_s> &command_ack_pub)

This makes sense to me, but what is not clear is that such function is not called inside send_vehicle_command() function. From tests that I ran, the function is called after the following line:
vcmd_pub.publish(vcmd) in the fuction send_vehicle_command ().
It seems that after the publication, the function is called, but when I follow the .publish(vcmd) I can’t find any caller to that function.

Any advice or comment about it will be appreciate

Thanks in advance

Vehicle commands are published to uORB which is the publish/subscribe system between modules. Usually it is used from one module to another one but it’s possible that here for commander it is actually used within a module.

1 Like

Hello JulianOes
Thank you very much for the response.
I believe that is exactly what happens in commander.
My question is a little bit more low level. How, for example function handle_command() is called. I understand that is a kind of reaction to a publication update when send_vehicle_command() is called and executed, but as I said, I followed the code and I was not able to validate my theory. I ended up at function _generation.fetch_add(1) in uORBDeviceNode.cpp which seems to do this but I was not able to go further.
If you have any comment on that it will be appreciated.