Navigation Menu

Skip to content

vicoslab/dis_tutorial1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tutorial 1: Introduction to ROS2

Development of Inteligent Systems, 2024

The focus of the first exercise is to get familiar with the basics of the ROS 2 platform. You will learn to write your program within the system, to communicate with other programs and execute it properly. This exercise will introduce several important concepts that are crucial for further tutorials, so it is recommended that you refresh the topics after the end of the formal laboratory time at home.

Setting up

To set up ROS 2 on your system, read the official documentation. In this course we will be using release Humble Hawksbill, which is a 4 year LTS release.

The recommended operating systems are Ubuntu/Kubuntu/Lubuntu/etc. 22.04 LTS that support a Tier 1 native installation. Dual booting is generally the most hassle-free method if you have the option. We strongly recommend you to use one of the mentioned operating systems. At worse, at-least one of the team members should have it.

It's also possible to get ROS 2 installed on Windows 10 in several ways:

Note that only the native install will likely be capable of running the Gazebo simulator with GPU acceleration, which is a requirement for realtime simulation. Please note that we might not be able to help you with issues you encounter with a Windows installation of ROS2.

Example code will be available for download as one metapackage (package that only contains other subpackages) per exercise.

Concepts and terminology

ROS 2 is a complex distributed system that introduces a few concepts that are good to know under their established expressions:

More info on the most important concepts:

Exploring ROS 2

Install the turtlesim package, if it's not already installed:

sudo apt install ros-humble-turtlesim

All binary ROS packages are all typically available on apt following the ros-ros_version_name-package_name convention.

Open a new terminal window and run the command:

ros2 run turtlesim turtlesim_node

The ros2 run command is the simplest way of running nodes. With the previous command we started the turtlesim_node which is located in the turtlesim package. In a third terminal run the command:

ros2 run turtlesim draw_square

Now we have started the node draw_square from the turtlesim package. Now open another terminal window and try to find out what's going on in the ROS system with the following commands:

  • ros2 topic
  • ros2 interface
  • ros2 service
  • ros2 param
  • ros2 doctor --report
  • ros2 run rqt_graph rqt_graph

Note that by typing −h or −help after the command verb will print information about the usage of these commands.

Answer the following questions:

  • Which nodes are currently active?
  • What topics are currently active?
  • What is the message type for each topic?
  • What topics is each node publishing to?
  • What topics is each node subscribed to?
  • The used message types belong to which packages?
  • Which parameters can be set on which nodes?
  • Which DDS middleware is currently distributing messages?

Additionally, try to:

  • Get a visualization of all the nodes and topics in the system.
  • Get a printout of all the packages installed in the system.
  • Get a printout of all the messages installed in the system.
  • Print out the messages being published on each topic.
  • Publish a message on each topic.

Explore the usage of other commands that are found in the ROS 2 Cheatsheet. You can also find the full turtlesim documentation here.

Writing a package

Write a package that contains a simple program that you can run using the ros2 run command and outputs a string (e.g. "Hello from ROS!") to the terminal every second.

Use the following tutorials as a starting point:

Now we can add two more nodes, one that sends a message and another one that retrieves it and prints it to the terminal.

Services

In the exercise you have examples of creating a service and a client as well as defining a custom service interface. We define a custom service by specifying the structure of the request that the service will accept and the response that it will return.

Use the following tutorials as a starting point:

See the interfaces doc for a reference of all the possible native data types. The ros2 interfaces list command shows all built messages, services, and actions, which are themselves types that can be used in custom interfaces.

Note that only ament_cmake packages are capable of building interfaces (i.e. services and messages), so if you have an ament_python package you'll need a separate one for message definitions.


🗎 Tips and tricks

For more useful code snippets, check out the ROS 2 Cookbook.

ROS 2 is still under heavy development, as such any issues you encounter might not necessarily be entirely your fault. One example is the SetuptoolsDeprecationWarning: setup.py install is deprecated. warning for all python packages, which can be ignored.

Remember to run colcon build after every change or set up an alias for symlinking python scripts and config files e.g. alias colcon_make='colcon build --symlink-install' If you run into any build errors that don't make any sense try deleting the build, log and install directories and run a fresh build again.

Here are some other useful colcon parameters:

  • --cmake-args=-DCMAKE_BUILD_TYPE=Release (disable debugging, enable compile time optimization)
  • --executor sequential (use single threaded compilation, takes longer but uses less memory which can be useful when compiling large projects on limited hardware)

When in doubt, reset the cache server: ros2 daemon stop; ros2 daemon start

About

Tutorial 1 for the course Development of Intelligent Systems

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published