colcon-ros is an extension for the colcon build tool that adds support for discovering and building ROS packages (both ROS 1 and ROS 2 style, primarily ROS 2). It enables `colcon` to understand `package.xml` files, making it the standard build system for ROS 2. The current version is 0.5.0, and it follows the release cadence of the wider colcon and ROS 2 ecosystem, with updates often tied to new ROS distributions.
pip install colcon-rosNo compatibility data collected yet for this library.
This quickstart demonstrates how to set up a basic ROS 2 workspace and build a package using `colcon build`, which leverages `colcon-ros` to discover and process ROS-specific package information. The resulting setup files must be sourced to make the built packages available in your environment.
Ensure `colcon-core` is installed (`pip install colcon-core` or via ROS distribution packages like `ros-foxy-colcon-common-extensions`). Verify `colcon --version` works.
For `colcon` to recognize a directory as a ROS package, ensure it contains a valid `package.xml` file at its root. Use `ros2 pkg create` for new packages to generate this file automatically.
Always execute `source install/setup.bash` (or `setup.zsh`, `setup.ps1`) from your workspace root after building and in any new shell where you need to use the workspace contents.
Always use separate terminal sessions for ROS 1 and ROS 2 development. For ROS 2, ensure your environment points to Python 3 and avoid sourcing ROS 1 setup files in the same shell.
Install `colcon-core` by running `pip install colcon-core` or ensure your ROS 2 environment (which typically includes colcon) is properly sourced.
Verify that your ROS package contains a `package.xml` file at its root. Ensure the package is located directly within the `src` folder of your colcon workspace, and that you are running `colcon build` from the workspace root.
Navigate to your ROS 2 workspace root (`~/ros2_ws`) and run `source install/setup.bash` (or `setup.zsh`, `setup.ps1`) before attempting to run ROS 2 commands or Python scripts.
Ensure you are using a Python 3 environment. Try updating pip (`pip install --upgrade pip`) and then installing `colcon-core` first, followed by `colcon-ros`: `pip install colcon-core && pip install colcon-ros`. If using a ROS distribution, prefer installing `colcon-common-extensions` via `apt` or `rosdep`.