Unable to publish to move_base
I am trying to stop the robot and this the code I have written in my program
ros::Publisher pub1 = nh->advertise<actionlibmsgs::GoalID> ("/move_base/cancel", 1000);
actionlib_msgs::GoalID msg;
msg.id = "";
ros::spinOnce();
pub1.publish(msg);
But, the robot continues to move and I even checked by listening to the topic using the below command but found no response.
rostopic echo /move_base/cancel
However, when I try to publish to the topic, directly from terminal, it works.
rostopic pub /movebase/cancel actionlibmsgs/GoalID -- {}
and also listening to the topic
rostopic echo /move_base/cancel
gives the below message
stamp: secs: 0 nsecs: 0 id: ''
Any idea why this might happen?
Node handle declaration:
class Door {
public: Door(ros::NodeHandle* nh);
protected: ros::NodeHandle *nh_;
};
Door::Door( ros::NodeHandle* nh ) {
nh_ = nh;
}int main(int argc, char**argv) {
ros::init(argc, argv,"robot_navigation");ros::NodeHandle nh;
ros::NodeHandle privateNode("~");
Door door(&nh);
Asked by Neeharika on 2019-04-28 17:08:20 UTC
Comments
Can you please edit the question to add your node handle declaration?
Asked by janindu on 2019-04-28 19:45:50 UTC
Yes, included the node declaration
Asked by Neeharika on 2019-04-28 20:21:31 UTC
If you don't have subscribers, you don't need
ros::spinOnce()
. However, that's not the problem here. Where does your publisher code come in your classDoor
, and how is it called inside themain()
?Asked by janindu on 2019-04-28 20:39:56 UTC
From main, run() is called (which is a member function of Door). Inside run(), I am listening to the topic /odom and in it's corresponding callback function, I have the publisher code for /move_base/cancel.
Asked by Neeharika on 2019-04-28 21:16:13 UTC
You need to show your code please.
Asked by janindu on 2019-04-28 21:17:03 UTC