-
Notifications
You must be signed in to change notification settings - Fork 1
Changes from ROS1
Nathan Hughes edited this page Apr 16, 2025
·
2 revisions
High-level changes that are important to know about:
- The convention for private topics has changed and it is no longer possible to do
~name. Every topic and service has to be~/name. -
rclcpp::initno longer "removes" ros arguments from the command line, which breaks libraries (glog) that can't handle unknown arguments.
First, note that catkin is now ament. This has the following implications:
- Changes how
CMakeLists.txtworks (see here) - Separate cmake packages for different use-cases:
-
ament_cmakeis for c++ packages -
ament_cmake_pythonis for ROS python packages (e.g., wherecatkin_python_setupwas used)
-
-
develno longer exists as a folder- Need to turn on symlink-based installation for changes to launch files and python scripts to show up
- Requires
installcommands in cmake to be correct (and to also install configuration files among other things)
- For non-library resources (e.g., configs) for a pure CMake package, you have to register the package with ament for things like
$(find-pkg-share PACKAGE_NAME)to work correctly- Setting the build type to be
ament_cmakeand doingseems to workfind_package(ament_cmake_core QUIET) if(${ament_cmake_core_FOUND}) ament_package(${PROJECT_NAME}) endif()
- Seems to be weird interplay between
colconandamentrather than a requirement to use a specific build type. Theoretically should be able to just install an empty file with the package name intoshare/ament_index/resource_index/packages/(see here or here) for documentation), butcolcondoesn't add the package root path by default toAMENT_PREFIX_PATHwithout the build type beingament_cmake. This may go away if the install layout is merged rather than separate (which is how system installations work).
- Setting the build type to be
Additionally, catkin_python_tools (i.e., the package that handled catkin build, etc.) is now colcon. This has many implications:
-
colcon buildworks differently thancatkin build- Will treat the directory you run
colcon buildin as the workspace - Cannot configure workspace with
colcondirectly (i.e., no morecatkin config) - Selecting packages to build is done via optional arguments (not positional):
-
colcon build --packages-up-to hydrais equivalent tocatkin build hydra -
colcon build --packages-select hydrais equivalent tocatkin build --no-deps hydra
-
- Will treat the directory you run
-
colconcan be configuration by file (see docs):- Globally in
~/.colcon/defaults.yaml - Per workspace in
colcon_defaults.yaml
- Globally in
-
colcon cleanrequires this to be installed - Can add or remove common compiler flags via mixins
- You should almost always run
colconwith the additional cmake arg--no-warn-unused-clito avoid warnings from project-specific cmake options -
colconis unlikely to have colored console printing (but compiler output still will be) - To see the output from various commands, you need to run with
--event-handlers console_direct+
Workspaces have also changed. Note that
-
roscddoesn't exist anymore.colcon_cdattempts to do the same thing, but requires sourcing the workspace you are building (which causes problems) - Do not source a workspace and try to rebuild it!
- Sourcing a workspace with zsh (at least on iron) breaks ros2 autocomplete. Something like
should fix the issue.
function activate_ros2() { source $1/setup.zsh eval "$(register-python-argcomplete3 ros2)" eval "$(register-python-argcomplete3 colcon)" }
Pure cmake libraries just work:
- You should update
package.xmlto have the right dependencies - Unclear if
colcon.pkgis a better choice thanpackage.xmlat the moment - Conventions are good to follow:
-
-Walland-Wextraare not flags for MVSC, so you need to check the compiler before adding them - CTest has a
BUILD_TESTINGoption that you can use to decide if you want to build unit tests or not - Set the minimum cmake version to match the system version on the oldest version of ubuntu you're supporting
- Having
set(BUILD_SHARED_LIBS ON)is a good idea
-
- Use
FetchContentoverExternalProject, but use submodules over either (not being able to build without internet is annoying)
Catkin packages require a few changes:
- Process is documented here for c++ packages
- Note that messages and services are now both "Interfaces"
-
catkin_python_setupno longer requiressetup.py - When linking against ament interface targets, you shouldn't use
${package_name_LIBRARIES}when trying to get private linkage; it is not de-duplicated and will take forever to link against. See the "How-To" guide for how to get private linkage andament_target_dependenciesto work
We prefer yaml launch files unless someone has a strong reason to use xml (conditional groups may be one). For several reasons, we don't consider python a valid option for launch files.
Launch files have the following changes:
-
argis now always mutable (e.g., no morevalueattribute)-
letis the replacement for an immutable argument
-
-
varis the substitution for using anargorletvalue -
argandletvalues are always strings and do not evaluate correctly in python-
ifandnotsubstitutions work though
-
- No documentation, so you'll have to skim the python implementation to find various substitutions and actions
-
remapis now only available at the node level (or component level) that functions similarly to how theargstag used to in ROS1. -
set_remapis now the equivalent of the originalremapcommand - Syntactically impossible to specify
iforunlessfor groups in yaml
See here for a good example.