Iām running a modified version of the PX4 software on a Pixracer. The PWM outputs are set to control slow-moving flaps, rather than rotors, so safety is not really an issue here. However, if these flaps malfunction in flight, it could lead to catastrophic failure of the vehicle. Iām wondering if itās possible to disable HIL lockdown to allow the servos to move in HIL and make testing software changes easier and safer.
Iāve tried commenting out all the lines that set āarmed->lockdown = trueā, but it hasnāt worked. I tried using the debug cable and sending ācommander lockdown offā, but it didnāt work. Iāve also tried logging the āactuator_armedā topic, and checking the ālockdownā and āmanual_lockdownā fields, but they seem to indicate lockdown is off. I have tested and confirmed that the servos work properly outside of HIL.
Thought Iād reply since I figured out the issue. In HIL, the simulated servo driver, pwm_out_sim, is started alongside the physical servo driver, px4fmu. This causes the device name pwm_output0 (the primary servo channel) to be registered by the simulated driver instead of the physical one. Under normal, non-HIL use, the device name pwm_output0 is occupied by the physical driver. Under HIL, the physical driver is still started, but itās registered under pwm_output1, which means it misses all messages, including primary servo commands.
To fix this, I edited the init script (rcS) to not start pwm_out_sim in HIL. Of course, for this to work, you must also set armed->lockdown = false, or comment out lines that say armed->lockdown = true.
Itās a little irritating that this wasnāt documented - setting lockdown to false is not enough to disable lockdown, you have to disable pwm_out_sim. And the physical driver didnāt throw any warnings, messages, etc. to indicate that it in fact was not registered under the primary servo device name. It took me over a month to figure this out.
Hi @zfurman!
Iām trying to enable motors in HIL mode for a simulation project. In this way, your post was very helpful.
However, the real motors still donāt work.
Do you know if there is another change to be made in the code?
It works, thank you! But when I apply takeoff, the plane in the simulator does not move, the propellers just spinning in its location. I am using Gazebo with a quadcopter Pixhawk 4. Did you encounter this problem?
Brother, I also encountered the same problem and wanted to drive the real motor in HITL mode. I have a few questions to ask you. Which version of PX4 do you use? Can you tell me the specific operating steps and areas that need to be changed?