diff --git a/README.md b/README.md index ed8e646a86ff8d3b76c39e0bb3a495834630eb87..c58f75d41d4e76eccab0db8f5b5d666a2b3a439c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,141 @@ -# ROS1 Bridge Custom Interfaces w/ Humble on 22.04 (jammy) +# ROS1 Bridge: Custom Messages and Services between ROS1 and ROS2 Humble on Ubuntu 22.04 (jammy) +There is an Ubuntu Focal (20.04) version of this here: https://code.research.uts.edu.au/157607/custom-bridge-focal-example -1. run `./run.sh -b` to build the docker image, copy custom msgs into the docker image and compile ros1 bridge +# Build and run -2. `./run.sh -r` to launch the container and interract with bridge, ros1 and ros2. +Everything runs in a docker container, so it doesn't matter what your local machine has. -3. test the bridge +**1. run `./run.sh -b` to build the docker image, copy custom msgs into the docker image and compile ros1 bridge.** + +This can take a while (we had it take 2305 sec on an XPS 15 9520). + +**2. `./run.sh -r` to launch the container and interact with bridge, ros1 and ros2.** + +Use `docker exec` to get into the containers and run stuff. + +**3. test the bridge** + +(this is not currently working `ros1_bridge not found`) + +``` + source /home/nx/ros1_bridge_ws/install/setup.bash && \ + source /home/nx/rosbridge_general_update_ament.sh '/home/nx/ros1_bridge_ws/install' 'ros1_bridge' &&\ + ros2 run ros1_bridge dynamic_bridge --print-pairs | grep custom + +``` + + +## info + +the docker image has pre-compiled custom ros1 msgs and ros2 msgs for a custom_bridge example package. + +* No ros1 desktop install, nothing to source, upon launching fresh shell run `rosversion -d` to return Debian as distro. + +* `$HOME/ros2_ws` contains ros2 humble install from src + +* `$HOME/custom_bridge_ros1_ws` contains ros1 custom package + +* `$HOME/custom_bridge_ros2_ws` contains ros2 custom package + +* `$HOME/ros1_bridge_ws` contains ros1_bridge src files and pre-compiled build + +you can run the container to interact/launch ros1 & ros2 nodes. + + +## example 1: custom msg example + +* ros1 talker (publish string) +* ros2 listener (subscribe to ros1 topic expecting string) + +`rostopic` or `ros2 topic` `echo /custom_state_topic` + + +1. launch container with `./run.sh -r --src`, then launch multiple shells with `docker exec -it image bash` into the active container. + +### Shell 1: roscore + +`source $HOME/ros1_ws/devel/setup.bash && roscore` + +### Shell 2: launch bridge + +`source $HOME/ros1_bridge_ws/install/setup.bash && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics` + +### Shell 3: launch ros1 custom talker node + +`source $HOME/custom_bridge_ros1_ws/devel/setup.bash && rosrun custom_bridge_msgs custom_talker` + +### Shell 4: launch ros2 custom listener node + +`source $HOME/custom_bridge_ros2_ws/install/setup.bash && ros2 run custom_bridge_msgs custom_listener` + + +## example 2: custom service example one + +* ros1 node advertises services +* ros2 node calls ros1 service from custom ros2 ws + +### Shell 1: roscore + +`source $HOME/ros1_ws/devel/setup.bash && roscore` + +### Shell 2: launch bridge + +`source $HOME/ros1_bridge_ws/install/setup.bash && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics` + +### Shell 3: launch ros1 custom service node + +`source $HOME/custom_bridge_ros1_ws/devel/setup.bash && rosrun custom_bridge_msgs custom_service_one` + +### Shell 4: source custom ros2_ws and call ros1 service from ros2 + +`source $HOME/custom_bridge_ros2_ws/install/setup.bash && ros2 service call /custom_service_topic` + + + +## example 3: custom service example two + +* ros2 node advertises services +* ros1 node calls ros2 service from custom ros1 ws + + +### Shell 1: roscore + +`source $HOME/ros1_ws/devel/setup.bash && roscore` + +### Shell 2: launch bridge + +`source $HOME/ros1_bridge_ws/install/setup.bash && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics` + +### Shell 3: launch ros2 custom service node + +`source $HOME/custom_bridge_ros2_ws/install/setup.bash && ros2 run custom_bridge_msgs custom_service_two` + +### Shell 4: source custom ros1_ws and call ros2 service from ros1 + +`source $HOME/custom_bridge_ros1_ws/devel/setup.bash && rosservice call /custom_service_topic` +(tab to autocomplete) + + +# Important details +- The message, service, and package names in ROS1 and ROS2 must match. + +# FAQ +- **What are "State" and "CustomState"?** + +These are examples of custom messages. + +- **What about "CustomServiceOne" and "CustomServiceTwo"?** + +These are examples of custom services. + +- **What version of ROS1 are you using?** + +Run `rosversion -d` to return `Debian`, not `melodic` or `noetic`. This because we use `ros-core-dev` on Ubuntu 22.04 (as prescribed by ros upstream docs -- https://docs.ros.org/en/humble/How-To-Guides/Using-ros1_bridge-Jammy-upstream.html) + +- **What version of ROS2 are you using?** + +ros2 humble installed from src + +https://docs.ros.org/en/humble/How-To-Guides/Using-ros1_bridge-Jammy-upstream.html#ros-2-from-source -source /home/nx/ros1_bridge_ws/install/setup.bash && source /home/nx/rosbridge_general_update_ament.sh '/home/nx/ros1_bridge_ws/install' 'ros1_bridge' && ros2 run ros1_bridge dynamic_bridge --print-pairs | grep custom \ No newline at end of file diff --git a/custom_bridge_ros1_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv b/custom_bridge_ros1_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv index c19f17f073e8969ac3071ef187303e512f27a60b..4c76764000c0892f3ed9ebd34af199642da6a93c 100644 --- a/custom_bridge_ros1_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv +++ b/custom_bridge_ros1_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv @@ -1,4 +1,4 @@ - +int32 index --- bool success float32 reward diff --git a/custom_bridge_ros2_ws/src/custom_bridge_msgs/CMakeLists.txt b/custom_bridge_ros2_ws/src/custom_bridge_msgs/CMakeLists.txt index 71e8cfd59ed601aae6e773af6c13e9c6405c91ae..77ba65aaee7ba005d85d2371c9a2acd6d2f91510 100644 --- a/custom_bridge_ros2_ws/src/custom_bridge_msgs/CMakeLists.txt +++ b/custom_bridge_ros2_ws/src/custom_bridge_msgs/CMakeLists.txt @@ -55,13 +55,12 @@ include_directories( add_executable(custom_listener "src/custom_listener.cpp" ) - ament_target_dependencies(custom_listener ${pkg_dependencies} ${msg_dependencies} ) - target_link_libraries(custom_listener "${cpp_typesupport_target}") +install(TARGETS custom_listener DESTINATION lib/custom_bridge_msgs) @@ -70,13 +69,12 @@ target_link_libraries(custom_listener "${cpp_typesupport_target}") add_executable(custom_service_two "src/custom_service_two.cpp" ) - ament_target_dependencies(custom_service_two ${pkg_dependencies} ${msg_dependencies} ) target_link_libraries(custom_service_two "${cpp_typesupport_target}") - +install(TARGETS custom_service_two DESTINATION lib/custom_bridge_msgs) ament_export_dependencies(rosidl_default_runtime) diff --git a/custom_bridge_ros2_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv b/custom_bridge_ros2_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv index c19f17f073e8969ac3071ef187303e512f27a60b..4c76764000c0892f3ed9ebd34af199642da6a93c 100644 --- a/custom_bridge_ros2_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv +++ b/custom_bridge_ros2_ws/src/custom_bridge_msgs/srv/CustomServiceTwo.srv @@ -1,4 +1,4 @@ - +int32 index --- bool success float32 reward diff --git a/run.sh b/run.sh index 72ee2fc393eae2af7d8d1edba4e4665de6835296..129565408d008d44d37c4cc3f0facd807603fdb1 100755 --- a/run.sh +++ b/run.sh @@ -34,10 +34,6 @@ docker run \ -it \ --rm \ --user "0" \ - -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ - --env DISPLAY=$DISPLAY \ - --env NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics \ - --env NVIDIA_VISIBLE_DEVICES=all \ --name $name \ $image \ "/bin/bash"