17.1. Misc

17.1.1. Build Command

Symlink builds are recommended, so symbolic links to src are used where possible.

$ colcon build --symlink-install

In case compile_commands.json is needed for parsing/autocompletion

$ colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

Attention

If one likes to source the custom workspace in .zshrc, make sure you do not use this environment to build the workspace. Instead run the build command in — for example — bash, where you only source workspaces outside the workspace you want to build! To avoid inheriting environment variables you can run env -i bash or for a docker setup run

$ docker exec -it ros2 bash

Hint

On a native Ubuntu installation, aliases for building the ROS workspaces are quite handy.

alias build_ros="env -i HOME=$HOME USER=$USER TERM=xterm-256color bash -l -c 'source $HOME/ros2_underlay/install/setup.bash && cd $HOME/ros2 && colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'"
alias build_underlay="env -i HOME=$HOME USER=$USER TERM=xterm-256color bash -l -c 'source /opt/ros/iron/setup.bash && cd $HOME/ros2_underlay && colcon build'"

The development workspace and the underlay can be built from any directory with the commands build_ros and build_underlay, respectively.

17.1.2. Installing Dependencies

$ rosdep install --from-paths src -y --ignore-src

17.1.3. Auto-Complete

Attention

ROS2 command line tools do not autocomplete as of this GitHub Issue. While this issue has since been closed, the problem still occurs. To fix it, add the following to .zshrc.

eval "$(register-python-argcomplete3 ros2)"
eval "$(register-python-argcomplete3 colcon)"

Attention

Auto-completing topic names seems to work only after an execution of ros2 topic list. Before the auto-complete gets stuck and has to be canceled by Ctrl + C.

Note

Sourcing install/setup.zsh might reset this. Better source install/local_setup.zsh.

17.1.4. Verifying XACRO

$ check_urdf <(xacro path/to/your/file.xacro)