Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (2024)

You're reading the documentation for a version of ROS 2 that has reached its EOL (end-of-life), and is no longer officially supported. If you want up-to-date information, please have a look at Iron.

Goal: Install and use the turtlesim package and rqt tools to prepare for upcoming tutorials.

Tutorial level: Beginner

Time: 15 minutes

Background

Turtlesim is a lightweight simulator for learning ROS 2.It illustrates what ROS 2 does at the most basic level, to give you an idea of what you will do with a real robot or robot simulation later on.

rqt is a GUI tool for ROS 2.Everything done in rqt can be done on the command line, but it provides an easier, more user-friendly way to manipulate ROS 2 elements.

This tutorial touches on core ROS 2 concepts, like the separation of nodes, topics, and services.All of these concepts will be elaborated on in later tutorials; for now, you will simply set up the tools and get a feel for them.

Prerequisites

The previous tutorial, Configuring your ROS 2 environment, will show you how to set up your environment.

Tasks

1 Install turtlesim

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

Install the turtlesim package for your ROS 2 distro:

sudo apt updatesudo apt install ros-eloquent-turtlesim

Check that the package installed:

ros2 pkg executables turtlesim

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

turtlesim draw_squareturtlesim mimicturtlesim turtle_teleop_keyturtlesim turtlesim_node

2 Start turtlesim

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

ros2 run turtlesim turtlesim_node

The simulator window should appear, with a random turtle in the center.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (1)

In the terminal under the command, you will see messages from the node:

[INFO] [turtlesim]: Starting turtlesim with node name /turtlesim[INFO] [turtlesim]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

Here you can see your default turtle’s name is turtle1, and the default coordinates where it spawns.

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

At this point you should have three windows open: a terminal running turtlesim_node, a terminal running turtle_teleop_key and the turtlesim window.Arrange these windows so that you can see the turtlesim window, but also have the terminal running turtle_teleop_key active so that you can control the turtle in turtlesim.

Use the arrow keys on your keyboard to control the turtle.It will move around the screen, using its attached “pen” to draw the path it followed so far.

Note

Pressing an arrow key will only cause the turtle to move a short distance and then stop.This is because, realistically, you wouldn’t want a robot to continue carrying on an instruction if, for example, the operator lost the connection to the robot.

You can see the nodes and their associated services, topics, and actions using the list command:

ros2 node listros2 topic listros2 service listros2 action list

You will learn more about these concepts in the coming tutorials.Since the goal of this tutorial is only to get a general overview of turtlesim, we will use rqt (a graphical user interface for ROS 2) to look at services a little closer.

4 Install rqt

Open a new terminal to install rqt and its plugins:

sudo apt updatesudo apt install ~nros-eloquent-rqt*

To run rqt:

rqt

5 Use rqt

After running rqt the first time, the window will be blank.No worries; just select Plugins > Services > Service Caller from the menu bar at the top.

Note

It may take some time for rqt to locate all the plugins itself.If you click on Plugins, but don’t see Services or any other options, you should close rqt, enter the command rqt --force-discover in your terminal.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (2)

Use the refresh button to the left of the Service dropdown list to ensure all the services of your turtlesim node are available.

Click on the Service dropdown list to see turtlesim’s services, and select the /spawn service.

5.1 Try the spawn service

Let’s use rqt to call the /spawn service.You can guess from its name that /spawn will create another turtle in the turtlesim window.

Give the new turtle a unique name, like turtle2 by double-clicking between the empty single quotes in the Expression column.You can see that this expression corresponds to the name value, and is of type string.

Enter new coordinates for the turtle to spawn at, like x = 1.0 and y = 1.0.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (3)

Note

If you try to spawn a new turtle with the same name as an existing turtle, like your default turtle1, you will get an error message in the terminal running turtlesim_node:

[ERROR] [turtlesim]: A turtle named [turtle1] already exists

To spawn turtle2, you have to call the service by clicking the Call button on the upper right side of the rqt window.

You will see a new turtle (again with a random design) spawn at the coordinates you input for x and y.

If you refresh the service list in rqt, you will also see that now there are services related to the new turtle, /turtle2/…, in addition to /turtle1/….

5.2 Try the set_pen service

