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

actionlib client question

asked 2014-04-26 06:00:30 -0600

Yantian_Zha gravatar image

updated 2014-05-07 04:46:28 -0600

BennyRe gravatar image

Hi all, I want to use actionlib to send gripping control cmd to gripper_controller(arbotix package), but after compiling I ran my node, and get strange info: "terminate called after throwing an instance of 'ros::InvalidNameException' what(): Using ~ names with NodeHandle methods is not allowed. If you want to use private names with the NodeHandle interface, construct a NodeHandle using a private name as its namespace. e.g. ros::NodeHandle nh("~"); nh.getParam("my_private_name"); (name = [~gripper_action]) Aborted (core dumped)"

I cannot change my code as the note's "nh.getParam("my_private_name")" because I need sentence like "GripperMoveClient ac("~gripper_action",true);" to define my client.

Pls help me, thanks! Below is my actionlib client code.

#include ros/ros.h>  //in order to show for you I //deliberately lose "<"

#include actionlib/client/simple_action_client.h>

#include control_msgs/GripperCommandAction.h>

typedef actionlib::SimpleActionClient<control_msgs::GripperCommandAction> GripperMoveClient;

int main(int argc, char** argv){

ros::init(argc, argv, "grasping_points_node");

GripperMoveClient ac("~gripper_action",true);

 while(!ac.waitForServer(ros::Duration(5.0))){

  ROS_INFO("Waiting...");}

  control_msgs::GripperCommandGoal goal;

  goal.command.position=0.01;

  ac.sendGoal(goal);

}
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2014-05-08 23:37:46 -0600

This solves your error message:

ros::NodeHandle pn("~");
GripperMoveClient ac(pn, "gripper_action", true);

By constructing the private node handle with namespace "~", and then passing that to your action client, the effect will be that you're subscribing to"~/gripper_action", which will be resolved to "/grasping_points_node/gripper_action". Are you sure you want that to happen? It only makes sense if the action server that you're trying to connect to is running in the private namespace of your client node, i.e. in almost all cases it's part of the same node.

Probably you should run rostopic list on the command line to figure out the final resolved name of the gripper_action topic.

Here is some more information on how ~ is resolved in ROS.

edit flag offensive delete link more

Comments

Thanks for your kind reply, and I solved my problem.

Yantian_Zha gravatar image Yantian_Zha  ( 2014-05-09 13:01:00 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-04-26 06:00:30 -0600

Seen: 3,119 times

Last updated: May 08 '14