In this post, we will talk about basics of ROS. We will follow the book A Gentle Introduction to ROS. The ROS version used in the book is Indigo which is ROS1, so we will also install a ROS1 version. The latest ROS1 version is Noetic.
Install ROS1 Noetic
To install Noetic, we can follow the instruction in Ubuntu install of ROS Noetic. The steps are easy to follow and I didn't run into any issues.
If you have already installed other ROS version before and want to uninstall the packages, you could following the instruction mentioned in this post. Here are the commands:
sudo apt-get remove ros-* sudo apt-get purge ros-* sudo apt-get autoremove
If you run into problems with downloading packages from Ubuntu repositories, you may try to clean up the repository list first. More specifically, you could
- Save a backup file for
/etc/apt/sources.list
- Remove ROS related items from
/etc/apt/sources.list
- Remove ROS related files in the
/etc/apt/sources.list.d/
directory.
For more information about Ubuntu repositories, please check https://help.ubuntu.com/community/Repositories/CommandLine
If the installation is successful, we should be able to run the turtle simulation by executing the following three commands in three different terminals
roscore rosrun turtlesim turtlesim_node rosrun turtlesim turtle_teleop_key
Basics
- Packages
- All ROS software is organized into packages.
- All ROS software is part of one package or another.
- Each package is defined by a manifest, which is a file called
package.xml
. - The manifest file contains information such as the package name, version, maintainer, and dependencies.
- The directory containing package.xml is called the package directory.
- ROS node and master
- ROS nodes are running application program. They are the places where the business logic exists.
- To start a node, we can execute command
rosrun package-name executable-name
- We can specify the node name when starting a node. For example:
rosrun turtlesim turtlesim_node __name:=A
- Note that the ROS master does not allow multiple nodes with the same name.
- Node name is not necessarily the same as the executable name.
- To kill a node, we can execute the command
rosnode kill node-name
. - Using
kill
command is better than terminate the node process manually because there are some clean-up work to do. (e.g. unregistering the node from the master). - The communication between nodes is handled by ROS master.
- ROS master is sort of the "main" process of the application.
- We can start ROS master by execution
roscore
. - You should allow the master to continue running for the entire time that you're using ROS.
- Topics and Messages
- The main communication method in ROS1 is publish/subscribe.
- Pub/sub is a many-to-many communication method.
- Messages are grouped by topics.
- ROS also provide a one-to-one communication mechanism called services.
Commands
Command | Description |
---|---|
rospack list | List packages |
rospack find package-name | Find the directory of a single package |
rosls package-name | View the files in a package directory |
roscd package-name | Go to the package directory |
rosrun package-name executable-name | Start a node |
rosnode list | Listing running nodes |
rosnode info node-name | Inspect a node |
rosnode kill node-name | Kill a node. |
rqt_graph | Display the message graph between nodes. |
rostopic list | List active topics. |
rostopic echo topic-name | Echo messages that are being published. |
rostopic hz topic-name | Measure the speed of message publication. |
rostopic bw topic-name | Measure the bandwidth of message publication. |
rostopic info topic-name | Inspect a topic. |
rosmsg show message-type-name | Inspect a message type. |
----- END -----
©2019 - 2022 all rights reserved