Now let’s give turtle1 a unique pen using the /set_pen service:

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (4)

The values for r, g and b, between 0 and 255, will set the color of the pen turtle1 draws with, and width sets the thickness of the line.

To have turtle1 draw with a distinct red line, change the value of r to 255, and the value of width to 5.Don’t forget to call the service after updating the values.

If you return to the terminal where turtle_teleop_node is running and press the arrow keys, you will see turtle1’s pen has changed.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (5)

You’ve probably noticed that there’s no way to move turtle2.You can accomplish this by remapping turtle1’s cmd_vel topic onto turtle2.

6 Remapping

In a new terminal, source ROS 2, and run:

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

Now you can move turtle2 when this terminal is active, and turtle1 when the other terminal running the turtle_teleop_key is active.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent documentation (6)

7 Close turtlesim

To stop the simulation, you can simply close the terminal windows where you ran turtlesim_node and turtle_teleop_key.If you want to keep those terminals open, but end the simulation, you can enter Ctrl + C in the turtlesim_node terminal, and q in the teleop terminal.

Summary

Using turtlesim and rqt is a great way to learn the core concepts of ROS 2.

Next steps

Now that you have turtlesim and rqt up and running, and an idea of how they work, let’s dive in to the first core ROS 2 concept with the next tutorial, Understanding ROS 2 nodes.

Related content

The turtlesim package can be found in the ros_tutorials repo.Make sure to adjust the branch to view the version of turtlesim corresponding to your installed ROS 2 distro.

This community contributed video demonstrates many of the items covered in this tutorial.

Introducing turtlesim and rqt — ROS 2 Documentation: Eloquent  documentation (2024)
Top Articles
Kale Salad With Cranberries, Pecans and Blue Cheese Recipe
Yotam Ottolenghi’s Tomato and Pomegranate Salad Recipe
Aberration Surface Entrances
Hotels Near 625 Smith Avenue Nashville Tn 37203
Food King El Paso Ads
Wellcare Dual Align 129 (HMO D-SNP) - Hearing Aid Benefits | FreeHearingTest.org
Miss Carramello
Barstool Sports Gif
83600 Block Of 11Th Street East Palmdale Ca
Rls Elizabeth Nj
Smokeland West Warwick
123Moviescloud
Oxford House Peoria Il
Ree Marie Centerfold
How Much Is Tj Maxx Starting Pay
Hca Florida Middleburg Emergency Reviews
1773X To
Dragonvale Valor Dragon
Craigs List Tallahassee
Imouto Wa Gal Kawaii - Episode 2
Gas Buddy Prices Near Me Zip Code
3Movierulz
What Individuals Need to Know When Raising Money for a Charitable Cause
Used Patio Furniture - Craigslist
Cornedbeefapproved
Medline Industries, LP hiring Warehouse Operator - Salt Lake City in Salt Lake City, UT | LinkedIn
Cosas Aesthetic Para Decorar Tu Cuarto Para Imprimir
Viduthalai Movie Download
Taylored Services Hardeeville Sc
Albertville Memorial Funeral Home Obituaries
Rubmaps H
Que Si Que Si Que No Que No Lyrics
Wega Kit Filtros Fiat Cronos Argo 1.8 E-torq + Aceite 5w30 5l
Southern Democrat vs. MAGA Republican: Why NC governor race is a defining contest for 2024
Tributes flow for Soundgarden singer Chris Cornell as cause of death revealed
Ippa 番号
Bimmerpost version for Porsche forum?
Build-A-Team: Putting together the best Cathedral basketball team
Enjoy4Fun Uno
MSD Animal Health Hub: Nobivac® Rabies Q & A
Blackstone Launchpad Ucf
Easy Pigs in a Blanket Recipe - Emmandi's Kitchen
Wayne State Academica Login
O'reilly's El Dorado Kansas
Hazel Moore Boobpedia
R: Getting Help with R
Union Supply Direct Wisconsin
Star Sessions Snapcamz
French Linen krijtverf van Annie Sloan
Cars & Trucks near Old Forge, PA - craigslist
Grandma's Portuguese Sweet Bread Recipe Made from Scratch
Myhrkohls.con
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6515

Rating: 4.2 / 5 (43 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.