Skip to content

use_colcon

Julian Viereck edited this page Aug 9, 2021 · 15 revisions

Colcon

Description

See in this wiki and in the official documentation

Installation

With pip (installed in /usr/local with sudo is used).

pip install -U colcon-common-extensions pytest setuptools

How to?

In order to build you workspace using colcon you need to go to your workspace root and perform:

colcon build

To build in release mode use

colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release

To build a single package use

colcon build --packages-select <package name>

See colcon build -h for more information.

To build and run the unit-tests:

colcon test 

with verbose output:

colcon test --event-handlers console_direct+

for selected package(s):

colcon test --packages-select package_name --event-handlers console_direct+

Visualize the dependency of your workspace

colcon graph --dot --legend | dot -Tpdf -o /tmp/dependencies_graph.pdf
firefox /tmp/dependencies_graph.pdf

colcon-cd and colcon-argcomplete

In order to activate the colcon-cd and colcon completion functionalities you need to add these lines in you bashrc:

  • debian install
# colcon
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /usr/share/colcon_cd/function/colcon_cd.sh
  • pip install
# colcon
source /usr/local/share/colcon_argcomplete/hook/colcon-argcomplete.bash
source /usr/local/share/colcon_cd/function/colcon_cd.sh

Pybind11

Pybind11 API evolves quickly and sometimes is not super robust, so we decided to stick to some releases. The build time can be drastically minimized by removing the unit-test build from pybind11:

colcon build --cmake-args \
          -DCMAKE_BUILD_TYPE=$BUILD_TYPE # debug/release \
          -DPYBIND11_TEST=OFF # remove only the unit-test from pybind11\
          -DBUILD_TESTING=OFF # remove all unit-test build, use with caution!!!

# One-liner
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DBUILD_TESTING=OFF

Troubleshooting

What if colcon seems to find the wrong python version and install pure python packages with the wrong version in site-packages?

(happened on MacOS): with pip3 install colcon-core a hard copy of colcon is put in /usr/local/bin which is not updated in case you update your python version. Delete this file, remove colcon and install it again. Check that the python script in /usr/local/bin/colcon calls the right version of python

Clone this wiki locally