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(); 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( 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];