In the ROS system, no matter the topic, service or action, an important concept is used - communication interface.
Communication is not a person talking to himself, but a communication between two or more people. What is the content of the communication? In order for everyone to understand it easily, we can define a standard structure for the transferred data, which is the communication interface.
Interfaces can reduce dependencies between programs, making it easier for us to use other people's code, and for others to use our code. This is the core goal of ROS, to reduce reinvention of the wheel.
ROS has three commonly used communication mechanisms, namely topics, services, and actions. Through the interface defined by each communication type, various nodes can be organically linked together.
The process of customizing interface messages is similar to the process of writing executable programs in function packages. The main steps are as follows:
In the case of [11.ROS2 action communication server], we have already demonstrated the complete process of creating an action communication interface. You can go back and review it first, so we will not go into details here.
string name
int32 age
float64 height
xxxxxxxxxx
cd ~/yahboomcar_ros2_ws/yahboomcar_ws
colcon build --packages-select pkg_interfaces
source install/setup.bash
xxxxxxxxxx
ros2 interface show pkg_interfaces/msg/Person
Under normal circumstances, the terminal will output content consistent with the Person.msg
file.
xxxxxxxxxx
int32 num1
int32 num2
---
int32 sum
xxxxxxxxxx
cd ~/yahboomcar_ros2_ws/yahboomcar_ws
colcon build --packages-select pkg_interfaces
source install/setup.bash
xxxxxxxxxx
ros2 interface show pkg_interfaces/srv/Add
Under normal circumstances, the terminal will output content consistent with the Person.msg
file.