uORB Read and Write – Flight Controller Message Read/Write Interface Library¶
The uORB Read and Write library provides read and write interfaces to the PX4 flight controller’s internal uORB (micro Object Request Broker) message bus, supporting subscription and publication of various sensor, control, and status messages within the flight controller.
Module List¶
| Module | Function Description |
|---|---|
| uORB Read (Async) | Asynchronously reads uORB messages; non-blocking subscription to internal flight controller data |
| uORB Read Trigger | Event-triggered uORB message reading; supports data acquisition upon event triggers |
| uORB Write | Basic uORB message writing; publishes custom messages to the internal flight controller |
| uORB Write Advanced | Advanced uORB message writing; supports enhanced configuration options for message publication |
| uORB Write Advanced (Dai) | Dai-extended advanced uORB writing; provides additional functionality and interfaces |
uORB Overview¶
uORB is a lightweight publish-subscribe message bus used by the PX4 flight controller for inter-module data exchange.
Key Features¶
| Feature | Description |
|---|---|
| Publish-Subscribe Pattern | Message producers publish messages; consumers subscribe to messages of interest |
| Asynchronous Communication | Publishers and subscribers operate independently, decoupling module dependencies |
| Lightweight and Efficient | Optimized for embedded systems; minimal resource usage and high transmission efficiency |
| Type Safety | Message formats are defined at compile time, preventing runtime type errors |
Usage Scenarios¶
Data Acquisition¶
- Sensor Data: Read raw or fused data from sensors such as IMU, magnetometer, barometer, etc.
- State Estimation: Obtain attitude, position, velocity, and other estimates output by the flight controller’s EKF
- Control Commands: Read control commands output by the flight controller for monitoring or analysis
- System Status: Retrieve system status information including battery, GPS, and RC receiver states
Data Publication¶
- Custom Sensors: Publish external sensor data to the flight controller for use by other internal modules
- Virtual Observations: Publish synthetic sensor data for simulation or testing purposes
- External Control: Enable external intervention in the flight controller by publishing control commands
Usage Considerations¶
Read Operations¶
- Message Update Check: Before reading, verify whether the message has been updated to avoid stale data.
- Subscription Management: Unsubscribe promptly after use to release system resources.
- Multi-Topic Handling: When subscribing to multiple topics, pay attention to processing order and synchronization.
- Data Synchronization: Asynchronously read data may have inconsistent timestamps; interpolation may be required when necessary.
Write Operations¶
- Topic Existence: Ensure the target topic exists before publishing; otherwise, publication may fail.
- Data Integrity: Ensure published message data is complete to prevent subscriber anomalies due to missing fields.
- Publishing Frequency Control: Excessively high publishing frequencies may consume excessive system resources; set appropriate publishing intervals.
- Conflict Avoidance: Avoid publishing to topics already used by native flight controller modules to prevent data conflicts.
Performance Optimization¶
- On-Demand Subscription: Subscribe only to data actually needed to reduce unnecessary data transmission.
- Batch Processing: Where possible, batch read or write operations to minimize system call overhead.
- Cache Utilization: Leverage the flight controller’s message caching mechanism appropriately to balance real-time performance and data completeness.
Related Resources¶
- PX4 Official Documentation – uORB Messaging
- PX4 Official Documentation – uORB Graph
- SimulinkPSP Official Documentation
Note: This document serves as the index for the uORB Read and Write library. For detailed usage instructions for each module, please refer to its respective standalone documentation page.