ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Connect to multiple namespaced movegroups from single C++ node

asked 2021-12-20 07:43:23 -0500

sniegs gravatar image

updated 2022-01-14 02:59:11 -0500

I am working on a two robot set up that uses SMACC state machines in C++, with MoveIt!. In order to control multiple robots from a state machine, I need to run the state machine in a node that is reachable by both robots, but to run multiple move_groups I need to run each robot in a separate namespace.

I am wondering if there is a way to connect to MoveGroupInterface from inside my C++ node, specifying, that the move_group node is located in a namespace, sort of as in the pictures below. Otherwise, if I would launch the move_group outside of the namespace, when launching the other robots move_group, it would kill the first one and so on.

image description

rqt_graph showing the node connected to move_group inside the namespace.

image description

rqt_graph showing the node outside of the namespace

Edit 1:

move_group_interface.h seems to have a struct Options which takes a ros::NodeHandle parameter, but I am not entirely sure about the correct way how to pass the wanted NodeHandle{/namespace} to it.

Edit 2: Disregard opinion in Edit 1!

Related links:

Similar github issue

Similar ros answers problem

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-04 16:08:23 -0500

Mike Scheutzow gravatar image

The trick seems to be that you open a NodeHandle with a namespace, then pass the NodeHandle object to the MoveGroupInterface constructor.

Please post a comment here if you get it working.

edit flag offensive delete link more

Comments

Do you mean to create for example ros::NodeHandle nh{/ns}; and pass it to the MoveGroupInterface constructor? That seems as the correct way to go, as the MoveGroupInterface has the Options structure which also takes that as one of the variables, but I seem to be having problems with how to pass the NodeHandle object to the constructor, which might or might not be a problem of my C++ programming knowledge.

sniegs gravatar image sniegs  ( 2022-01-05 01:14:41 -0500 )edit

Your nh syntax above is wrong for c++. You just create the Options object using 3 arguments:

ros::NodeHandle nh("ur5");
Options opt("arm_group", "robot_description", nh);
Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-05 12:40:21 -0500 )edit

Yes, thank you so much, I got it working! So the syntax would be

ros::NodeHandle nh("/ur5");
moveit::planning_interface::MoveGroupInterface::Options options("arm_group", "robot_description", nh);
moveit::planning_interface::MoveGroupInterface move_group(options);

and now MoveGroupInterface is launched in the namespace set in nh!

sniegs gravatar image sniegs  ( 2022-01-06 01:33:09 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-12-20 07:43:23 -0500

Seen: 199 times

Last updated: Jan 14 '22