Configure Environment:
The ROS 2 development environment needs to be correctly configured before use. This can be done in two ways: either sourcing the setup files in every new shell you open, or adding the source command to your startup script. You can refer the tutorial to configure ros 2 environment.
Install colcon:
colcon
is an iteration on the ROS build tools catkin_make, catkin_make_isolated, catkin_tools and ament_tools. For more information on the design of colcon see this document.
sudo apt install python3-colcon-common-extensions
A workspace is a directory containing ROS 2 packages (ROS 2 is version name and not two packages). Before using ROS 2, it’s necessary to source your ROS 2 installation workspace in the terminal you plan to work in. This makes ROS 2’s packages available for you to use in that terminal.
A ROS workspace is a directory with a particular structure. Commonly there is a src
subdirectory. Inside that subdirectory is where the source code of ROS packages will be located. Typically the directory starts otherwise empty.
colcon does out of source builds. By default it will create the following directories as peers of the src
directory:
build
directory will be where intermediate files are stored. For each package a subfolder will be created in which e.g. CMake is being invoked.install
directory is where each package will be installed to. By default each package will be installed into a separate subdirectory.log
directory contains various logging information about each colcon invocation.Note: Compared to catkin there is no devel directory.
First, create a directory (ros2_ws
) to contain our workspace:
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
At this point the workspace contains a single empty directory src
:
.
└── src
1 directory, 0 files
NOTE: Till here is what you need for TASK 0 to get started. Further if you want to explore more on ROS workspace, happy learning...
Let’s clone the examples repository into the src
directory of the workspace: