Hi,
I am trying to communicate ROS1 (Melodic) and ROS2 (Dashing), but I am not able after several attempts ... My ROS2 package is called new_msgs, the same name that in ROS1 workspace, with the same .msg:
YoloList.msg
YoloObstacle.msg
Now I describe the package.xml and CMakeLists.txt of ROS2 workspace:
package.xml:
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>new_msgs</name>
<version>0.0.1</version>
<description>New message defined for ROS2</description>
<maintainer email="[email protected]">root</maintainer>
<license>Apache License 2.0</license>
<author>CGH</author>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(new_msgs)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(std_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)
rosidl_generate_interfaces(new_msgs
"msg/YoloObstacle.msg"
"msg/YoloList.msg"
"msg/Header.msg"
DEPENDENCIES builtin_interfaces std_msgs
)
ament_package()
Now I describe the package.xml and CMakeLists.txt of ROS1 workspace:
<?xml version="1.0"?>
<package format="2">
<name>new_msgs</name>
<version>0.0.0</version>
<description>The new_msgs package</description>
<maintainer email="[email protected]">root</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>sensor_msgs</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- <exec_depend>message_runtime</exec_depend> -->
</package>
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(new_msgs)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
sensor_msgs
std_msgs
message_generation
)
add_message_files(
FILES
Header.msg
YoloList.msg
YoloObstacle.msg
)
generate_messages(
DEPENDENCIES
sensor_msgs
std_msgs
)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES new_msgs
CATKIN_DEPENDS roscpp rospy sensor_msgs std_msgs
#CATKIN DEPENDS message_runtime
# DEPENDS system_lib
)
include_directories(
# include
${catkin_INCLUDE_DIRS}
)
In both cases the content of the messages is exactly the same:
Header.msg
#Common Header for ROS2-ROS1 communication
uint32 seq
int32 sec
uint32 nanosec
string frame_id
YoloObstacle.msg
string type
float64 probability
float64 x1
float64 y1
float64 x2
float64 y2
float64 h
float64 w
float64 l
float64 tx
float64 ty
float64 tz
int8 object_id
YoloList.msg
new_msgs/Header header
YoloObstacle[] yololist # Cannot write the name file with the same msg name (YoloList in this case)
Then, when I try to compile by using:
colcon build --merge-install --symlink-install --packages-select ros1_bridge --cmake-force-configure
I get the following error:
root@robesafe-GT62VR-7RE:~/ros1_bridge_ws# colcon build --merge-install --symlink-install --packages-select ros1_bridge --cmake-force-configure
Starting >>> ros1_bridge
--- stderr: ros1_bridge
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__Header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloObstacle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [parameter_bridge] Error 1
make[1]: *** [CMakeFiles/parameter_bridge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__Header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloObstacle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [dynamic_bridge] Error 1
make[1]: *** [CMakeFiles/dynamic_bridge.dir/all] Error 2
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloList(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__Header(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
libros1_bridge.so: undefined reference to `ros1_bridge::get_factory_new_msgs__msg__YoloObstacle(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [static_bridge] Error 1
make[1]: *** [CMakeFiles/static_bridge.dir/all] Error 2
Any idea :( ??
Carlos
Originally posted by Cram3r95 on ROS Answers with karma: 11 on 2019-08-22
Post score: 0
Original comments
Comment by Dirk Thomas on 2019-08-22:
You don't have to modify the code of the ros1_bridge
. You only have to rebuild it from source following its README.
If that doesn't pickup your custom message package than something is wrong in that package. You might want to share the content of both your ROS 1 and ROS 2 messsage packages in that case.
Comment by Cram3r95 on 2019-08-22:
Yeah sure:
ros2_ws: src: new_msgs: CMakeLists.txt package.xml msg include (not used) src (not used)
The content of msg is: Header.msg YoloList.msg YoloObstacle.msg
In both new_msgs packages (both ROS1 and ROS2) the content is identical (same fields in the messages).
Comment by Dirk Thomas on 2019-08-22:
You need to share the actual content of your message packages if you would like help, e.g. the package.xml.
Comment by Cram3r95 on 2019-08-22:
Ok, it is already done. I have shared the content of both packages and the fields of their messages.
Comment by Dirk Thomas on 2019-08-23:
Please include all your steps to build the bridge including what you have sourced in that shell. Also what version of the ros1_bridge
repo have you cloned? The full logs (either using --event-handlers console_direct+
or from the log/latest_build
directory might also contain valuable information.
Comment by pavel92 on 2019-08-24:
I edited your question to apply proper code formatting and removed the comments in your files to make it shorter and improve readability