ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Colcon Build from Any Directory and Need to Re-build for changes in Launch file

asked 2020-11-16 07:08:58 -0600

puru gravatar image

New to ROS2 and Nav2 here.

  1. Currently, my directory structure is like this: home>nav2_ws>src>navigation2. I need my build and install directory to be in nav2_ws. For which currently I call colcon build --symlink-install while in ~/nav2_ws. In ros1- catkin build, I used to call it from anywhere in the workspace (after initialization), and it used to build it at the same location. Is there a quick way to set a single build space and install space in colcon, so that colcon build could be called from anywhere in the workspace?

  2. while using colcon build --symlink-install, it ‘installs’ the workspace, due to which ros2 launch uses all the launch files from the “share” directory (not from the src directory). Now if we change anything in the launch file (src dir), it won’t be reflected in the share directory unless we again do colcon build --symlink-install. Is there way to simplify this? so that user doesn’t have to build it again and again for changes in the launch file?

Ros version - foxy

edit retag flag offensive close merge delete

Comments

2

There's been some talk about item 1 and a proposed change too, respectively https://github.com/colcon/colcon-core... and https://github.com/colcon/colcon-core...

christophebedard gravatar image christophebedard  ( 2020-11-16 08:25:40 -0600 )edit

As for item 2, there's a workaround here: https://github.com/colcon/colcon-core.... It was mentioned in that issue that newer versions of setuptools should allow for symlinking instead of copying, but I'm not sure if it actually happened/is available through colcon.

christophebedard gravatar image christophebedard  ( 2020-11-16 08:36:50 -0600 )edit
1

Thought I'd clarify some potential confusion based on the question wording. colconalways installs things into the install/ dir and the ros2 tools never use anything from src/. What happens with --symlink-install is those files underneath install/ are just links back to the originals under src/ so you can change them and see it take effect without rebuilding. @christophebedard is referring to a bug where python packages don't create those links when they ideally should. It's not clear from the question if that's the problem you're running into.

jdlangs gravatar image jdlangs  ( 2020-11-16 14:16:30 -0600 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2021-12-22 04:56:05 -0600

tnajjar gravatar image

For item 1, you can use provided command line arguments --build-base and --install-base specified here

colcon build --build-base <your-build-path> --install-base <your-install-path>

I expected a --log-base argument as well but it does not seem to exist; instead you can set the COLCON_LOG_PATH environment variable. Just add this to your .bashrc:

export COLCON_LOG_PATH=<your-log-path>

Pro tip:

Instead of always specifying the build and install base in your command you can set your configuration in ~/.colcon/defaults.yaml as specified here

Here is my configuration as reference:

{
    "build": {
        "symlink-install": true,
        "build-base": "/code/ros2_ws/build",
        "install-base": "/code/ros2_ws/install",
        "base-paths": ["/code/ros2_ws/src"]
    },
    "test": {
        "build-base": "/code/ros2_ws/build",
        "install-base": "/code/ros2_ws/install",
        "event-handlers": ["console_direct+"],
        "base-paths": ["/code/ros2_ws/src"],
    }
}
edit flag offensive delete link more
0

answered 2023-05-05 01:36:24 -0600

Hey there!

I had the same problem and kept building in the wrong path, which was super annoying so I created a script with an alias. The alias is defined in project_dir/scripts/aliases.sh and builds a workspace in the directory project_dir/moveit2_ws.

parent_path="$(dirname $(dirname "$(realpath "$0")"))"

alias build-moveit2-ws='colcon \
                            --log-base $parent_path/moveit2_ws/log \
                        build \
                            --base-paths $parent_path/moveit2_ws/src \
                            --install-base $parent_path/moveit2_ws/install \
                            --build-base $parent_path/moveit2_ws/build \
                            --symlink-install \
                            --mixin rel-with-deb-info compile-commands ccache
                        source $parent_path/scripts/source-project.zsh'

Hope I this can help you! Johannes

edit flag offensive delete link more

Question Tools

5 followers

Stats

Asked: 2020-11-16 07:08:58 -0600

Seen: 3,935 times

Last updated: May 05 '23