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

MoveBaseClient::sendGoal Defining Custom Callbacks

asked 2020-05-05 05:33:52 -0500

MarkyMark2012 gravatar image

Hi All,

Not sure where I an going wring here - byt the compiler isn't happy. Basically I want to add the callbacks to the MoveBaseClient sendGoal() method so that I can monitor progress.

Code is basically this:

Callbacks:

void goalCompletePlanCallBack(const actionlib::SimpleClientGoalState &state, 
                          const move_base_msgs::MoveBaseActionResultConstPtr &result)
{
    ROS_INFO("Goal Plan Complete");
}

void goalActiveCallBack()
{
    ROS_INFO("Planning Goal Active");
}

void goalFeedbackCallback(const move_base_msgs::MoveBaseFeedbackConstPtr &feedback)
{

}

then in the code I call:

...
move_base_msgs::MoveBaseGoal goal;

ac.sendGoal(goal, &goalCompletePlanCallBack, &goalActiveCallBack, &goalFeedbackCallback);

...

But the compiler just errors. What is the the correct way to call this?

Many Thanks

Mark

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-05-10 14:24:20 -0500

MarkyMark2012 gravatar image

So I found a work around.

After calling sendGoal() I've not got this little while loop

while (navigationState == actionlib::SimpleClientGoalState::ACTIVE ||
     navigationState == actionlib::SimpleClientGoalState::PENDING)
{
    navigationState = ac.getState();
    ROS_DEBUG("Navigation State: %s", navigationState.toString().c_str());
    sleep(1);

    if (cmdString == "HOME")
    {
        ac.cancelGoal();
    }
}

Basically checking for incoming messages/commands and cancelling the goal when I need

This might be of use to someone ;-)

Mark

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-05-05 05:33:52 -0500

Seen: 591 times

Last updated: May 10 '20