Skip to content

Commit

Permalink
Merge branch 'action_bridge' of https://github.com/ipa-hsd/ros1_bridge
Browse files Browse the repository at this point in the history
…into action_bridge

# Conflicts:
#	include/ros1_bridge/action_factory.hpp
#	ros1_bridge/__init__.py
#	src/action_bridge.cpp
  • Loading branch information
hsd-dev committed Nov 17, 2020
2 parents a418e7e + 469b025 commit b2a83f9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
9 changes: 6 additions & 3 deletions include/ros1_bridge/action_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ROS2GoalHandle> 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
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions ros1_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,20 @@ def generate_cpp(output_path, template_dir):
'interface_type': interface_type,
'interface': interface,
'mapped_msgs': [
'mapped_actions': [],
m for m in data['mappings']
if m.ros2_msg.package_name == ros2_package_name and
m.ros2_msg.message_name == interface.message_name],
'mapped_services': [
s for s in data['services']
if s['ros2_package'] == ros2_package_name and
s['ros2_name'] == interface.message_name],
'mapped_actions': [
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(
Expand Down
9 changes: 5 additions & 4 deletions src/action_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit b2a83f9

Please sign in to comment.