Hello everyone, I am xiaoyu, the new generation of migrant workers, xiaoyu’s “Hands-on learning ROS2” video tutorial outline has been decided. I will be able to meet you soon. Today I will share an article in a tutorial about the introduction of ROS2 nodes. Interested partners can have a look.

1. What is ROS2 node

ROS2 son inherits father’s throne, ROS mayor an old age! Pray for peace in Zhengzhou!

There is a story about Li Si and Wang Er, Li Si is a writer, every day will update a novel called “The Legend of The Colourful woman”, Wang er is a bachelor, the most like to read is li Si wrote “the Legend of the Colourful woman”. So we have Li Si publishing novels, Wang Er subscribing novels.

We regard the li si and wang er in the story as the nodes in ROS2, and the legend of the exotic woman is the topic.

In today’s society, which emphasizes division of labor and cooperation, each villager is only responsible for a single module. For example, one villager only works as a carpenter, another sells tofu, another makes wheels, etc. All of them form a social group, just like a complete ecosystem.

The same is true of the nodes in ROS2, where each node is responsible for a single modular function (for example, one node is responsible for controlling wheel rotation, one node is responsible for obtaining data from lidar, one node is responsible for processing lidar data, one node is responsible for positioning, etc.)

2. How do nodes interact?

In the lidar example above, one node is responsible for retrieving the lidar scan data, and one node is responsible for processing the lidar data, such as removing noise.

So nodes have to communicate with each other, so how do they communicate with each other? ROS2 already has four ways of communication ready for you:

  • Topic – switchable viewer
  • Services – services
  • Action
  • Parameters – the parameters

The use and use of these four communication methods, small fish in the fourth and fifth chapter to introduce, when the time will take you hand lift code.

The official gave a picture, you have a general look, to help understand

3. How do I start a node?

Now that we know the concept of nodes, how do we start a node?

Because of the concept of workspaces and packages, fish is moved to the next lecture, where you run a node along with fish to get a feel for it.

Use instructions:

ros2 run <package_name> <executable_name>
Copy the code

Instruction meaning: Start the node under the package.

Example Command output:

ros2 run turtlesim turtlesim_node
Copy the code

You can try the instruction above, the one we used to start the turtle simulator in Chapter 2.

After you run it, you see a little turtle, and then you can try the instructions in the next section to see the node information and list.

4. Ros2 node related commands

Running node (common)

ros2 run <package_name> <executable_name>
Copy the code

View the node list (common) :

ros2 node list
Copy the code

Viewing node information (Common) :

ros2 node info <node_name>
Copy the code

Remap nodes (not important yet)

ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle
Copy the code

The last

Fish found that he was very tired on Thursdays, probably because he worked four days in a row. It would be nice if he could work four days a week. But the new generation of farmer fish is not a chance ha ha!