Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
39fa2bf
0.9.0
jacobperron May 18, 2020
37a06eb
Remove outdated information on Fast RTPS bug (#260)
Thom747 May 19, 2020
761546e
use reliable publisher in simple bridge (#264)
dirk-thomas May 20, 2020
7eb9534
gracefully handle invalid ROS 1 publishers (#266)
dirk-thomas May 22, 2020
62fd0d8
fix removing obsolete ROS 2 service bridges (#267)
dirk-thomas May 26, 2020
06839a0
deprecate package key for service parameters, use full type instead (…
dirk-thomas May 26, 2020
3256127
0.9.1
jacobperron May 27, 2020
7aaf32f
When generating service mappings cast pair to set to avoid duplicate …
suddrey-qut May 29, 2020
5094cb5
0.9.2
jacobperron Jun 1, 2020
aaf4ccf
fix multiple definition if message with same name as service exists (…
dirk-thomas Jun 8, 2020
51bef56
0.9.3
jacobperron Jul 8, 2020
0c6decf
document explicitly passing the topic type to 'ros2 topic echo' (#279)
dirk-thomas Jul 27, 2020
2102d8c
use hardcoded QoS (keep all, transient local) for /tf_static topic in…
dirk-thomas Aug 19, 2020
4763129
update changelog
dirk-thomas Sep 10, 2020
82d1f45
0.9.4
dirk-thomas Sep 10, 2020
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
671a915
init docker based CI
hsd-dev Mar 22, 2021
9282829
target rolling only
hsd-dev Apr 23, 2021
51460e8
use setup-ros and action-ros-ci instead of custom scripts
hsd-dev Apr 27, 2021
9382a3f
quiet blind except warnings
hsd-dev Apr 28, 2021
ea86075
remove ccache
hsd-dev May 10, 2021
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/setup-ros@v0.1
with:
required-ros-distributions: "noetic rolling"
- name: Build and test ros1-bridge
uses: ros-tooling/action-ros-ci@v0.2
with:
package-name: ros1_bridge
target-ros1-distro: noetic
target-ros2-distro: rolling

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

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>`_)
* document explicitly passing the topic type to 'ros2 topic echo' (`#279 <https://github.com/ros2/ros1_bridge/issues/279>`_)

0.9.3 (2020-07-07)
------------------
* Fix multiple definition if message with same name as service exists (`#272 <https://github.com/ros2/ros1_bridge/issues/272>`_)
* Contributors: Dirk Thomas

0.9.2 (2020-06-01)
------------------
* When generating service mappings cast pair to set to avoid duplicate pairs (`#268 <https://github.com/ros2/ros1_bridge/issues/268>`_)
* Contributors: Gavin Suddrey

0.9.1 (2020-05-27)
------------------
* Deprecate package key for service parameters, use full type instead (`#263 <https://github.com/ros2/ros1_bridge/issues/263>`_)
* Fix removing obsolete ROS 2 service bridges (`#267 <https://github.com/ros2/ros1_bridge/issues/267>`_)
* Gracefully handle invalid ROS 1 publishers (`#266 <https://github.com/ros2/ros1_bridge/issues/266>`_)
* Use reliable publisher in simple bridge (`#264 <https://github.com/ros2/ros1_bridge/issues/264>`_)
* Remove outdated information on Fast RTPS bug (`#260 <https://github.com/ros2/ros1_bridge/issues/260>`_)
* Contributors: Dirk Thomas, Thom747

0.9.0 (2020-05-18)
------------------
* Avoid new deprecations (`#255 <https://github.com/ros2/ros1_bridge/issues/255>`_)
* Updates since changes to message_info in rclcpp (`#253 <https://github.com/ros2/ros1_bridge/issues/253>`_)
* Assert ROS 1 nodes' stdout (`#247 <https://github.com/ros2/ros1_bridge/issues/247>`_)
* Ignore actionlib_msgs deprecation warning (`#245 <https://github.com/ros2/ros1_bridge/issues/245>`_)
* Drop workaround for https://github.com/ros2/rmw_fastrtps/issues/265. (`#233 <https://github.com/ros2/ros1_bridge/issues/233>`_)
* Code style only: wrap after open parenthesis if not in one line (`#238 <https://github.com/ros2/ros1_bridge/issues/238>`_)
* Contributors: Dirk Thomas, Jacob Perron, Michel Hidalgo, William Woodall

0.8.2 (2020-01-17)
------------------
* fix building test when ROS 1 diagnostic_msgs is isolated from roscpp (`#236 <https://github.com/ros2/ros1_bridge/issues/236>`_)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ foreach(package_name ${ros2_interface_packages})
if(NOT "${package_name}" STREQUAL "builtin_interfaces")
list(APPEND generated_files "${generated_path}/${package_name}_factories.cpp")
list(APPEND generated_files "${generated_path}/${package_name}_factories.hpp")
foreach(interface_file ${${package_name}_INTERFACE_FILES})
foreach(interface_file ${${package_name}_IDL_FILES})
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
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ If you would like to use a bridge with other interfaces (including your own cust
See [the documentation](doc/index.rst) for an example setup.

For efficiency reasons, topics will only be bridged when matching publisher-subscriber pairs are active for a topic on either side of the bridge.
Note that before `rostopic echo` would work with bridged topics, a subscriber must already exist, in order for `echo` to determine the message type and then to create its own subscriber.
You can use the `--bridge-all-2to1-topics` option to bridge all ROS 2 topics to ROS 1 so that tools such as `rostopic list` and `rqt` will see the topics even if there are no matching ROS 1 subscribers.
As a result using `ros2 topic echo <topic-name>` doesn't work but fails with an error message `Could not determine the type for the passed topic` if no other subscribers are present since the dynamic bridge hasn't bridged the topic yet.
As a workaround the topic type can be specified explicitly `ros2 topic echo <topic-name> <topic-type>` which triggers the bridging of the topic since the `echo` command represents the necessary subscriber.
On the ROS 1 side `rostopic echo` doesn't have an option to specify the topic type explicitly.
Therefore it can't be used with the dynamic bridge if no other subscribers are present.
As an alternative you can use the `--bridge-all-2to1-topics` option to bridge all ROS 2 topics to ROS 1 so that tools such as `rostopic echo`, `rostopic list` and `rqt` will see the topics even if there are no matching ROS 1 subscribers.
Run `ros2 run ros1_bridge dynamic_bridge -- --help` for more options.

## Prerequisites
Expand Down Expand Up @@ -174,9 +177,6 @@ Once you stop either the talker or the listener in *shell B* a line will be stat
removed 1to2 bridge for topic '/chatter'
```

*Note:* When the bridge is run using the default ROS 2 middleware implementation, which uses Fast RTPS, it does not always remove bridges instantly.
See [https://github.com/ros2/ros1_bridge/issues/38](https://github.com/ros2/ros1_bridge/issues/38).

The screenshot shows all the shell windows and their expected content:

![ROS 1 talker and ROS 2 listener](doc/ros1_talker_ros2_listener.png)
Expand Down
23 changes: 23 additions & 0 deletions include/ros1_bridge/bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ create_bridge_from_1_to_2(
const std::string & ros2_topic_name,
size_t publisher_queue_size);

Bridge1to2Handles
create_bridge_from_1_to_2(
ros::NodeHandle ros1_node,
rclcpp::Node::SharedPtr ros2_node,
const std::string & ros1_type_name,
const std::string & ros1_topic_name,
size_t subscriber_queue_size,
const std::string & ros2_type_name,
const std::string & ros2_topic_name,
const rclcpp::QoS & publisher_qos);

Bridge2to1Handles
create_bridge_from_2_to_1(
rclcpp::Node::SharedPtr ros2_node,
Expand All @@ -95,6 +106,18 @@ create_bridge_from_2_to_1(
size_t publisher_queue_size,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr);

Bridge2to1Handles
create_bridge_from_2_to_1(
rclcpp::Node::SharedPtr ros2_node,
ros::NodeHandle ros1_node,
const std::string & ros2_type_name,
const std::string & ros2_topic_name,
const rclcpp::QoS & subscriber_qos,
const std::string & ros1_type_name,
const std::string & ros1_topic_name,
size_t publisher_queue_size,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr);

BridgeHandles
create_bidirectional_bridge(
ros::NodeHandle ros1_node,
Expand Down
42 changes: 36 additions & 6 deletions include/ros1_bridge/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class Factory : public FactoryInterface
{
auto qos = rclcpp::QoS(rclcpp::KeepAll());
qos.get_rmw_qos_profile() = qos_profile;
return create_ros2_publisher(node, topic_name, qos);
}

rclcpp::PublisherBase::SharedPtr
create_ros2_publisher(
rclcpp::Node::SharedPtr node,
const std::string & topic_name,
const rclcpp::QoS & qos)
{
return node->create_publisher<ROS2_T>(topic_name, qos);
}

Expand Down Expand Up @@ -103,9 +112,8 @@ class Factory : public FactoryInterface
ros::Publisher ros1_pub,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr)
{
rmw_qos_profile_t custom_qos_profile = rmw_qos_profile_sensor_data;
custom_qos_profile.depth = queue_size;
return create_ros2_subscriber(node, topic_name, custom_qos_profile, ros1_pub, ros2_pub);
auto qos = rclcpp::SensorDataQoS(rclcpp::KeepLast(queue_size));
return create_ros2_subscriber(node, topic_name, qos, ros1_pub, ros2_pub);
}

rclcpp::SubscriptionBase::SharedPtr
Expand All @@ -115,18 +123,30 @@ class Factory : public FactoryInterface
const rmw_qos_profile_t & qos,
ros::Publisher ros1_pub,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr)
{
auto rclcpp_qos = rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos));
rclcpp_qos.get_rmw_qos_profile() = qos;
return create_ros2_subscriber(
node, topic_name, rclcpp_qos, ros1_pub, ros2_pub);
}

rclcpp::SubscriptionBase::SharedPtr
create_ros2_subscriber(
rclcpp::Node::SharedPtr node,
const std::string & topic_name,
const rclcpp::QoS & qos,
ros::Publisher ros1_pub,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr)
{
std::function<
void(const typename ROS2_T::SharedPtr msg, const rclcpp::MessageInfo & msg_info)> callback;
callback = std::bind(
&Factory<ROS1_T, ROS2_T>::ros2_callback, std::placeholders::_1, std::placeholders::_2,
ros1_pub, ros1_type_name_, ros2_type_name_, node->get_logger(), ros2_pub);
auto rclcpp_qos = rclcpp::QoS(rclcpp::QoSInitialization::from_rmw(qos));
rclcpp_qos.get_rmw_qos_profile() = qos;
rclcpp::SubscriptionOptions options;
options.ignore_local_publications = true;
return node->create_subscription<ROS2_T>(
topic_name, rclcpp_qos, callback, options);
topic_name, qos, callback, options);
}

void convert_1_to_2(const void * ros1_msg, void * ros2_msg) override
Expand Down Expand Up @@ -214,6 +234,16 @@ class Factory : public FactoryInterface
}
}

void * ptr = ros1_pub;
if (ptr == 0) {
RCLCPP_WARN_ONCE(
logger,
"Message from ROS 2 %s failed to be passed to ROS 1 %s because the "
"ROS 1 publisher is invalid (showing msg only once per type)",
ros2_type_name.c_str(), ros1_type_name.c_str());
return;
}

ROS1_T ros1_msg;
convert_2_to_1(*ros2_msg, ros1_msg);
RCLCPP_INFO_ONCE(
Expand Down
16 changes: 16 additions & 0 deletions include/ros1_bridge/factory_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class FactoryInterface
const std::string & topic_name,
const rmw_qos_profile_t & qos_profile) = 0;

virtual
rclcpp::PublisherBase::SharedPtr
create_ros2_publisher(
rclcpp::Node::SharedPtr node,
const std::string & topic_name,
const rclcpp::QoS & qos) = 0;

virtual
ros::Subscriber
create_ros1_subscriber(
Expand Down Expand Up @@ -94,6 +101,15 @@ class FactoryInterface
ros::Publisher ros1_pub,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr) = 0;

virtual
rclcpp::SubscriptionBase::SharedPtr
create_ros2_subscriber(
rclcpp::Node::SharedPtr node,
const std::string & topic_name,
const rclcpp::QoS & qos,
ros::Publisher ros1_pub,
rclcpp::PublisherBase::SharedPtr ros2_pub = nullptr) = 0;

virtual
void
convert_1_to_2(const void * ros1_msg, void * ros2_msg) = 0;
Expand Down
7 changes: 5 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>ros1_bridge</name>
<version>0.8.2</version>
<version>0.10.1</version>
<description>A simple bridge between ROS 1 and ROS 2</description>
<maintainer email="dthomas@osrfoundation.org">Dirk Thomas</maintainer>
<maintainer email="jacob@openrobotics.org">Jacob Perron</maintainer>
<maintainer email="sloretz@openrobotics.org">Shane Loretz</maintainer>
<license>Apache License 2.0</license>

<author email="dthomas@openrobotics.org">Dirk Thomas</author>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_index_python</buildtool_depend>
<buildtool_depend>python3-catkin-pkg-modules</buildtool_depend>
Expand Down
Loading