Connect PX4_sitl to a mathematical model

Hello, I’m trying to connect px4 sitl with a mathematical model and I have 2 problems:

  1. I would like to generate another target when I start px4, something like “make px4_sitl Model” and that instead of starting the simulators it would run my Model.py file. I don’t know exactly how this should be configured.

  2. Now I’m running px4 without a simulator (make px4_sitl none) and I run my model.py separately and communication starts. Everything is working correctly but I can’t get the message from HIL_ACTUATORS_CONTROL. I get to read the initial HEARTBEAT and command long messages and send the HIL_SENSORS and HIL_STATE_QUATERNION messages but I can’t get the action messages.

thanks in advance

  1. Make sure to read about how lockstep simulation works. This might be confusing you. https://dev.px4.io/master/en/simulation/#lockstep-simulation

Thank you very much, I just read it and I have corrected a problem with timestamp. Now PX4 starts communications with QGC but I still do not receive the message from the actuators

Have you tried disabling lockstep and checking if that works? You might also have to arm to get actuator messages.

Yes, I have disabled it and am not getting anything new. How should I arm it? I think it must have something to do with it. Is there an armed message?

I have read in the documentation that arming is a state that sends the PX4 to the simulator in the command HIL_ACTUATORS

I have solved the communication problem with the system_time command which was not sent correctly.
I only have to solve the first problem.

  1. I would like to generate another target when I start px4, something like “make px4_sitl Model ” and that instead of starting the simulators it would run my Model.py file. I don’t know exactly how this should be configured.
  1. You could as a start just run px4 without a simulator: make px4_sitl none and then start the model manually in another terminal.

Thank you.

For now I am doing it like this but I would like to know if it is possible to do it with “make px4_sitl Model”.

Yes it is possible. See here how for example airsim is added:

Thanks, I’m going to try to do it like this