Ask Your Question
0

Colcon build include path from overlay workspace

asked 2020-07-29 16:55:00 -0500

patrick gravatar image

updated 2020-07-31 13:13:33 -0500

How can I control which include paths will be used when colcon builds a package? I would like to use the includes form a package in my current workspace instead of the ones of the same package in the ros2 underlay workspace. It seems to look in both places, but unfortunately the underlay workspace has priority.

As a concrete example, I'm trying to build the master branch of rosbag2. I am using the latest foxy (patch1) binary release. The build currently fails because it is trying to use the rosbag2_cpp include files from the foxy release when building the rosbag_transport package. Instead it should be looking for the rosbag2_cpp includes in the current workspace. (the max_bagfile_size has been added in rosbag2_cpp/storage_options.hpp on master (current workspace) but it is not present in the foxy release, see error below) I solved the build errors by simply deleting the rosbag2 library out of the ros2 binary installation so that the includes from the current workspace are used. However I am thinking there must be a better way to do this.

Sourcing ros2 environment, then creating a workspace and cloning rosbag2 into it, running colcon build:

--- stderr: rosbag2_transport
/home/pi/ws/src/rosbag2/rosbag2_transport/src/rosbag2_transport/rosbag2_transport_python.cpp: In function ‘PyObject* rosbag2_transport_record(PyObject*, PyObject*, PyObject*)’:
/home/pi/ws/src/rosbag2/rosbag2_transport/src/rosbag2_transport/rosbag2_transport_python.cpp:149:19: error: ‘using StorageOptions = struct rosbag2_cpp::StorageOptions’ {aka ‘struct rosbag2_cpp::StorageOptions’} has no member named ‘max_bagfile_duration’; did you mean ‘max_bagfile_size’?
  149 |   storage_options.max_bagfile_duration = static_cast<uint64_t>(max_bagfile_duration);
      |                   ^~~~~~~~~~~~~~~~~~~~
      |                   max_bagfile_size
make[2]: *** [CMakeFiles/rosbag2_transport_py.dir/build.make:66: CMakeFiles/rosbag2_transport_py.dir/src/rosbag2_transport/rosbag2_transport_python.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/rosbag2_transport_py.dir/all] Error 2
make: *** [Makefile:144: all] Error 2
---
Failed   <<< rosbag2_transport [32.6s, exited with code 2]

Edit: These are the compiler calls without --merge-install:

/usr/bin/c++  -DDEFAULT_RMW_IMPLEMENTATION=rmw_fastrtps_cpp -DPLUGINLIB__DISABLE_BOOST_FUNCTIONS -DROS_PACKAGE_NAME=\"rosbag2_transport\" -DSPDLOG_COMPILED_LIB -Drosbag2_transport_py_EXPORTS -I/usr/include/python3.8 -I/home/pi/ws/src/rosbag2/rosbag2_transport/include -isystem /home/pi/ws/install/rosbag2_compression/include -isystem /home/pi/ros2/opt/yaml_cpp_vendor/include -isystem /home/pi/ros2/include -isystem /home/pi/ws/install/rosbag2_storage/include -isystem /home/pi/ws/install/zstd_vendor/include -isystem /home/pi/ws/install/rosbag2_cpp/include -isystem /home/pi/ws/install/shared_queues_vendor/include/moodycamel -isystem /home/pi/ws/install/shared_queues_vendor/include  -fPIC   -Wall -Wextra -Wpedantic -Werror -std=gnu++14 -o CMakeFiles/rosbag2_transport_py.dir/src/rosbag2_transport/rosbag2_transport_python.cpp.o -c /home/pi/ws/src/rosbag2/rosbag2_transport/src/rosbag2_transport/rosbag2_transport_python.cpp

and with --merge-install:

/usr/bin/c++  -DDEFAULT_RMW_IMPLEMENTATION=rmw_fastrtps_cpp -DPLUGINLIB__DISABLE_BOOST_FUNCTIONS -DROS_PACKAGE_NAME=\"rosbag2_transport\" -DSPDLOG_COMPILED_LIB -Drosbag2_transport_py_EXPORTS -I/usr/include/python3.8 -I/home/pi/ws/src/rosbag2/rosbag2_transport/include -isystem /home/pi/ws/install/include -isystem /home/pi/ros2/opt/yaml_cpp_vendor/include -isystem /home/pi/ros2/include -isystem /home/pi/ws/install/include/moodycamel  -fPIC   -Wall -Wextra -Wpedantic -Werror -std=gnu++14 -o CMakeFiles/rosbag2_transport_py.dir/src/rosbag2_transport/rosbag2_transport_python.cpp.o -c /home/pi/ws/src/rosbag2/rosbag2_transport/src/rosbag2_transport/rosbag2_transport_python.cpp
edit retag flag offensive close merge delete

Comments

I can reproduce this in a foxy container when building in isolation, which is colcon's default. My rosbag2 overlay workspace works just fine when compiling with colcon build --merge-install. At this point I honestly have no idea and I wonder if that's a problem with rosbag2 or something more fundamental.

Karsten gravatar image Karsten  ( 2020-07-30 18:46:05 -0500 )edit

I can confirm that with --merge-install it compiles fine for me too.

patrick gravatar image patrick  ( 2020-07-31 13:08:36 -0500 )edit

I posted the compiler calls, I don't see how the include sequence is generated from the CMakeLists.txt. I'm not familiar enough with the build system to know whether this is a colcon / ament / or rosbag2 issue.

patrick gravatar image patrick  ( 2020-07-31 13:16:36 -0500 )edit

There's an open issue for this already: https://github.com/ros2/rosbag2/issue... I suspect it has something to do when we switched to modern cmake targets in Foxy. I'd recommend watching the ticket for further updates.

Karsten gravatar image Karsten  ( 2020-07-31 13:18:40 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-07-31 15:32:57 -0500

Dirk Thomas gravatar image

The package failed to declare target dependencies and as a result the include directories for that dependency in the overlay isn't being set. Since the (older) headers are found in the underlay it fails with the compiler error complaining that the new symbol doesn't exist.

Please see https://github.com/ros2/rosbag2/pull/479 for the fix.

edit flag offensive delete link more

Comments

Thank you!

patrick gravatar image patrick  ( 2020-07-31 17:48:47 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-07-29 16:55:00 -0500

Seen: 20 times

Last updated: Jul 31