Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action bridge #2

Merged
merged 27 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ee7d258
Fix typo (`services_1_or_2` -> `services_1_to_2`) (#379)
AndrejOrsula Sep 13, 2022
518d104
added action templates
hsd-dev May 3, 2020
1a2710a
generate action interface mappings
hsd-dev May 3, 2020
281c4ed
added action factories
hsd-dev May 3, 2020
076317d
added action_bridge executable
hsd-dev May 5, 2020
4288410
fix template
hsd-dev May 5, 2020
cf9e425
hack for GripperCommand
hsd-dev May 5, 2020
5992551
Update include/ros1_bridge/action_factory.hpp
hsd-dev Jun 9, 2020
91358e6
Fix python script errors in action generation
Nov 13, 2020
dc36c20
Foxy and later action compatibility
Nov 13, 2020
3443014
Reorder ros node initialization to allow renaming of bridge
Nov 17, 2020
0e2f7e3
fix error during rebase
hsd-dev May 24, 2021
b82a76c
updated deprecated GoalResponseCallback signature
hsd-dev May 24, 2021
4b31517
Update resource/interface_factories.cpp.em
hsd-dev Nov 18, 2020
136628a
applied uncrustify patches
hsd-dev Nov 18, 2020
d2c6550
fix action mapping rules
hsd-dev Nov 20, 2020
2a82e8c
print available action pairs
hsd-dev Nov 21, 2020
0e54354
get active ROS1 action servers and clients
hsd-dev Nov 21, 2020
234016b
fix mapping rules for services
hsd-dev Nov 24, 2020
875705c
reformatted with uncrustify
hsd-dev May 26, 2021
7567668
map actions in dynamic_bridge
hsd-dev Jun 6, 2021
6ca008b
shutdown internal server before removing the bridge
hsd-dev Jun 7, 2021
bd8b703
updated GoalResponseCallback signature
hsd-dev Jan 12, 2022
828280a
updated README
hsd-dev Jan 12, 2022
91b7730
fix formatting
hsd-dev Jan 13, 2022
2fc402d
add actionlib dependency with condition
hsd-dev Jun 16, 2022
f31c7d0
added dependency on rclcpp_action
hsd-dev Jul 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions 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 @@ -110,7 +112,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 @@ -189,7 +191,7 @@ add_library(${PROJECT_NAME} SHARED
ament_target_dependencies(${PROJECT_NAME}
${prefixed_ros1_message_packages}
${ros2_interface_packages}
"rclcpp"
"rclcpp" "rclcpp_action"
"ros1_roscpp"
"ros1_std_msgs")

Expand All @@ -205,6 +207,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
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ ros2 run demo_nodes_cpp add_two_ints_client
This example expands on example 3 by selecting a subset of topics and services to be bridged.
This is handy when, for example, you have a system that runs most of it's stuff in either ROS 1 or ROS 2 but needs a few nodes from the 'opposite' version of ROS.
Where the `dynamic_bridge` bridges all topics and service, the `parameter_bridge` uses the ROS 1 parameter server to choose which topics and services are bridged.
**Note**: The service bridge is **monodirectional**. You must use either `services_2_to_1` and/or `services_1_or_2` to bridge ROS 2 -> ROS 1 or ROS 1 -> ROS 2 services accordingly.
**Note**: The service bridge is **monodirectional**. You must use either `services_2_to_1` and/or `services_1_to_2` to bridge ROS 2 -> ROS 1 or ROS 1 -> ROS 2 services accordingly.
For example, to bridge only the `/chatter` topic bidirectionally, and the `/add_two_ints service` from ROS 2 to ROS 1 only, create this configuration file, `bridge.yaml`:

```yaml
Expand Down Expand Up @@ -502,3 +502,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 action interface. The bridge works in both directions, meaning an action goal can be sent from ROS1 client to ROS2 server, or from ROS2 client to ROS1 server.

The arguments for `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 ROS2 action client to ROS1 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 -- ROS1 action server
source <ros1-install-dir>/setup.bash
rosrun actionlib_tutorials fibonacci_server

# Terminal 3 -- ROS2 action client
source <ros2-install-dir>/setup.bash
ros2 run action_tutorials_cpp fibonacci_action_client 20
```

For sending goals from ROS1 action client to ROS2 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 -- ROS2 action server
source <ros2-install-dir>/setup.bash
ros2 run action_tutorials_cpp fibonacci_action_server

# Terminal 3 -- ROS1 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