-
Notifications
You must be signed in to change notification settings - Fork 4
ROS2 in practice
Nick Ng edited this page Jun 12, 2020
·
1 revision
This is an exploration of ROS 2 development.
- What is the minimal setup required for building ROS 2 packages?
- Focus:
- build systems/pipelines/workflows that are replicable
- Focus:
- What is the minimal setup required for running ROS 2 packages?
- Focus:
- deployment automation
- emulation/virtualization/containerization
- Focus:
- To explain the steps needed to achieve the above.
In the future:
- An exploration of cross-compilation
- Development machine
- Primarily used for development.
- ROS 2 Desktop install.
- A development machine may also be used as a 'build machine' or 'target machine'.
- Build machine
- Primarily used for building.
- ROS 2 Base install.
- Target machine
- Primarily used for running a ROS 2 based application.
- ROS 2 Base install.
In the course of working with ROS 2, many dependencies will be installed in a machine. This leads to:
- dependency hell
- lack of clarity of what is required to build a ROS 2 package, leading to difficulties in replicating build environments.
- lack of clarity of what is required to run a ROS 2 package, leading to difficulties in replicating runtime environments.
This exploration uses Vagrant and Docker to isolate dependencies in order to provide blank slates from which to work from.
The first step is to set up a workspace. Typically, this has the structure:
-
dev_ws/
src/
Example:
mkdir -p dev_ws/src && \
cd dev_ws
The src/
contains the ROS 2 packages to be built. These may be imported into the src/
directory via:
vcs import src < my_project.repos
- manually using a VCS tool (such as
git
)cd src && git clone $MY_PROJECT_REPO_URL && cd ..
- manually copying it into the directory
- or a mix of the above
Example:
cd src && \
git clone https://github.com/ros2/examples.git && \
cd ..
The following steps assume that the ROS 2 installation has been sourced.
- Select the packages to be built.
- Example:
examples_rclcpp_minimal_publisher
examples_rclcpp_minimal_subscriber
SELECTED_PACKAGES="examples_rclcpp_minimal_publisher examples_rclcpp_minimal_subscriber"
- Example:
- List the source paths for these packages.
- Often times source repositories may contain multiple packages, this step excludes unnecessary packages.
- Example:
SOURCE_PATHS=$(colcon list -p --packages-up-to ${SELECTED_PACKAGES}) echo ${SOURCE_PATHS}
- Download and install the dependencies of the selected packages.
- Example:
rosdep install -i -y --from-paths ${SOURCE_PATHS}
- Example:
- Build the selected packages.
- Example:
colcon build --packages-select ${SELECTED_PACKAGES}
- Example:
- List the rosdep keys that the packages defined in those source paths depend on.
- Example:
ROSDEP_KEYS=$(rosdep keys --from-paths ${SOURCE_PATHS}) echo ${ROSDEP_KEYS}
- Example:
- Resolve rosdeps to system dependencies.
- Example:
rosdep resolve ${ROSDEP_KEYS} # the output lists the dependencies that need to installed (on build machines or target machines) # this output will require parsing/processing
- Example output:
#ROSDEP[std_msgs] #apt ros-dashing-std-msgs #ROSDEP[ament_cmake] #apt ros-dashing-ament-cmake #ROSDEP[rclcpp] #apt ros-dashing-rclcpp
- Example:
A Vagrant/Docker-based approach can be found here:
-
https://github.com/ngyewch/ros2-vagrant/tree/dashing
- for ROS 2 dashing