From 4d219a3442ee419c6afaf9be60e7871da6c37bed Mon Sep 17 00:00:00 2001 From: Victor Lopez Date: Fri, 13 Nov 2020 12:32:27 +0000 Subject: [PATCH 1/3] Fix python script errors in action generation Signed-off-by: Victor Lopez --- ros1_bridge/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ros1_bridge/__init__.py b/ros1_bridge/__init__.py index 063ace1d..80006f4e 100644 --- a/ros1_bridge/__init__.py +++ b/ros1_bridge/__init__.py @@ -154,6 +154,7 @@ def generate_cpp(output_path, template_dir): 'interface': interface, 'mapped_msgs': [], 'mapped_services': [], + 'mapped_actions': [], } if interface_type == 'msg': data_idl_cpp['mapped_msgs'] += [ @@ -164,12 +165,13 @@ def generate_cpp(output_path, template_dir): data_idl_cpp['mapped_services'] += [ s for s in data['services'] if s['ros2_package'] == ros2_package_name and - s['ros2_name'] == interface.message_name], - 'mapped_actions': [ + s['ros2_name'] == interface.message_name] + if interface_type == 'action': + data_idl_cpp['mapped_actions'] += [ s for s in data['actions'] if s['ros2_package'] == ros2_package_name and - s['ros2_name'] == interface.message_name], - } + s['ros2_name'] == interface.message_name] + template_file = os.path.join( template_dir, 'interface_factories.cpp.em') output_file = os.path.join( From 2ed746973c61809381d6a8f59468e914461f5fca Mon Sep 17 00:00:00 2001 From: Victor Lopez Date: Fri, 13 Nov 2020 12:32:59 +0000 Subject: [PATCH 2/3] Foxy and later action compatibility Signed-off-by: Victor Lopez --- include/ros1_bridge/action_factory.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/ros1_bridge/action_factory.hpp b/include/ros1_bridge/action_factory.hpp index 3e91d0d7..82665b31 100644 --- a/include/ros1_bridge/action_factory.hpp +++ b/include/ros1_bridge/action_factory.hpp @@ -136,11 +136,14 @@ class ActionFactory_1_2 : public ActionFactoryInterface return; } + // goal_response_callback signature changed after foxy, this implementation + // works with both + std::shared_future gh2_future; //Changes as per Dashing auto send_goal_ops = ROS2SendGoalOptions(); send_goal_ops.goal_response_callback = - [this](auto gh2_future) mutable { - auto goal_handle = gh2_future.get(); + [this, &gh2_future](auto gh2) mutable { + auto goal_handle = gh2_future.get(); if (!goal_handle) { gh1_.setRejected(); // goal was not accepted by remote server @@ -168,7 +171,7 @@ class ActionFactory_1_2 : public ActionFactoryInterface }; // send goal to ROS2 server, set-up feedback - auto gh2_future = client_->async_send_goal(goal2, send_goal_ops); + gh2_future = client_->async_send_goal(goal2, send_goal_ops); auto future_result = client_->async_get_result(gh2_future.get()); auto res2 = future_result.get(); From 6b945fbf8bc6e6993b4313eef988c6fa4e05c936 Mon Sep 17 00:00:00 2001 From: Victor Lopez Date: Tue, 17 Nov 2020 09:48:14 +0100 Subject: [PATCH 3/3] Reorder ros node initialization to allow renaming of bridge --- src/action_bridge.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/action_bridge.cpp b/src/action_bridge.cpp index 33a61dfa..c79df303 100644 --- a/src/action_bridge.cpp +++ b/src/action_bridge.cpp @@ -31,14 +31,15 @@ int main(int argc, char *argv[]) { - // ROS 1 node - ros::init(argc, argv, "ros_bridge"); - ros::NodeHandle ros1_node; - // ROS 2 node + // must be before ROS1, because ros::init consumes args like __name and we cannot remap the node rclcpp::init(argc, argv); auto ros2_node = rclcpp::Node::make_shared("ros_bridge"); + // ROS 1 node + ros::init(argc, argv, "ros_bridge"); + ros::NodeHandle ros1_node; + std::string dir = argv[1]; std::string package = argv[2]; std::string type = argv[3];