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

Combined branch #1

Merged
merged 48 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
596eb40
Update maintainers (#286)
jacobperron Oct 10, 2020
4567d4c
[forward port] update to use rosidl_parser and .idl files rather than…
wjwwood Nov 24, 2020
db10a88
0.9.5
jacobperron Dec 8, 2020
81b7610
fix bug with sizeof when type of the arrays differ (#298)
wjwwood Dec 8, 2020
3cb1e0b
0.10.0
wjwwood Dec 9, 2020
b520c5f
Fix typo in comments (#297)
Vicidel Dec 22, 2020
08cf32c
Fix logging for updated rclcpp interface (#303)
mjcarroll Dec 22, 2020
ebbc4ca
Changelog.
clalancette Jan 25, 2021
8339080
0.10.1
clalancette Jan 25, 2021
2cd59a6
Update includes after rcutils/get_env.h deprecation (#311)
christophebedard May 4, 2021
5d77ce0
Add GitHub workflow for CI (#310)
hsd-dev May 10, 2021
ba32b22
support services run with multiple threads
May 24, 2021
16c85a6
fix unscrutify
May 25, 2021
f980aba
use only one custom callback with reentrant for service, client and s…
May 25, 2021
50ba40f
fix ros2 callback of ros1_bridge running with multiple threads
May 25, 2021
bb062af
ensure that the message data of each topic is received in order
May 27, 2021
597a205
use custom callbackqueue instead of ros1 global callbackqueue
May 31, 2021
23d065f
adjust creating callbackgroup location and rename the variable
May 31, 2021
f96ce59
update new tag version with v0.2 for ros-tooling/setup-ros
Jun 1, 2021
879dfb8
add option and refactor some code based on review
Jun 8, 2021
0d41087
update test for --multi-threads option
Jun 8, 2021
d514e06
Bump ros-tooling/[email protected] (#323)
sloretz Aug 6, 2021
eceda75
Use FindPython3 and make Python dependency explicit (#322)
sloretz Aug 6, 2021
4c89542
Use rcpputils/scope_exit.hpp instead of rclcpp/scope_exit.hpp (#324)
christophebedard Aug 31, 2021
6979cea
Example for `parameter_bridge` (#330)
LoyVanBeek Oct 18, 2021
ba6e72c
Extend create_bidirectional_bridge to take qos param for ROS2 publisher
LoyVanBeek Oct 14, 2021
7dd23c3
Busy setting up a way to read QoS parameters from ROS1 params
LoyVanBeek Oct 14, 2021
f9dcb47
Parse history qos params
LoyVanBeek Oct 14, 2021
5909480
Call qos_from_params when setting up topics
LoyVanBeek Oct 14, 2021
0846b9f
Configure deadline, lifespan, liveliness_lease_durations
LoyVanBeek Oct 14, 2021
d408ac0
Configure liveliness
LoyVanBeek Oct 14, 2021
4dd0ef0
Add some basic debug text
LoyVanBeek Oct 18, 2021
148e261
Print the QoS settings to stdout when setting them up
LoyVanBeek Oct 18, 2021
6f13f2c
Catch XmlRpc::XmlRpcExceptions when constructing QoS from parameters
LoyVanBeek Oct 18, 2021
b777cbf
Parse liveliness as either int enum value or upper/lower case string …
LoyVanBeek Oct 18, 2021
774330e
Fix formatting with uncrustify
LoyVanBeek Oct 19, 2021
4796dcf
Fix cpplint formatting
LoyVanBeek Oct 19, 2021
a2d10d0
Changelog.
clalancette Nov 5, 2021
859e156
0.10.2
clalancette Nov 5, 2021
c078d34
Clearer logging as suggested by code review
LoyVanBeek Nov 22, 2021
ec44770
Clarify keep_last vs keep_all setting for history
LoyVanBeek Nov 22, 2021
bfa8493
Update package maintainers (#335)
gbiggs Dec 9, 2021
70d0d73
change order in node initialization
sgermanserrano Dec 13, 2021
b7d2032
Merge remote-tracking branch 'multi_thread_remote/topic-support-multi…
Mar 1, 2022
71f80ce
add positive logs
Mar 2, 2022
1ce4bc2
Merge remote-tracking branch 'remap_pr_remote/param_bridge_remap' int…
Mar 3, 2022
e14ae3b
Update readme and notice file
Mar 3, 2022
5f6fb3b
Merge branch 'develop' into combined_branch
Mar 3, 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
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on: [push, pull_request] # on all pushes and PRs

jobs:
ros1_bridge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ros-tooling/[email protected]
with:
required-ros-distributions: "noetic rolling"
- name: Build and test ros1-bridge
uses: ros-tooling/[email protected]
with:
package-name: ros1_bridge
target-ros1-distro: noetic
target-ros2-distro: rolling

22 changes: 22 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
Changelog for package ros1_bridge
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0.10.2 (2021-11-05)
-------------------
* Example for `parameter_bridge` (`#330 <https://github.com/ros2/ros1_bridge/issues/330>`_)
* Use rcpputils/scope_exit.hpp instead of rclcpp/scope_exit.hpp (`#324 <https://github.com/ros2/ros1_bridge/issues/324>`_)
* Use FindPython3 and make Python dependency explicit (`#322 <https://github.com/ros2/ros1_bridge/issues/322>`_)
* Bump ros-tooling/[email protected] (`#323 <https://github.com/ros2/ros1_bridge/issues/323>`_)
* Add GitHub workflow for CI (`#310 <https://github.com/ros2/ros1_bridge/issues/310>`_)
* Update includes after rcutils/get_env.h deprecation (`#311 <https://github.com/ros2/ros1_bridge/issues/311>`_)
* Contributors: Christophe Bedard, Harsh Deshpande, Loy, Shane Loretz

0.10.1 (2021-01-25)
-------------------
* Fix logging for updated rclcpp interface (`#303 <https://github.com/ros2/ros1_bridge/issues/303>`_)
* Fix typo in comments (`#297 <https://github.com/ros2/ros1_bridge/issues/297>`_)
* Contributors: Michael Carroll, Vicidel

0.9.5 (2020-12-08)
------------------
* Update to use rosidl_parser and .idl files rather than rosidl_adapter and .msg files (`#296 <https://github.com/ros2/ros1_bridge/issues/296>`_)
* Update maintainers (`#286 <https://github.com/ros2/ros1_bridge/issues/286>`_)
* Contributors: Jacob Perron, William Woodall

0.9.4 (2020-09-10)
------------------
* use hardcoded QoS (keep all, transient local) for /tf_static topic in dynamic_bridge (`#282 <https://github.com/ros2/ros1_bridge/issues/282>`_)
Expand Down
79 changes: 49 additions & 30 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(xmlrpcpp REQUIRED)

# find ROS 1 packages
set(cmake_extras_files cmake/find_ros1_package.cmake cmake/find_ros1_interface_packages.cmake)
Expand Down Expand Up @@ -122,9 +123,12 @@ set(target_dependencies
"resource/pkg_factories.hpp.em"
"ros1_bridge/__init__.py")

find_package(Python3 REQUIRED COMPONENTS Interpreter)

add_custom_command(
OUTPUT ${generated_files}
COMMAND ${PYTHON_EXECUTABLE} bin/ros1_bridge_generate_factories
COMMAND Python3::Interpreter
ARGS bin/ros1_bridge_generate_factories
--output-path "${generated_path}" --template-dir resource
DEPENDS ${target_dependencies}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down Expand Up @@ -223,35 +227,44 @@ endif()
macro(targets)
set(TEST_BRIDGE_RMW ${rmw_implementation})

configure_file(
test/test_topics_across_dynamic_bridge.py.in
test_topics_across_dynamic_bridge${target_suffix}.py.genexp
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}.py.genexp"
)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
TARGET test_topics_across_dynamic_bridge${target_suffix}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)

configure_file(
test/test_services_across_dynamic_bridge.py.in
test_services_across_dynamic_bridge${target_suffix}.py.genexp
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}.py.genexp"
)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_$<CONFIG>.py"
TARGET test_services_across_dynamic_bridge${target_suffix}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)
list(LENGTH DYNAMIC_BRIDGE_TYPE count)
math(EXPR count "${count}-1")
foreach(i RANGE ${count})
list(GET DYNAMIC_BRIDGE_TYPE ${i} bridge_type)
list(GET DYNAMIC_BRIDGE_ARG ${i} bridge_arg)
set(TEST_BRIDGE_DYNAMIC_BRIDGE_ARG "${bridge_arg}")

configure_file(
test/test_topics_across_dynamic_bridge.py.in
test_topics_across_dynamic_bridge${target_suffix}_${bridge_type}.py.genexp
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_${bridge_type}_$<CONFIG>.py"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_${bridge_type}.py.genexp"
)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_topics_across_dynamic_bridge${target_suffix}_${bridge_type}_$<CONFIG>.py"
TARGET test_topics_across_dynamic_bridge${target_suffix}_${bridge_type}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)

configure_file(
test/test_services_across_dynamic_bridge.py.in
test_services_across_dynamic_bridge${target_suffix}_${bridge_type}.py.genexp
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_${bridge_type}_$<CONFIG>.py"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_${bridge_type}.py.genexp"
)
add_launch_test(
"${CMAKE_CURRENT_BINARY_DIR}/test_services_across_dynamic_bridge${target_suffix}_${bridge_type}_$<CONFIG>.py"
TARGET test_services_across_dynamic_bridge${target_suffix}_${bridge_type}
ENV RMW_IMPLEMENTATION=${rmw_implementation}
TIMEOUT 60)
endforeach()

endmacro()

if(TEST_ROS1_BRIDGE)
Expand All @@ -266,6 +279,12 @@ if(TEST_ROS1_BRIDGE)
set(TEST_BRIDGE_ROS1_CLIENT "$<TARGET_FILE:test_ros1_client>")
set(TEST_BRIDGE_ROS1_SERVER "$<TARGET_FILE:test_ros1_server>")

list(APPEND DYNAMIC_BRIDGE_TYPE "st")
list(APPEND DYNAMIC_BRIDGE_ARG " ")

list(APPEND DYNAMIC_BRIDGE_TYPE "mt")
list(APPEND DYNAMIC_BRIDGE_ARG "--multi-threads")

call_for_each_rmw_implementation(targets)
endif()

Expand Down
19 changes: 19 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Note

This is a fork of the [ros1_bridge repo](https://github.com/ros2/ros1_bridge) containing modifications to support usage with the CARMAPlatform. This repository contains changes to the ros1_bridge source code, All modifications in this repository are licensed under the same Apache License 2.0 as ros1_bridge and all modifications of the source code made will be marked as such in accordance with the terms of the Apache License 2.0. For a list of modifications and their descriptions please see NOTICE.md.

## For developers working in this repository

For any modified file please follow these steps to ensure proper documentation of this modification in compliance with the terms of the Apache License 2.0:

1. Add a comment at the top of any modified file with a high-level description of the modification and date the modification was made.
2. Add a high-level description and date of the overall modification to the [NOTICE.md](NOTICE.md) file.

## Modifications

- Created develop branch which is built off the foxy branch and contains the following PRs from ros1_bridge which were yet unmerged:
- https://github.com/ros2/ros1_bridge/pull/331
- https://github.com/ros2/ros1_bridge/pull/315
- https://github.com/ros2/ros1_bridge/pull/339
- 3/3/2022
- Michael McConnell
123 changes: 123 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Bridge communication between ROS 1 and ROS 2

## NOTE

This is a fork of the [ros1_bridge repo](https://github.com/ros2/ros1_bridge) containing modifications to support usage with the CARMAPlatform. This repository contains changes to the ros1_bridge source code, All modifications in this repository are licensed under the same Apache License 2.0 as ros1_bridge and all modifications of the source code made will be marked as such in accordance with the terms of the Apache License 2.0. For a list of modifications and their descriptions please see [NOTICE.md](NOTICE.md).

## README

This package provides a network bridge which enables the exchange of messages between ROS 1 and ROS 2.

The bridge is currently implemented in C++ as at the time the Python API for ROS 2 had not been developed.
Expand Down Expand Up @@ -346,3 +352,120 @@ Launch AddTwoInts client:
. <ros2-install-dir>/setup.bash
ros2 run demo_nodes_cpp add_two_ints_client
```

## Example 4: bridge only selected topics and services
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.
For example, to bridge only eg. the `/chatter` topic and the `/add_two_ints service` from ROS1 to ROS2, create this configuration file, `bridge.yaml`:

```yaml
topics:
-
topic: /chatter # ROS1 topic name
type: std_msgs/msg/String # ROS2 type name
queue_size: 1 # For the publisher back to ROS1
services_1_to_2:
-
service: /add_two_ints # ROS1 service name
type: example_interfaces/srv/AddTwoInts # The ROS2 type name
```

Start a ROS 1 roscore:

```bash
# Shell A (ROS 1 only):
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
roscore
```

Then load the bridge.yaml config file and start the talker to publish on the `/chatter` topic:

```bash
Shell B: (ROS1 only):
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash
rosparam load bridge.yaml

rosrun rospy_tutorials talker
```

```bash
Shell C: (ROS1 only):
. /opt/ros/melodic/setup.bash
# Or, on OSX, something like:
# . ~/ros_catkin_ws/install_isolated/setup.bash

rosrun roscpp_tutorials add_two_ints_server
```

Then, in a few ROS 2 terminals:

```bash
# Shell D:
. <install-space-with-ros2>/setup.bash
ros2 run ros1_bridge parameter_bridge
```

If all is well, the logging shows it is creating bridges for the topic and service and you should be able to call the service and listen to the ROS 1 talker from ROS 2:

```bash
# Shell E:
. <install-space-with-ros2>/setup.bash
ros2 run demo_nodes_cpp listener
```
This should start printing text like `I heard: [hello world ...]` with a timestamp.

```bash
# Shell F:
. <install-space-with-ros2>/setup.bash
ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 1, b: 2}"
```
If all is well, the output should contain `example_interfaces.srv.AddTwoInts_Response(sum=3)`

### Parametrizing Quality of Service
An advantage of ROS 2 over ROS 1 is the possibility to define different Quality of Service settings per topic.
The parameter bridge optionally allows for this as well.
For some topics, like `/tf_static` this is actually required, as this is a latching topic in ROS 1.
In ROS 2 with the `parameter_bridge`, this requires that topic to be configured as such:

```yaml
topics:
-
topic: /tf_static
type: tf2_msgs/msg/TFMessage
queue_size: 1
qos:
history: keep_all
durability: transient_local
```

All other QoS options (as documented here in https://docs.ros.org/en/foxy/Concepts/About-Quality-of-Service-Settings.html) are available:

```yaml
topics:
-
topic: /some_ros1_topic
type: std_msgs/msg/String
queue_size: 1
qos:
history: keep_last # OR keep_all, then you can omit `depth` parameter below
depth: 10 # Only required when history == keep_last
reliability: reliable # OR best_effort
durability: transient_local # OR volatile
deadline:
secs: 10
nsecs: 2345
lifespan:
secs: 20
nsecs: 3456
liveliness: liveliness_system_default # Values from https://design.ros2.org/articles/qos_deadline_liveliness_lifespan.html, eg. LIVELINESS_AUTOMATIC
liveliness_lease_duration:
secs: 40
nsecs: 5678
```

Note that the `qos` section can be omitted entirely and options not set are left default.
19 changes: 16 additions & 3 deletions include/ros1_bridge/bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ create_bridge_from_2_to_1(
const std::string & ros1_type_name,
const std::string & ros1_topic_name,
size_t publisher_queue_size,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr);
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr,
bool custom_callback_group = false);

Bridge2to1Handles
create_bridge_from_2_to_1(
Expand All @@ -116,7 +117,8 @@ create_bridge_from_2_to_1(
const std::string & ros1_type_name,
const std::string & ros1_topic_name,
size_t publisher_queue_size,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr);
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr,
bool custom_callback_group = false);

BridgeHandles
create_bidirectional_bridge(
Expand All @@ -125,7 +127,18 @@ create_bidirectional_bridge(
const std::string & ros1_type_name,
const std::string & ros2_type_name,
const std::string & topic_name,
size_t queue_size = 10);
size_t queue_size = 10,
bool custom_callback_group = false);

BridgeHandles
create_bidirectional_bridge(
ros::NodeHandle ros1_node,
rclcpp::Node::SharedPtr ros2_node,
const std::string & ros1_type_name,
const std::string & ros2_type_name,
const std::string & topic_name,
size_t queue_size,
const rclcpp::QoS & publisher_qos);

} // namespace ros1_bridge

Expand Down
Loading