Skip to content

Commit

Permalink
Implemented action bridge (ros2#256)
Browse files Browse the repository at this point in the history
Co-authored-by: tomoya <[email protected]>
Co-authored-by: Geoffrey Biggs <[email protected]>
Signed-off-by: Victor Lopez <[email protected]>
Signed-off-by: Harsh Deshpande <[email protected]>
  • Loading branch information
3 people authored and gavanderhoorn committed Oct 16, 2024
1 parent 0387316 commit 7429c77
Show file tree
Hide file tree
Showing 14 changed files with 1,498 additions and 31 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rclcpp_action REQUIRED)

# find ROS 1 packages
set(cmake_extras_files cmake/find_ros1_package.cmake cmake/find_ros1_interface_packages.cmake)
Expand Down Expand Up @@ -43,6 +44,7 @@ if(NOT ros1_roscpp_FOUND)
endif()

find_ros1_package(std_msgs REQUIRED)
find_ros1_package(actionlib REQUIRED)

# Dependency that we should only look for if ROS 1 is installed (it's not present on a ROS 2
# system; see https://github.com/ros2/ros1_bridge/pull/331#issuecomment-1188111510)
Expand Down Expand Up @@ -146,7 +148,7 @@ foreach(package_name ${ros2_interface_packages})
file(TO_CMAKE_PATH "${interface_file}" interface_name)
get_filename_component(interface_basename "${interface_name}" NAME_WE)
# skipping actions and request and response messages of services
if(NOT "${interface_name}" MATCHES "^(msg|srv)/" OR "${interface_basename}" MATCHES "_(Request|Response)$")
if(NOT "${interface_name}" MATCHES "^(msg|srv|action)/" OR "${interface_basename}" MATCHES "_(Request|Response)$")
continue()
endif()
string(REPLACE "/" "__" interface_name "${interface_name}")
Expand Down Expand Up @@ -227,6 +229,7 @@ ament_target_dependencies(${PROJECT_NAME}
${prefixed_ros1_message_packages}
${ros2_interface_packages}
"rclcpp"
"rclcpp_action"
"ros1_roscpp"
"ros1_std_msgs")

Expand All @@ -242,6 +245,13 @@ custom_executable(static_bridge
target_link_libraries(static_bridge
${PROJECT_NAME})

custom_executable(action_bridge
"src/action_bridge.cpp"
ROS1_DEPENDENCIES
TARGET_DEPENDENCIES ${ros2_interface_packages})
target_link_libraries(action_bridge
${PROJECT_NAME})

custom_executable(parameter_bridge
"src/parameter_bridge.cpp"
ROS1_DEPENDENCIES
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,51 @@ topics:
```
Note that the `qos` section can be omitted entirely and options not set are left default.

# Action bridge

This bridge extends the `ros1_bridge` to support actions. The bridge works in both directions, meaning an action goal can be sent from ROS 1 client to ROS 2 server, or from ROS 2 client to ROS 1 server.

The arguments for the `action_bridge` node are:
`direction`: from client (`ros1` or `ros2`)
e.g.:
- `ROS1` client to `ROS2` server --> `direction` = `ros1`
- `ROS2` client to `ROS1` server --> `direction` = `ros2`

`package`: package of the `ROS1` server node
`type`: action interface type of `ROS1`
`name`: action name

For sending goals from a ROS 2 action client to a ROS 1 action server
```
# Terminal 1 -- action bridge
# Make sure roscore is already running
source <ros1_bridge-install-dir>/setup.bash
ros2 run ros1_bridge action_bridge ros1 actionlib_tutorials Fibonacci fibonacci

# Terminal 2 -- ROS 1 action server
source <ros1-install-dir>/setup.bash
rosrun actionlib_tutorials fibonacci_server

# Terminal 3 -- ROS 2 action client
source <ros2-install-dir>/setup.bash
ros2 run action_tutorials_cpp fibonacci_action_client 20
```
For sending goals from a ROS 1 action client to a ROS 2 action server
```
# Terminal 1 -- action bridge
# Make sure roscore is already running
source <ros1_bridge-install-dir>/setup.bash
ros2 run ros1_bridge action_bridge ros2 action_tutorials_interfaces action/Fibonacci fibonacci

# Terminal 2 -- ROS 2 action server
source <ros2-install-dir>/setup.bash
ros2 run action_tutorials_cpp fibonacci_action_server

# Terminal 3 -- ROS 1 action client
source <ros1-install-dir>/setup.bash
rosrun actionlib_tutorials fibonacci_client 20
```
`dynamic_bridge` has been extended to handle actions as well.
Loading

0 comments on commit 7429c77

Please sign in to comment.