Subscribing to move_base feedback
Hi,
I have following problem:
I simply want to now the current status published by move_base actionserver, but the problem is that I can't make any changes to current move base goal so I can. I want to treat this rather than normal topic, I tried that but it always gives errors[core dumped
]
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <actionlib/client/terminal_state.h>
#include <actionlib_msgs/GoalStatusArray.h>
void statusCallback(const actionlib_msgs::GoalStatusArray &msg) {
ROS_INFO("calling");
int status = msg.status_list[0].status;
ROS_INFO("I heard status: %d", status);
}
int main(int argc, char **argv) {
ros::init(argc, argv, "sub_state_node");
ros::NodeHandle nh;
ROS_INFO("inicialized");
ros::Subscriber move_base_sub = nh.subscribe("move_base/status", 1, statusCallback);
ros::Subscriber cmd_sub = nh.subscribe("cmd_vel", 1, cmdCallback);
ROS_INFO("made sub");
ros::spin();
return 0;
}
Do you guys found solution for this problem?
Edit: I've updated code
Are your action server and subscriber using the same callback method?
It would be useful to post the entire error instead of the end of it
Yes, if you could give us the error and a more detailed, concise explanation of what you are trying to do would be helpful :-)
I only want to know current status of move_base/status topic and call appropriate service for each status. So I came to idea to subscribe this topic but it's not that simple because every time callback function should be executed node crashes
Add the
::ConstPtr&
to the end of the message for the callback, so it would look like this:See if this works.
the same result
But I fount accidentally that this problem occurs only if any goal was passed to move base and
status=' '
I surmise that memory is not allocated before sending any goal and this is the problem. Solution is to add if statement checking size of status_list :)