ros2message
Create ROS 2 message structures
Description
Examples
Create a String Message
Create a ROS 2 string message.
strMsg = ros2message('std_msgs/String')
strMsg = struct with fields:
MessageType: 'std_msgs/String'
data: ''
Create an empty laser scan message
Create an empty ROS 2 laser scan message.
scanMsg = ros2message("sensor_msgs/LaserScan")
scanMsg = struct with fields:
MessageType: 'sensor_msgs/LaserScan'
header: [1x1 struct]
angle_min: 0
angle_max: 0
angle_increment: 0
time_increment: 0
scan_time: 0
range_min: 0
range_max: 0
ranges: 0
intensities: 0
Input Arguments
msgType
— Message type for a ROS 2 topic
character vector
Message type for a ROS 2 topic, specified as a character vector.
Output Arguments
msg
— ROS 2 message for a given topic
object handle
ROS 2 message for a given topic, returned as an object handle.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
This function supports C/C++ code generation with the limitations:
For messages with fields containing cell array of strings, such as
sensor_msgs/JointState
, accessing those fields in the MATLAB® function is not supported.
Version History
Introduced in R2019bR2022a: Deprecation of Messages
Behavior changed in R2022a
The following messages in std_msgs
is deprecated in ROS 2 Foxy Fitzroy.
Messages |
---|
std_msgs/msg/Bool |
std_msgs/msg/Byte |
std_msgs/msg/ByteMultiArray |
std_msgs/msg/Char |
std_msgs/msg/Float32 |
std_msgs/msg/Float32MultiArray |
std_msgs/msg/Float64 |
std_msgs/msg/Float64MultiArray |
std_msgs/msg/Int16 |
std_msgs/msg/Int16MultiArray |
std_msgs/msg/Int32 |
std_msgs/msg/Int32MultiArray |
std_msgs/msg/Int64 |
std_msgs/msg/Int64MultiArray |
std_msgs/msg/Int8 |
std_msgs/msg/Int8MultiArray |
std_msgs/msg/MultiArrayDimension |
std_msgs/msg/MultiArrayLayout |
std_msgs/msg/String |
std_msgs/msg/UInt16 |
std_msgs/msg/UInt16MultiArray |
std_msgs/msg/UInt32 |
std_msgs/msg/UInt32MultiArray |
std_msgs/msg/UInt64 |
std_msgs/msg/UInt64MultiArray |
std_msgs/msg/UInt8 |
std_msgs/msg/UInt8MultiArray |
See Also
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)