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?
Hi, I’m pretty sure OP was using v1.11 release for the steps above. There’s a file called state_machine_helper.cpp in it with the line armed->lockdown = true that can be commented out.
Hello! I think your post is very helpful!
However, the link about how to edit the init script is 404 now, so I cannot solve the problem.
Do you still remember how to edit the init script? Thank you a lot!