Basics#
Coding Rules#
The following rules apply when writing code with ROS.
Type |
Naming Rule |
Example |
---|---|---|
Package |
under_scored |
|
Topic, Service |
under_scored |
|
File |
under_scored |
|
Namespace |
under_scored |
|
Variable |
under_scored |
|
Type |
camelCased |
|
Class |
camelCased |
|
Structure |
camelCased |
|
Enumeration Type |
camelCased |
|
Function |
camelCased |
|
Method |
camelCased |
|
Constant |
ALL_CAPITALS |
|
Marco |
ALL_CAPITALS |
|
Standard Unit in ROS#
Quantity |
Unit |
---|---|
Length |
Meter |
Mass |
Kilogram |
Time |
Second |
Current |
Ampere |
Angle |
Radian |
Frequency |
Hertz |
Force |
Newton |
Power |
Watt |
Voltage |
Volt |
Temperature |
Celsius |
Master#
ROS master
is a Server tracking all network addresses of all nodes.
In addition to network addresses it also tracks other information like
parameters. All nodes
must know the network address of the master on
startup ROS_MASTER_URI
.
A master
can be started with the roscore
command or a
roslaunch
will also start a master
if it doesn’t exists already.
roscore
ROS Master Publisher Slave#
Publisher and Subscribers#
With help of the master
, publisher
and subscriber
establish
a peer-to-peer connection. All nodes
must know the network address
of the master on startup ROS_MASTER_URI
.
ROS Publisher Slave#
Any node can publish a message to any topic
Any node can subscribe to any topic
Multiple nodes can publish to the same topic
Multiple nodes can subscribe to the same topic
A node can publish to multiple topics
A node can subscribe to multiple topics
Catkin Overview#
src/
Folder#
Location for creating or cloning new packages
The command catkin_make
searches only in the src/
folder for packages and builds them
It is a good practice to clone the ros packages into a different folder e.g. ~/git/<package_name>
and create a symlink into you catkin workspace
ls -s ~/git/<package_name>/ ~/catkin_ws/src/
build/
Folder#
catkin_make
create build files and intermediate cache CMake files inside the build/
folder.
devel/
Folder#
catkin_make
builds each package, if successful, the target executable le is created. Executables are stored inside the devel/
folder. Current workspace packages can be access by the command line if the following command is used:
# for bash
source ~/<workspace_name>/devel/setup.bash
# for zsh
source ~/<workspace_name>/devel/setup.zsh
It is beneficial to add this the the ~/.bashrc
or ~/.zshrc
file.
In addtion there is the catkin_tools
program which simplifies the use.
See dedicated page: Catkin Tools
install/
Folder#
After building the executables in the devel/
folder, this executables can be install by:
catkin_make install
See also:
Messages#
Serialization format for structured data
Defined in a
.msg
fileCompiled to C++/Python classes before using them
more info https://wiki.ros.org/Messages