How does arm work in the code?

Hi guys,

Can someone help me understand the flow of arming? I guess px4io checks uORB for arm event during init, then calls commander to arm. But what code posts the arm event on uORB?

Thanks a lot.

Can anyone help? What’s the flow of arming?

I will try to give you a clue.
Suppose you are using a remote to control the drone.
In the commander.cpp, the mode is defaulted to be manual mode, if nothing changed.
In every iteration of this main loop, from line 2482, it will check the position of two sticks.
If the arm position is detected, the arming_state_transition function would be called.
Then, in state_transition_helper.cpp, the system would check whether it is valid to transfer to arm.
Once the arm variable is changed, it will be published to actuator_armed topic in commander.cpp line 2845.
Then px4io or other actuator drivers would subscribe to such topic. Once the armed is set to true, it would make the rotors spin.
If anything is wrong, I appreciate you can share your points.

1 Like

Hi langxm1223,
That really helps me. I know roughly how it works now. Let me read the code to get the details. Thank you very much.