ROS nodehandle question

asked 2014-04-26 20:21:46 -0500

Yantian_Zha 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);



control_msgs::GripperCommandGoal goal;




edit retag flag offensive close merge delete


Try to add ros::Time::init(); at the beginning of your main().

pan gravatar image pan  ( 2018-04-12 06:40:52 -0500 )edit