SITL simulation with PX4

  1. Start PteroSim, spawn the aircraft (e.g. F450) while the simulation is stopped, then press Start on the simulation panel. You may start PX4 SITL before or after starting the simulation; lockstep engages once PX4 connects.

  2. In the control source panel choose PX4:

    Control Source panel with PX4 selected
  3. Run PX4 SITL in WSL2 with lockstep. Set PX4_SIM_HOSTNAME to the Windows host IP as seen from WSL (PX4 connects from WSL to PteroSim on Windows; this is the default gateway, often 172.20.0.1):

    export PX4_SIM_HOSTNAME=$(ip route | awk '/default/ {print $3; exit}')
    PX4_LOCKSTEP=1 PX4_SIM_SPEED_FACTOR=1 make px4_sitl none_iris
    
  4. Launch QGroundControl and open Application Settings:

    QGroundControl main menu and Application Settings
  5. Add or edit a Comm Link to your PX4 instance (UDP to the WSL IP where SITL runs — hostname -I in Ubuntu — typically port 14550):

    QGroundControl communication link configuration QGroundControl comm link edit window with server address
  6. Manually connect using the configured link:

    QGroundControl select link to connect
  7. Head to Plan Flight:

    QGroundControl main screen with Plan Flight highlighted
  8. Create flight plan using options on the pannel on the left of the screen and press Upload button to upload the plan.

    QGroundControl plan editor and Upload button
  9. Exit planning mode and use the takeoff slider.

    QGroundControl takeoff slider prompt