PX4 Host Target:This refers to running PX4 firmware on your development computer (host machine) instead of on actual hardware. It’s mainly used for Software-In-The-Loop (SITL) simulation. - PX4 runs as a process on your PC.
- You can connect it to Gazebo or Simulink for simulation.
- No physical hardware is involved.
Pixhawk 6x (or similar boards):This is the actual flight controller hardware. When you deploy to Pixhawk, you’re doing Hardware-In-The-Loop (HITL) or real flight tests.
- PX4 runs natively on the Pixhawk board.
- You can still simulate sensors and actuators via HITL before flying.
Summary:
- Host Target = SITL (pure software)
- Pixhawk = HITL or real flight (hardware)
PX4 blocks in Simulink serve both purposes, depending on your workflow:
- In SITL, they interface with PX4 running on your PC.
- In HITL or deployment, they generate code and communicate with Pixhawk hardware.
For example:
PX4 Actuator Write block:
- In SITL: Sends actuator commands to the PX4 process on your PC.
- In HITL: Sends commands to Pixhawk hardware via MAVLink or serial.
When you generate code for a Simulink model that contains the PX4 Actuator Write block and deploy it either on PX4 Host target or actual hardware like Pixhawk 6x, it would write to the motor. In case of Host Target, the motors are virtual and hence you should see the motors spinning and drone flying in QGC. In case of actual hardware, the PWM pins would output the values you are writing to the PX4 Actuator write in the Simulink model.
You can model your flight controller in Simulink and deploy the generated code on hardware. The workflow is:
- Model your flight controller in Simulink (see the UAV Toolbox Support Package for PX4 AutoPilots controller examples).
- Use PX4 SITL using the PX4 Support Package to validate your controller.
- Once you are happy with the performance of your controller in SITL, you can deploy to actual hardware
I recommend trying out the examples in the UAV Toolbox Support Package for PX4 Autopilots for a detailed understanding of the capabilities.
In Run on board mode, code is generated and deployed on hardware. This is required for real-time behaviour. For Connected IO mode, the data is fetched via IO protocol. No code is generated, but the data is not real time.