ROS
This post is some ROS command from ROS tutorial.
Tutorial commands
Create a ROS workspace
1 | mkdir -p <path>/src |
Create ROS Packages
Packages are the software organization unit of ROS code. Each package can contain libraries, executables, scripts, or other artifacts.
A manifest (package.xml) is a description of a package. It serves to define dependencies between packages and to capture meta information about the package like version, maintainer, license, etc…
One workspace could have several packages. Each package folder has the package.xml
file and the CMakeList.txt
file. There is also a top level CMakeList.txt
file in the <path>/src
provided by catkin.
To make and build a package inside a workspace
1 | cd <path>/src |
Create a executable (node)
In <path>/src
, create a cpp file with main function. Then add dependencies in CMakeList.txt
. Use catkin_make
to build the package.
The executable files are located in catkin_ws/devel/lib/<package_name>
.
ROS Graph - Nodes, Topics and Messages
Nodes: an executable that uses ROS to communicate with other nodes
Topics: Nodes can publish messages to a topic as well as subscribe to a topic to receive messages
Messages: data type used when subscribing or publishing to a topic
Master: Name service for ROS (i.e. helps nodes find each other)
rosout: ROS equivalent of stdout/stderr
roscore: Master + rosout + parameter server
1 | # Run the server |
Below is a rqt_graph figure showing the communications among nodes.
ROS Services
Services are another way that nodes can communicate with each other. Services allow nodes to send a request and receive a response.
1 | # Show all running services |
ROS msg and srv file
msg: msg files are simple text files that describe the fields of a ROS message. They are used to generate source code for messages in different languages
srv: an srv file describes a service. It is composed of two parts: a request and a response
msg files and srv files are located in the src/msg
and src/srv
folders in a package folder. msg files contain the data type and data name; srv files contain the request and response data type and data name which are split by ---
.
Once added new msg files and srv files. The package.xml
and CMakeLists.txt
files are required to be edited to include the new added files. Then the package needs to be make again. The generated codes files for msg and srv are located in devel/include/<package_name>
(C++) and devel/lib/python3/dist-package/<package_name>
(Python).
ROS Parameter Server
The Parameter Server can store integers, floats, boolean, dictionaries, and lists.
rosparam
uses the YAML markup language for syntax.
1 | # Show parameter names in parameter server |
ROS Debug
Record topic data to ROS bag
1 | # in a folder to place the .bag file |
Check nodes status
1 | roscd [package_name] |