Ask Your Question
0

Precedence of colcon_ws rclcpp over /opt/ros/crystal version?

asked 2019-02-16 10:27:34 -0500

lucasw gravatar image

updated 2019-02-19 17:42:54 -0500

I forked rclcpp crystal branch and made some modification in my colcon_ws, and then made changes to another package that depends on those modifications, but the includes still point to the opt version.

In file included from /opt/ros/crystal/include/rclcpp/executors/single_threaded_executor.hpp:28:0,
                 from /opt/ros/crystal/include/rclcpp/executors.hpp:22,
                 from /opt/ros/crystal/include/rclcpp/rclcpp.hpp:144,
                 from /home/lucasw/colcon_ws/src/ros2_cpp_py/src/node_init.cpp:35:

ros2 pkg list rclcpp shows the location of the modified version.

Removing the entirety of install and build didn't and rebuilding didn't help (in other cases such as changing a msg or srv deleting the install and build for the altered package seems to be necessary).

If I go into build/ros2_cpp_py and run make VERBOSE=1 I see the opt include is coming first, which corresponds to the order in CMakeFiles/node_init.dir/DependInfo.cmake. I can manually fix the order and build (editing that DependInfo.cmake didn't work, output from it must be cached somewhere) then:

/usr/bin/c++  -DPOCO_NO_AUTOMATIC_LIBS -I/home/lucasw/colcon_ws/src/ros2_cpp_py/include -I/home/lucasw/colcon_ws/install/rclcpp/include -I/opt/ros/crystal/include -Wall -Wextra -Wpedantic -std=gnu++14 -o CMakeFiles/node_init.dir/src/node_init.cpp.o -c /home/lucasw/colcon_ws/src/ros2_cpp_py/src/node_init.cpp
/usr/bin/c++     CMakeFiles/node_init.dir/src/node_init.cpp.o  -o node_init -Wl,-rpath,/home/lucasw/colcon_ws/install/rclcpp/lib:/opt/ros/crystal/lib: /opt/ros/crystal/lib/libament_index_cpp.so /usr/lib/libPocoFoundation.so.50 /opt/ros/crystal/lib/libconsole_bridge.so.0.4 /opt/ros/crystal/lib/libclass_loader.so /home/lucasw/colcon_ws/install/rclcpp/lib/librclcpp.so /opt/ros/crystal/lib/librcl.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_generator_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librcl_interfaces__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librmw_implementation.so -lpthread /opt/ros/crystal/lib/librmw.so /opt/ros/crystal/lib/librcl_logging_noop.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_generator_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/libbuiltin_interfaces__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_generator_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_introspection_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_introspection_cpp.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_c.so /opt/ros/crystal/lib/librosgraph_msgs__rosidl_typesupport_fastrtps_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_cpp.so /opt/ros/crystal/lib/librosidl_typesupport_c.so /opt/ros/crystal/lib/librosidl_generator_c.so /opt/ros/crystal/lib/librcl_yaml_param_parser.so /opt/ros/crystal/lib/librcutils.so -lpthread -ldl -lrt /usr/lib/x86_64-linux-gnu/libpcre.so /usr/lib/x86_64-linux-gnu/libz.so

colcon will then be tricked into relinking the .o built from the right includes if ... (more)

edit retag flag offensive close merge delete

Comments

Wouldn't changing a pkg as "far down" in the dependency trees as rclcpp have the potential to create ABI compatibility issues, leading to many pkgs needing to be recompiled anyway? That's not a reason for overlaying not working btw, just an observation/question prompted by your last comment.

gvdhoorn gravatar imagegvdhoorn ( 2019-02-16 11:35:41 -0500 )edit

That's the kind of issue I'm expecting, but so far the changes are additive and the only nodes I'm using here are ones that are getting recompiled anyhow. I think the compositional architecture of Node is going to help, the components I don't change are insulated from breaking.

lucasw gravatar imagelucasw ( 2019-02-16 12:34:39 -0500 )edit

but so far the changes are additive

that's not a guarantee that you won't break ABI (and is the reason patterns like PIMPL exist).

gvdhoorn gravatar imagegvdhoorn ( 2019-02-17 04:33:32 -0500 )edit

First of all colcon has nothing to do with this behavior. The include directories are exclusively defined in CMake.

Dirk Thomas gravatar imageDirk Thomas ( 2019-02-19 12:55:59 -0500 )edit

Please share the CMake code of the package ros2_cpp_py which is using the wrong include directories.

Dirk Thomas gravatar imageDirk Thomas ( 2019-02-19 12:57:14 -0500 )edit

Oh it's the order of the dependencies in ament_target_dependencies, rclcpp needs to be before any other packages outside of the current ws dependent on it.

lucasw gravatar imagelucasw ( 2019-02-19 15:25:55 -0500 )edit

Please provide steps to reproduce the above error. Just building the referenced repository doesn't fail for me.

Dirk Thomas gravatar imageDirk Thomas ( 2019-02-19 16:55:26 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-02-19 18:14:54 -0500

Dirk Thomas gravatar image

I was able to reproduce the problem with the steps. While the function was supposed to order the include dirs automatically it fails to do so correctly on non-Windows platforms where the separator for the paths in AMENT_PREFIX_PATH is : (instead of ; as on Windows and in CMake).

Please see https://github.com/ament/ament_cmake/... for the proposed patch. You should be able to apply the same diff to the file installed in /opt/ros/crystal/share/ament_cmake_include_directories/cmake/ament_include_directories_order.cmake and your next build should succeed.

edit flag offensive delete link more
-1

answered 2019-02-19 15:30:06 -0500

lucasw gravatar image

updated 2019-02-19 18:49:43 -0500

These options don't solve the problem, they are just workarounds:

Changing this

ament_target_dependencies(node_init
  "ament_index_cpp"
  "class_loader"
  "rclcpp"
  "rcutils"
)

to

ament_target_dependencies(node_init
  "rclcpp"
  "ament_index_cpp"
  "class_loader"
  "rcutils"
)

avoids the problem- ament_index_cpp and/or class_loader are dependent on rclcpp so their includes come first. That doesn't seem like a good requirement to have so alternatively I would have to bring in sources of those two packages and anything else they depend on that also depends on rclcpp- but that is too much work to do manually so ros2_ws sources for everything is easier and less error prone, follow https://index.ros.org/doc/ros2/Instal... instead of any of this.

edit flag offensive delete link more

Comments

This is certainly not the proper fix for the problem. The CMake function is supposed to order the include directories based on the order of your workspaces: https://github.com/ament/ament_cmake/...

Dirk Thomas gravatar imageDirk Thomas ( 2019-02-19 16:50:06 -0500 )edit

This looks like the relevant code:

ament_include_directories_order(ordered_include_dirs ${include_dirs})

https://github.com/ament/ament_cmake/...

lucasw gravatar imagelucasw ( 2019-02-19 17:54:41 -0500 )edit
lucasw gravatar imagelucasw ( 2019-02-19 17:57:15 -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

2 followers

Stats

Asked: 2019-02-16 10:27:34 -0500

Seen: 145 times

Last updated: Feb 19