1 Install turtlesim

As always, start by sourcing your setup files in a new terminal, as described in the previous tutorial.

sudo apt update

sudo apt install ros-humble-turtlesim

Check that the package is installed:

ros2 pkg executables turtlesim


The above command should return a list of turtlesim’s executables:

turtlesim draw_square
turtlesim mimic
turtlesim turtle_teleop_key
turtlesim turtlesim_node

2. Start turtlesim

To start turtlesim, enter the following command in your terminal:

ros2 run turtlesim turtlesim_node

3 Use turtlesim

Open a new terminal and source ROS 2 again.

Now you will run a new node to control the turtle in the first node:

ros2 run turtlesim turtle_teleop_key

4 Install rqt

sudo apt update

sudo apt install ~nros-humble-rqt*

5 Use rqt

5.1 Try the spawn service

5.2 Try the set_pen service

6 Remapping

ros2 run turtlesim turtle_teleop_key --ros-args --remap turtle1/cmd_vel:=turtle2/cmd_vel

* If you want to remap the setting in the node you can do like below :

ros2 run turtlesim turtlesim_node --ros-args --remap __node:=my_turtle \
--ros-args --remap turtle1/cmd_vel:=my_turtle/cmd_vel

 

+ Recent posts