Hauptinhalt

Develop Algorithms and Deploy on PX4 Autopilot

R2026b
Develop algorithms and prepare model for deploying on PX4 Autopilots

Develop algorithms and prepare model for deploying on PX4 Autopilots. These topics provide additional information about model configuration parameters, setting COM ports, and deploying PX4 Autopilots from Simulink®.

Blocks

expand all

I2C Controller Read blockI2C Controller ReadRead data from I2C peripheral device or I2C peripheral device register
I2C Controller Write blockI2C Controller WriteWrite data to I2C peripheral device or I2C peripheral device register
PX4 Analog Input blockPX4 Analog InputMeasure analog voltage applied to an ADC channel
CAN Receive blockPX4 CAN ReceiveReceive message from CAN network (Since R2022b)
CAN Transmit blockPX4 CAN Transmit Transmit message to CAN network (Since R2022b)
Serial Receive blockSerial ReceiveRead data from UART or USART port on PX4 flight controller
Serial Transmit blockSerial TransmitSend serial data to UART or USART port
Accelerometer blockAccelerometerRead sensor_accel uORB topic and obtain three dimensional linear acceleration
Battery blockBatteryRead battery_status uORB topic and obtain details about the battery's state
GPS blockGPSRead vehicle_gps_position uORB topic and obtain GPS coordinates
Gyroscope blockGyroscopeRead sensor_gyro uORB topic and obtain three dimensional rate of rotation
Magnetometer blockMagnetometerRead sensor_mag uORB topic and obtain three dimensional magnetic field
Radio Control Transmitter blockRadio Control TransmitterRead input_rc uORB topic to obtain data from Radio Control Transmitter
Vehicle Attitude blockVehicle AttitudeRead vehicle_odometry uORB topic and obtain attitude measurements
PX4 uORB Message blockPX4 uORB MessageCreate a blank message using specified uORB topic
PX4 uORB Read blockPX4 uORB ReadRead uORB data for the specified uORB topic
PX4 uORB Write blockPX4 uORB WriteWrite uORB data for the specified uORB topic
MAVLink Bridge SourceMAVLink Bridge SourceRead MAVLink data from the Pixhawk board (Since R2022a)
MAVLink Bridge SinkMAVLink Bridge SinkWrite MAVLink data to the Pixhawk board (Since R2022a)
PX4 Read Position SetpointRead the position setpoints published by the PX4 Navigator module in the uORB topic position_setpoint_triplet
PX4 TimestampPX4 TimestampOutput absolute timestamp from the PX4 Autopilot to a Simulink model (Since R2023b)
PX4 ULogPX4 ULogLog Simulink signals to an SD card in ULog format (Since R2023b)
PX4 Write Parameter Simulink blockPX4 Write ParameterWrite PX4 system parameters (Since R2025a)
Read Parameter blockRead ParameterRead PX4 system parameters

Functions

getMATFilesFromPixhawkRetrieve MAT files from SD card inserted on Pixhawk hardware board
px4MATFilestitcherCombine multiple MAT-files retrieved from SD card into a single MAT-file
createPX4uORBMessageCreate custom uORB topic for logging in a Simulink model (Since R2023b)
createCustomPX4ParameterCreate custom PX4 parameter for writing to the PX4 system parameter (Since R2025a)
getLogFilesFromPX4AutopilotRetrieve MDF log files from SD card on PX4 autopilot (Since R2026b)

Topics

Set Up Simulink Model

PX4 Autopilot Peripheral Information

MAVLink Communication with PX4 Autopilots

Additional Information

Troubleshooting

Troubleshooting Deploy to Hardware Issues

Solve the problems when you try to deploy the Simulink model to Generic Board flight controllers.

Resolve Firmware Build Failure Due to Flash Memory Overflow

Troubleshoot flash memory overflow errors when building PX4 firmware with the default board build target file.

Troubleshooting Running Out of File Descriptor Issues

Solve the running out of file descriptor issues.

Troubleshooting USB Issues with Cube Orange on Windows

Solve the USB issues with Cube Orange.

Set COM Port for Upload and Communication in Simulink

Troubleshoot COM port detection failures and manually configure ports for firmware upload and host-target communication on Pixhawk boards in Simulink.

Featured Examples