ROS control hardware interface for ddsm-210 servo
If you are familiar with ROS 2, here are the quick-and-dirty build instructions.
cd $COLCON_WS
sudo apt-get update
sudo apt-get upgrade
git clone git@github.com:ddsm-210/ddsm-210.git src/ddsm-210
vcs import src --input src/ddsm-210/ddsm-210.iron.repos
vcs import src --input src/ddsm-210/ddsm-210.iron.upstream.repos
source /opt/ros/iron/setup.bash
rosdep install --ignore-src --from-paths src -y -r
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release # Faster and more efficient build type
cd ..
If you end up with missing dependencies, install them using commands from Setup ROS Workspace section.
- Workflow With Docker
- Install and Build
- Running Executables
- Testing and Linting
- Creating a new ROS 2 Package
- References
Workflow With Docker
NOTE: If you do not use Docker in the current workflow you can skip this section and jump to Install and Build
We usually use a separate Docker container for each of the projects/workspaces we work on. An internal tool from Stogl Robotics called Ros Team Workspace (RTW) simplifies the creation and work with Docker based workspaces. The tool is targeted toward developers.
Installation of docker depends on the operating system you are using. Instructions can be found here: Windows, Mac and Linux.
Using Ros Team Workspace (RTW) you can easily with the following command:
setup-ros-workspace-docker WS_FOLDER_NAME ROS_DISTRO
and then after sourcing the new workspace with the _WS_FOLDER_NAME
command, you can switch to the workspace with the:
rtw_switch_to_docker
command.
These instructions assume you are running Ubuntu 20.04:
-
Install ROS 2 Iron. You can stop following along with the tutorial after you complete the section titled: Environment setup. Make sure you setup your environment with:
source /opt/ros/iron/setup.bash
NOTE: You may want to add that line to your
~/.bashrc
NOTE: There is also a
zsh
version of the setup script. -
Install ROS 2 Build Tools. You do not need to build ROS 2 from source. Simply install the tooling under the section titled "Install development tools and ROS tools".
-
Install
ccache
:sudo apt install ccache
-
Setup
colcon mixin
Reference for convenience commands.sudo apt install python3-colcon-mixin colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml colcon mixin update default
-
Create a colcon workspace:
export COLCON_WS=~/workspace/ros_ws_iron mkdir -p $COLCON_WS/src
NOTE: Feel free to change
~/workspace/ros_ws_iron
to whatever absolute path you want.NOTE: Over time you will probably have multiple ROS workspaces, so it makes sense to them all in a subfolder. Also, it is good practice to put the ROS version in the name of the workspace, for different tests you could just add a suffix to the base name
ros_ws_iron
. -
Download the required repositories and install package dependencies:
cd $COLCON_WS git clone git@github.com:ddsm-210/ddsm-210.git src/ddsm-210 vcs import src --input src/ddsm-210/ddsm-210.iron.repos vcs import src --input src/ddsm-210/ddsm-210.iron.repos rosdep install --ignore-src --from-paths src -y -r # install also is there are unreleased packages
Sometimes packages do not list all their dependencies so
rosdep
will not install everything. If you are getting missing dependency errors, try manually install the following packages:sudo apt install ros2-iron-forward_command_controller ros2-iron-joint_state_broadcaster ros2-iron-joint_trajectory_controller ros2-iron-xacro
To configure and build workspace execute following commands:
cd $COLCON_WS
colcon build --symlink-install --mixin rel-with-deb-info compile-commands ccache
See README.md
files of the packages for information regarding running executables.
To use the local workspace you have to source it by using local setup script:
source $COLCON_WS/install/local_setup.bash
Since there are many errors one unintentionally do with wrong sourcing, please check also Notes on Sourcing ROS Workspace.
Sourcing of a workspace appends the binary and resource directories to appropriate environment variables. It is important that you do not run the build command in the same terminal that you have previously sourced your local workspace. This can cause dependency resolution issues. Here is some advice copied from Official ROS Workspace Tutorial on this:
Before sourcing the overlay, it is very important that you open a new terminal, separate from the one where you built the workspace. Sourcing an overlay in the same terminal where you built, or likewise building where an overlay is sourced, may create complex issues.
Sourcing the local_setup of the overlay will only add the packages available in the overlay to your environment.
setup
sources the overlay as well as the underlay it was created in, allowing you to utilize both workspaces.
So, sourcing your main ROS 2 installation’s setup and then the dev_ws overlay’s local_setup, like you just did, is the same as just sourcing dev_ws’s setup, because that includes the environment of the underlay it was created in.
To test the packages packages built from source, use the following command with colcon. In order to run tests and linters you will have had to already built the workspace. To run the tests use following commands:
cd $COLCON_WS
colcon test
colcon test-result
There are --mixin
arguments that can be used to control testing with linters, specifically linters-only
and linters-skip
.
If you need to create a new ROS 2 package it is helpful to start with the official boilerplate for a ROS 2 package.
The command ros2 pkg
can be used to generate the boilerplate details.
For example to create a new ROS 2 package called example_package
with a node called example_node
and library called example_library
use this command:
ros2 pkg create --build-type ament_cmake --node-name example_node --library-name example_library example_package
Here are some useful references for developing with ROS 2: