Skip to content
Snippets Groups Projects
Commit 155c92ae authored by finn's avatar finn
Browse files

merge branch felix into master

parents 29370ed6 5908ba85
Branches master
1 merge request!1Update run.sh and readme
# 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
int32 index
---
bool success
float32 reward
......
......@@ -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)
......
int32 index
---
bool success
float32 reward
......
......@@ -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"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment