Main Content

PX4 uORB Write

R2026b

Write uORB data for the specified uORB topic

  • PX4 uORB Write 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 Write block publishes uORB data for the specified uORB topic and instance.

The Msg block input accepts a uORB topic (non-virtual bus signal). When publishing to an existing instance, Status is 0 if the instance has been published and 1 if not.

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 actuator output groups, estimator outputs, or sensor streams each publish to separate instances of the same topic.

By default, the block publishes to instance 0 of the selected topic. To publish to a different instance, use the Publish to other instances parameter to select whether to create a new instance or publish to an existing instance.

On each sample hit, the block converts the Msg input from a Simulink® bus signal to a uORB message and publishes it. The block does not distinguish whether the input is a new message; but, merely publishes it on every sample hit.

During Connected I/O simulation, this block writes data to 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

Input

expand all

To specify the type of uORB message, use the parameter, Topic to publish to.

Data Types: bus

Output

expand all

The Status output indicates whether the instance has been published successfully:

  • 0 - The instance has been published.

  • 1 - The instance has not been published.

Dependencies

This port appears only when you set Publish to other instances paramter to Publish to existing instance and select the Output status check box.

Data Types: uint8

The instance number assigned to the newly created uORB topic instance.

Dependencies

This port appears only when you set Publish to other instances to Publish to new instance and select the Output published instance number check box.

Data Types: uint8

Parameters

expand all

Main Tab

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

Select the name of the uORB topic that the block publishes to. The dropdown lists the topics that correspond to the selected uORB message type.

Select the publishing mode for instances of the uORB topic:

  • None - Publish to the default instance of the topic.

  • Publish to new instance - Create and publish to a new instance of the topic. When you select this option, the Output published instance number parameter appears.

  • Publish to existing instance - Publish to an existing instance of the topic. When you select this option, the Select instance and Output status parameters appear.

Select this check box to add an output port that returns the instance number assigned to the newly created instance.

Dependencies

This parameter appears only when you set Publish to other instances to Publish to new instance.

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

Dependencies

This parameter appears only when you set Publish to other instances to Publish to existing instance.

Select this check box to add a Status output port. The Status output indicates whether the instance has been published successfully (0) or not (1).

Dependencies

This parameter appears only when you set Publish to other instances to Publish to existing instance.

Version History

Introduced in R2018b