Generating custom messages for ros1_bridge results in failure to find ROS1 messages... #include <my_msgs/MyCustom.h> fails

asked 2018-08-24 16:20:39 -0600

Rob V gravatar image

ROS: Kinetic, ROS2: Ardent, OS: Ubuntu 16.04

Hello. For a while now, I've been trying to include my custom messages in ros1_bridge's functionality. However, it seems that no matter what I do, it can never find the message's .h files and fails while trying to build ros1_bridge. To build the ros2 core, I am using the ros2.repos file from https://github.com/ros2/ros2/blob/ard... . The steps I take to build the environment are as follows:

cd <path_to_ros2_core_workspace>
src/ament/ament_tools/scripts/ament.py build --skip-packages ros1_bridge
source /opt/ros/kinetic/setup.bash
source <path_to_ros2_core_workspace>/install/local_setup.bash
source <path_to_ros1_overlay_workspace>/install/setup.bash
source <path_to_ros1_project_workspace>/install/setup.bash
src/ament/ament_tools/scripts/ament.py build --only-packages ros1_bridge --force-ament-cmake-configure

While scanning dependencies of ros1_bridge, I get the following error:

In file included from <path_to_ros2_core_workspace>/build/ros1_bridge/generated/get_factory.cpp:25:0:<path_to_ros2_core_workspace>/build/ros1_bridge/generated/my_interfaces_factories.hpp:6:33: fatal error: my_msgs/MyCustom.h: No such file or directory

It's definitely recognizing that the factory to connect the ROS1 package my_msgs and the ROS2 package my_interfaces should be made, it just can't find the absolute file name it seems like. Another message I'm generating has a dependency on std_msgs/Time and it was finding that file properly, so for some reason it just cannot find my custom messages. That to me sounds like I'm not building my ros1 overlay workspace correctly, so here are the contents of that CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8)
project(my_msgs)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  message_generation
)

include_directories(${catkin_INCLUDE_DIRS})

add_message_files(DIRECTORY msg
  FILES
  MyCustom.msg
  MyCustomStdMsgsDepends.msg
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS message_runtime roscpp std_msgs
)

install(
  DIRECTORY include
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

add_executable(pub src/pub.cpp)
target_link_libraries(pub ${catkin_LIBRARIES})

Please help me figure out what it is, I've been trying for ages and I would really like for this to work.

edit retag flag offensive close merge delete

Comments

Just a comment on your ROS1 CMakeLists.txt: you don't have an add_dependencies(..) in there that makes the build dependency of pub on your MyCustom.msg explicit. Build ordering will not take that into account, leading to unpredictable results. Please see the Catkin documentation on ..

gvdhoorn gravatar imagegvdhoorn ( 2018-08-25 03:36:39 -0600 )edit

.. this subject here.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-25 03:36:50 -0600 )edit

Ok, thanks :)

Rob V gravatar imageRob V ( 2018-08-25 07:55:25 -0600 )edit

You are sourcing 3 different ROS 1 workspaces. Only the last of them will be "effective" (including the workspaces which you had sourced when you built the last one). You already suspect that you do something wrong when building the ROS 1 workspaces but you didn't share any information what you did.

Dirk Thomas gravatar imageDirk Thomas ( 2018-08-27 13:50:14 -0600 )edit