Sending actuator_control commands externally. But also need lockstep enabled

Hello,

I am attempting to run PX4 SITL by sending actuator_control commands externally through mavros. And to send actuator_control messages, I had to disable lockstep. All this is working just fine. But there is a problem that my laptop is not a very powerful one and running all this, with lockstep disabled, makes the drone very unstable in simulation and causes the following error:

ERROR [sensors] Accel #0 fail: TIMEOUT!
ERROR [sensors] Sensor Accel #0 failed. Reconfiguring sensor priorities.
WARN [sensors] Remaining sensors after failover event 0: Accel #0 priority: 1
ERROR [sensors] Gyro #0 fail: TIMEOUT!
ERROR [sensors] Sensor Gyro #0 failed. Reconfiguring sensor priorities.
WARN [sensors] Remaining sensors after failover event 0: Gyro #0 priority: 1

I figured the quad is unstable as I am able to send actuator_control at max 10Hz. As a workaround, I tried keeping the lockstep enabled by commenting these lines in the file mavlink_receiver.cpp. (Basically, I stopped the error signal generated when sending actuator_control commands with lockstep enabled). But the quad is getting paused in simulation on doing this.

Is there anywhere else where changes need to be made to make keep lockstep enabled while sending actuator_control signals? Please help.

I don’t think you can expect stable flight for a multirotor with 10 Hz actuator signals! That’s just too slow for a decent control response. I would argue that you need at a minimum 50 Hz and even then performance will be quite poor.

Edit: I’m conflating rate and delay here, so what you really care about is the delay from doing sensing and estimation until you send a signal to control the motor. So it’s mostly all about the delay and not the actual rate. However, the rate is often a good proxy because at 10 Hz it usually means that your worst case delay is 100ms and at 50 Hz it would be 20ms.

Hi, Thanks for the reply.

Yes, the actuator commands at 10Hz would not be enough for a stable flight. But this a constraint that I cannot overcome as of now. So as a workaround, I was attempting to keep the lockstep enabled (by making changes in the mavlink_receiver.cpp file), while sending external actuator commands. I was of the idea that if the simulator waits for the actuator signals to arrive, this problem of quad being unstable would not occur.

Is it required to disable lockstep when sending external actuator signals? If no, where do I need to make changes to keep it enabled.

Yes it’s required to be disabled.

And by the way, I’m guessing that you have some sort of vision/machine learning whatever pipeline and therefore you can’t have update rates higher than 10 Hz. However, this won’t fly, or at least not well.

What I would recommend doing if you have something only coming at 10 Hz is to use the lower faster loops of PX4 and send higher level commands, e.g. velocity or attitude commands but let PX4 control the inner angular rate loops which really need to be at least around 250 Hz to work smoothly.