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

Revision history [back]

If you are using move_base to autonomously drive to a location, then using the service provides a return message when it reaches the goal. Otherwise, if you want to use the bool method, it is the same as any other callback. Make a global variable to hold some flag, called reached below, and populate it with the data value from the message.

bool reached = false;

void positionreached(const std_msgs::Bool::ConstPtr& Reached)
{
  reached = Reached->data;
}

If you are using move_base to autonomously drive to a location, then using the service provides a return message when it reaches the goal. Otherwise, if you want to use the bool method, it is the same as any other callback. Make a global variable to hold some flag, called reached below, and populate it with the data value from the message.

bool reached = false;

void positionreached(const std_msgs::Bool::ConstPtr& Reached)
{
  reached = Reached->data;
}

[EDIT]

Right, Arduino. Try:

void positionreached(const std_msgs::Bool Reached)
{
  reached = Reached.data;
}

Also, reached only needs to be bool, not std_msgs::Bool.