Robotics StackExchange | Archived questions

How to add new subscriber in move_base node ?

Hello,

I have integrated listener.cpp subscriber (from ROS tutorials) into the movebase node. I started movebase node and after I started talker.cpp node. But it does not work. Following steps show my process, where I am doing wrong ?

in move_base.h

ros::Subscriber listen_;

void listenCallback(const std_msgs::String::ConstPtr& msg); 

in move_base.cpp

ros::NodeHandle listen_nh_;

listen_=  listen_nh_.subscribe<std_msgs::String>("chatter", 1, boost::bind(&MoveBase::listenCallback, this, _1));

void MoveBase::listenCallback(const std_msgs::String::ConstPtr& msg) {

 ROS_INFO("I heard: [%s]", msg->data.c_str());

}

So this is what I do. Do have any idea what my failure is or something forgetting ?

thanks

Asked by Developer on 2018-05-25 15:38:55 UTC

Comments

But it does not work

What does this mean? What's happening vs what do you expect to happen?

Asked by jayess on 2018-05-25 16:08:09 UTC

thanks. I had written just topic name false. Now Problem is solved.

Asked by Developer on 2018-05-30 04:55:48 UTC

What does that mean? Are you saying that you had the wrong topic name?

Asked by jayess on 2018-05-30 11:31:02 UTC

I had written different topic names, I corrected it

Asked by Developer on 2018-05-30 14:25:23 UTC

Answers

Did you do a catkin_make? (this would be the easiest problem to solve)

Also you shouldn't need the boost::bind ( I don't personally know what that does, but all of my nodes work without it.

Another thing to check, when you run the node, if you do rosnode info your_node_name does it say that your node is subscribing to "chatter"?

Asked by mmmfarrell on 2018-05-25 15:47:50 UTC

Comments

thanks for the info I have written just topic name false. Now Problem is solved.

Asked by Developer on 2018-05-25 16:10:03 UTC