Main Content

Header Assignment

Update fields of ROS 2 message header

Since R2023a

  • Header Assignment ROS 2 block icon.

Libraries:
ROS Toolbox / ROS 2

Description

The Header Assignment block updates the values in the header field of a ROS 2 message. When a ROS 2 message contains a header field of type std_msgs/header, you can use this block to update the frame_id and stamp values in its header field. During each sample hit, the block updates the frame_id and stamp fields in the header. The accuracy of the timestamp depends on the step size of the solver. Smaller step sizes result in more accurate timestamps.

Ports

Input

expand all

ROS 2 message with a std_msgs/header field, specified as a nonvirtual bus.

Data Types: bus

Output

expand all

ROS 2 message with an updated header, returned as a nonvirtual bus.

Data Types: bus

Parameters

expand all

Select this parameter to specify the frame that the message data is associated with. Specify the frame ID in the text box enabled when you select this parameter. The block populates the frame_id field of the ROS 2 message header with the specified frame.

Example: base_link

Select this parameter to set the stamp value of the header to the current ROS 2 system time.

Specify the name of the Header field as one of the following:

  • Use the default Header field name — The block sets the name of the header field in the ROS 2 message to the default value, header.

  • Specify your own — Enables a text box in which you can specify a custom name for the header field in the ROS 2 message.

Example: my_custom_header

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2023a