ros1_bridge 패키지를 이용해서 ROS1 토픽을 ROS2 로 전달하는데 성공했다.
using static_bridge, success bridge ROS1 'scan_2D' topic to ROS2 topic.
https://github.com/ros2/ros1_bridge/blob/master/README.md
작업환경
1) 노트북 환경 : Ubuntu 20.04(Focal) + ROS1 noetic + ROS2 galctic
2) 라즈베리파이 환경 : Ubuntu 16.04(Xenial) + ROS1 kinetic + cyglidar USB 연결
: Ubiquity robotics에서 배포한 우분투+ROS 설치된 이미지 파일 사용
3) CREATE3 : ROS2 (로봇 센서 토픽, 로봇 제어 액션)
< ros1_bridge 설치, 빌드, 수정, 실행 과정>
# SHELL : download ROS1_BRIDGE code at '~/ros2_galactic' (you can change the folder name)
git clone https://github.com/ros2/ros1_bridge.git
# set ROS1 core address (raspberrypi connected with cyglidar)
export ROS_HOSTNAME=192.168.0.39#
export ROS_MASTER_URI=http://192.168.0.39:11311
# run ROS1 and check topic list and message type
/opt/ros/noetic/setup.bash
rostopic list -v
# you can see
>> Published topics:
>> * /scan_2D [sensor_msgs/PointCloud2] 1 publisher
// modify static_bridge.cpp
// bridge one example topic
std::string topic_name = "scan_2D";
std::string ros1_type_name = "sensor_msgs/PointCloud2";
std::string ros2_type_name = "sensor_msgs/msg/PointCloud2";
# SHELL : build code (doing this at ~/ros2_galactic)
export ROS1_INSTALL_PATH=/opt/ros/noetic
export ROS2_INSTALL_PATH=~/ros2_rolling/install
colcon build --symlink-install --packages-skip ros1_bridge
source ${ROS1_INSTALL_PATH}/setup.bash
source ${ROS2_INSTALL_PATH}/setup.bash
colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure
### build took 30 minutes.. I don't know why!!
# SHELL : run 'static_bridge' node
ros2 run ros1_bridge static_bridge
[INFO] [1657369620.191703541] [ros_bridge]: create bidirectional bridge for topic scan_2D
[INFO] [1657369620.881221371] [ros_bridge]: Passing message from ROS 1 sensor_msgs/PointCloud2 to ROS 2 sensor_msgs/msg/PointCloud2 (showing msg only once per type)
# SHELL B : check topic published into ROS2
ros2 topic list
===============================================================
ros1_bridge 설명에 나온 다른 예제들 (아직 잘 안된다)
Example 1a: ROS 1 talker and ROS 2 listener
Shell A:
source ${ROS1_INSTALL_PATH}/setup.bash
roscore
Shell B:
source ${ROS1_INSTALL_PATH}/setup.bash
source ${ROS2_INSTALL_PATH}/setup.bash
export ROS_MASTER_URI=http://192.168.0.39:11311
ros2 run ros1_bridge dynamic_bridge
Shell C:
source ${ROS1_INSTALL_PATH}/setup.bash
rosrun rospy_tutorials talker
Shell D:
source ${ROS2_INSTALL_PATH}/setup.bash
ros2 run demo_nodes_cpp listener
===============================================================
Example 1b: ROS 2 talker and ROS 1 listener
Shell A:
source ${ROS1_INSTALL_PATH}/setup.bash
roscore
# Shell B:
source ${ROS1_INSTALL_PATH}/setup.bash
source ${ROS2_INSTALL_PATH}/setup.bash
export ROS_MASTER_URI=http://192.168.0.39:11311
ros2 run ros1_bridge dynamic_bridge
# Shell C:
source ${ROS2_INSTALL_PATH}/setup.bash
ros2 run demo_nodes_py talker
# Shell D:
source ${ROS1_INSTALL_PATH}/setup.bash
rosrun roscpp_tutorials listener
===============================================================
Example 4: bridge only selected topics and services
<bridge.yaml>
topics:
-
topic: /scan_2D # Topic name on both ROS 1 and ROS 2
type: std_msgs/msg/String # sensor_msgs/PointCloud2 Type of topic to bridge
queue_size: 10 # Queue size
# Shell A (ROS 1 only):
source ${ROS1_INSTALL_PATH}/setup.bash
roscore
Shell B: (ROS 1 only):
source ${ROS1_INSTALL_PATH}/setup.bash
rosparam load bridge.yaml
rosrun rospy_tutorials talker
Shell C: (ROS 1 only):
source ${ROS1_INSTALL_PATH}/setup.bash
rosrun roscpp_tutorials add_two_ints_server
# Shell D:
source ${ROS2_INSTALL_PATH}/setup.bash
ros2 run ros1_bridge parameter_bridge
# Shell E:
source ${ROS2_INSTALL_PATH}/setup.bash
ros2 run demo_nodes_cpp listener
===============================================================
https://dgist-artiv.github.io/vision/2020/02/16/ros1_bridge-in-av-system.html
https://github.com/ros2/ros1_bridge/commit/57ebd138bd9c06ee7b265bd0c79370e449ed06c8
https://industrial-training-master.readthedocs.io/en/melodic/_source/session7/ROS1-ROS2-bridge.html
https://roscon.ros.org/2019/talks/roscon2019_bridging_ros1_to_ros2.pdf
https://dgist-artiv.github.io/vision/2020/02/16/ros1_bridge-in-av-system.html
ROS2 foxy compile error
orasman@orasman-A515-K-AFLUL:~$ colcon build --symlink-install --packages-select ros1_bridge --cmake-force-configure
Starting >>> ros1_bridge
[0.561s] WARNING:colcon.colcon_core.shell:The following packages are in the workspace but haven't been built:
- turtlebot3_msgs
- xmlrpcpp
They are being used from the following locations instead:
- /home/orasman/ros2_ws/install/turtlebot3_msgs
- /home/orasman/ros2_ws/install/xmlrpcpp
To suppress this warning ignore these packages in the workspace:
--packages-ignore turtlebot3_msgs xmlrpcpp
[Processing: ros1_bridge]
[Processing: ros1_bridge]
--- stderr: ros1_bridge
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/parameter_bridge.dir/build.make:348: parameter_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:314: CMakeFiles/parameter_bridge.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/dynamic_bridge.dir/build.make:348: dynamic_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:341: CMakeFiles/dynamic_bridge.dir/all] Error 2
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_1_to_2(controller_manager_msgs::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::msg::ControllerState_<std::allocator<void> >&)'
/usr/bin/ld: libros1_bridge.so: undefined reference to `ros1_bridge::Factory<controller_manager_msgs::ControllerState_<std::allocator<void> >, controller_manager_msgs::msg::ControllerState_<std::allocator<void> > >::convert_2_to_1(controller_manager_msgs::msg::ControllerState_<std::allocator<void> > const&, controller_manager_msgs::ControllerState_<std::allocator<void> >&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/static_bridge.dir/build.make:348: static_bridge] Error 1
make[1]: *** [CMakeFiles/Makefile2:233: CMakeFiles/static_bridge.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed <<< ros1_bridge [1min 11s, exited with code 2]
Summary: 0 packages finished [1min 11s]
1 package failed: ros1_bridge
1 package had stderr output: ros1_bridge