主要内容

PX4 uORB Read

R2026b

Read uORB data for the specified uORB topic

  • PX4 uORB Read block

Libraries:
UAV Toolbox Support Package for PX4 Autopilots / PX4 uORB Read and Write Blocks

Description

Add-On Required: This feature requires the UAV Toolbox Support Package for PX4 Autopilots add-on.

The PX4 uORB Read block receives uORB data for the specified uORB topic and instance.

The Msg port outputs the data received as a Simulink® Bus. Use a Bus Selector block to extract signals you want to work with.

uORB (micro Object Request Broker) is the publish-subscribe messaging mechanism in PX4 that enables decoupled communication between publishers and subscribers. uORB supports multi-instance topics, which allow multiple independent publishers of the same message type to coexist under a single topic definition. For example, multiple accelerometers, gyroscopes, or GPS receivers each publish to separate instances of the same topic.

By default, the block subscribes to instance 0 of the selected topic. To subscribe to a different instance, select the Subscribe to other instances check box and specify the instance number.

On each simulation step, the block checks if a new message is available on the specific topic and instance. If a new message is available, the block retrieves the message and converts it to a Simulink bus signal. The Msg port outputs this new message. If a new message is not available, Msg outputs the last received uORB message. If the selected instance has not been published, the Status port outputs 2. If a message has not been received since the start of the simulation, Msg outputs a blank message.

During Normal mode simulation, the block outputs zeroes.

During Connected I/O simulation, this block reads data from the peripherals of the hardware.

Note

When you add a PX4 uORB Read or PX4 uORB Write block to a model, the block automatically creates Simulink nonvirtual bus definitions for the selected PX4 message types. If the model is associated with a Simulink Data Dictionary (.sldd), these bus definitions can be stored in the data dictionary. Review and manage the generated bus definitions as needed to avoid creating unused or duplicate bus objects.

Examples

Ports

Output

expand all

uORB message, returned as a nonvirtual bus. The type of uORB message is specified using the parameter, Topic to subscribe to.

Connect a Bus Selector block to the Msg output to extract the signals.

Data Types: bus

The Status output indicates the state of the received uORB message:

  • 0 - New data received. Msg holds the newly received message.

  • 1 - No new data. Msg holds the last received message.

  • 2 - Instance not published. Msg holds the last received message.

This output can be used to trigger subsystems for processing the new messages received in the uORB network.

Data Types: uint8

Parameters

expand all

Main tab

Select the uORB message type that the block subscribes to. Click Select to browse the available uORB message types.

Select the name of the uORB topic that the block subscribes to for reading the uORB data. The dropdown lists the topics that correspond to the selected uORB message type.

Select this check box to subscribe to a specific instance of the uORB topic. When you select this option, the Select instance parameter appears.

Select the instance number of the uORB topic to subscribe to.

Dependencies

This parameter appears only when you select the Subscribe to other instances check box.

Enter the time interval at which the block reads values from the uORB network.

When you set this parameter to -1, Simulink determines the best sample time for the block based on the block context within the model.

Advanced Tab

  • When you select this option, the read operation runs in Blocking Mode. The read operation is blocked while waiting for the requested data to be available. When waiting for the data, the Status port displays same values from the previous time step. When the data become available, the Data port outputs data bytes, and the Status port changes to 0.

    A task overrun occurs if the target hardware is still waiting for the data to be available when the next read operation is scheduled to begin.

    To fix overruns, increase the time step by using the Sample time parameter.

  • When you clear this option, the read operation runs in Non-Blocking Mode. In this mode, the block does not wait for the requested data to be available.

Specify the amount of time that the block waits for the data during each time step, if the Wait until data received parameter is selected. If timeout occurs, the read operation is aborted.

Dependencies

This parameter appears only when you select the Wait until data received parameter.

Version History

Introduced in R2018b