Now that your ROS environments have been set up properly, let's try testing the ROS-2 nodes. Follow these steps to test the nodes:
- Open a Terminal and source the ROS-2 environment workspace using the following command:
$ initros2
You should see a message, as shown here:
- Let's run the traditional talker node that we saw, similar to ROS-1, using the following command:
$ ros2 run demo_nodes_cpp talker
As you may have noticed, there isn't much difference between the way ROS-1 and ROS-2 run the nodes. You could very well say from the preceding command that the package name is demo_nodes_cpp and that the node name is talker. And instead of rosrun in ROS-1, it is ros2 run in ROS-2.
- In another Terminal, let's initialize ROS-2 once again using the following command:
$ initros2
- Let's run the traditional listener node that we saw, similar to ROS-1, using the following command:
$ ros2 run demo_nodes_py listener
You should see talker saying that it's Publishing: 'Hello World: 1,2...' and listener saying I heard: [Hello World: <respective count>]. The output should look like this:
You could use the ros2 topic list command to see the list of topics that are available as well, as shown here:
This brings us to the end of ROS-2's installation. Now, let's learn to set up our ROS-2 workspace.