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

Action bridge #1

Merged
merged 3 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
10 changes: 6 additions & 4 deletions ros1_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] += [
Expand All @@ -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(
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