Skip to content

Changes from ROS1

Nathan Hughes edited this page Apr 16, 2025 · 2 revisions

ROS Client Changes

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::init no longer "removes" ros arguments from the command line, which breaks libraries (glog) that can't handle unknown arguments.

Build System Changes

First, note that catkin is now ament. This has the following implications:

  • Changes how CMakeLists.txt works (see here)
  • Separate cmake packages for different use-cases:
    • ament_cmake is for c++ packages
    • ament_cmake_python is for ROS python packages (e.g., where catkin_python_setup was used)
  • devel no longer exists as a folder
    • Need to turn on symlink-based installation for changes to launch files and python scripts to show up
    • Requires install commands 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_cmake and doing
      find_package(ament_cmake_core QUIET)
      if(${ament_cmake_core_FOUND})
        ament_package(${PROJECT_NAME})
      endif()
      seems to work
    • Seems to be weird interplay between colcon and ament rather than a requirement to use a specific build type. Theoretically should be able to just install an empty file with the package name into share/ament_index/resource_index/packages/ (see here or here) for documentation), but colcon doesn't add the package root path by default to AMENT_PREFIX_PATH without the build type being ament_cmake. This may go away if the install layout is merged rather than separate (which is how system installations work).

Additionally, catkin_python_tools (i.e., the package that handled catkin build, etc.) is now colcon. This has many implications:

  • colcon build works differently than catkin build
    • Will treat the directory you run colcon build in as the workspace
    • Cannot configure workspace with colcon directly (i.e., no more catkin config)
    • Selecting packages to build is done via optional arguments (not positional):
      • colcon build --packages-up-to hydra is equivalent to catkin build hydra
      • colcon build --packages-select hydra is equivalent to catkin build --no-deps hydra
  • colcon can be configuration by file (see docs):
    • Globally in ~/.colcon/defaults.yaml
    • Per workspace in colcon_defaults.yaml
  • colcon clean requires this to be installed
  • Can add or remove common compiler flags via mixins
  • You should almost always run colcon with the additional cmake arg --no-warn-unused-cli to avoid warnings from project-specific cmake options
  • colcon is 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

  • roscd doesn't exist anymore. colcon_cd attempts 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
    function activate_ros2() {
      source $1/setup.zsh
      eval "$(register-python-argcomplete3 ros2)"
      eval "$(register-python-argcomplete3 colcon)"
    }
    
    should fix the issue.

CMake Changes

Pure cmake libraries just work:

  • You should update package.xml to have the right dependencies
  • Unclear if colcon.pkg is a better choice than package.xml at the moment
  • Conventions are good to follow:
    • -Wall and -Wextra are not flags for MVSC, so you need to check the compiler before adding them
    • CTest has a BUILD_TESTING option 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 FetchContent over ExternalProject, 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_setup no longer requires setup.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 and ament_target_dependencies to work

Launch File Changes

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:

  • arg is now always mutable (e.g., no more value attribute)
    • let is the replacement for an immutable argument
  • var is the substitution for using an arg or let value
  • arg and let values are always strings and do not evaluate correctly in python
    • if and not substitutions work though
  • No documentation, so you'll have to skim the python implementation to find various substitutions and actions
  • remap is now only available at the node level (or component level) that functions similarly to how the args tag used to in ROS1.
  • set_remap is now the equivalent of the original remap command
  • Syntactically impossible to specify if or unless for groups in yaml

See here for a good example.

Clone this wiki locally