ros1_bridge generating custom messages but when running, throws error "No template specialization for the pair"
I have successfully ran ros1_bridge's dynamic_bridge and passed messages between ROS and ROS2, but cannot quite figure out how to implement custom message definitions. I am using 64-bit Ubuntu 16.04 LTS, ROS Kinetic, and ROS2 Ardent.
Below is my general file structure:
<path_to_folder>
---ros2_ws
------[workspace built from [this](https://github.com/ros2/ros2/wiki/Ament-Tutorial) tutorial, with ardent branch's ros2.repos file]
---my_ros2_ws
------[other ros2 stuff I'm doing that will later utilize the ros1_bridge]
---ros1_bridge_ws_overlay
------catkin_ws_overlay
---------src
------------CMakeLists.txt
------------my_interfaces
---------------CMakeLists.txt
---------------package.xml
---------------msg
------------------MyCustom.msg
---------------src
------------------my_publisher.cpp
------ros2_ws_overlay
---------src
------------my_interfaces
---------------CMakeLists.txt
---------------package.xml
---------------msg
------------------MyCustom.msg
---------------src
------------------my_subscriber.cpp
To specify, I've named the package and message file the same for each workspace, and the message file itself is a simple definition with a couple of float64[] list variables (I copied the exact contents so it matches).
My process to build all of this is as follows (each build is done in a separate terminal):
**Process for building ros1_bridge_ws_overlay/catkin_ws_overlay:
$ source /opt/ros/kinetic/setup.bash
$ cd <path_to_folder>/ros1_bridge_overlay/catkin_ws_overlay/
$ catkin_make
The output for catkin_make clearly generates my custom message and link's my executable.
**Process for building ros1_bridge_ws_overlay/ros2_ws_overlay:
$ source /opt/ros/ardent/setup.bash
$ cd <path_to_folder>/ros1_bridge_overlay/ros2_ws_overlay/
$ ament build
Again, the output clearly generates my custom messages (I can see them in install/include/my_interfaces/msg/) and links my executable.
Now that I've generated my custom messages, I go to my ros2_ws and delete the folder ros2_ws/build/ros1_bridge. Then, to rebuild the ros1_bridge, I do as follows:
**Process for rebuilding ros1_bridge:
$ source <path_to_folder>/ros1_bridge_overlay/catkin_ws_overlay/devel/setup.bash
$ source <path_to_folder>/ros1_bridge_overlay/ros2_ws_overlay/install/local_setup.bash
$ cd <path_to_folder>/ros2_ws
$ src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install
From this, I see important output such as:
[ 2%] Generating generated/get_factory.cpp, generated/get_mappings.cpp, generated/nav_msgs_factories.cpp, generated/actionlib_msgs_factories.cpp, generated/logging_demo_factories.cpp, generated/trajectory_msgs_factories.cpp, generated/test_msgs_factories.cpp, generated/tf2_msgs_factories.cpp, generated/stereo_msgs_factories.cpp, generated/lifecycle_msgs_factories.cpp, generated/visualization_msgs_factories.cpp, generated/geometry_msgs_factories.cpp, generated/shape_msgs_factories.cpp, generated/std_msgs_factories.cpp, generated/rcl_interfaces_factories.cpp, generated/std_srvs_factories.cpp, generated/diagnostic_msgs_factories.cpp, generated/builtin_interfaces_factories.cpp, generated/sensor_msgs_factories.cpp, generated/example_interfaces_factories.cpp, generated/pendulum_msgs_factories.cpp, generated/composition_factories.cpp, generated/my_interfaces_factories.cpp
and
[ 84%] Building CXX object CMakeFiles/ros1_bridge.dir/generated/my_interfaces_factories.cpp.o
At this point, I would guess that my custom message is being processed and built properly. Then, I run all the executables necessary to bring up the bridge (again, all of these are in separate terminals), as so:
**Process for starting roscore:
$ source /opt/ros/kinetic/setup.bash
$ source <path_to_folder>/ros1_bridge_overlay/catkin_ws_overlay/devel/setup.bash
$ roscore
**Process for starting dynamic_bridge:
$ source /opt/ros/kinetic/setup.bash
$ source <path_to_folder>/ros1_bridge_overlay/catkin_ws_overlay/devel/setup.bash
$ source /opt/ros/ardent/setup.bash
$ source <path_to_folder>/ros2_ws/install/local_setup.bash
$ source <path_to_folder>/ros1_bridge_overlay/ros2_ws_overlay/install/local_setup.bash
$ ros2 run ros1_bridge dynamic_bridge
**Process for starting ROS publisher:
$ source /opt/ros/kinetic/setup.bash
$ source <path_to_folder>/ros1_bridge_overlay/catkin_ws_overlay/devel/setup.bash
$ rosrun my_interfaces test_publisher // How ...
Did you run the bridge with
--print-pairs
to see which message types from your custom package are included? The content of the generated filegenerated/my_interfaces_factories.cpp
would reveal similar information.I tried
--print-pairs
andgenerated/my_interfaces_factories.cpp
was not included in the list...Can you share the content of the generated file
generated/my_interfaces_factories.cpp
.Sorry for the delay, I was away from my machine for a little bit - see the edit above for the contents of the file. Thanks again!
The source code doesn't contain any mapping. Please post the exact content of your message files from the ROS 1 as well as 2 workspaces.
See the next edit for the message contents.
Please try to edit the source code of the
ros1_bridge
before building it by adding print statements for the various variables in this sectionMake sure that your message appears in
ros1_msgs
as well asros2_msgs
and that the packages are correlated inpackage_pairs
and the messages inmessage_pairs
.