move_base receiving empty plan
I'm trying to write a global planner to use with move_base. I'm printing the path in the console and it looks good, but I'm getting a warn from move_base telling me the plan is empty, even though I'm checking in the end of makePlan that it isn't.
This is the part of makePlan that adds the poses to the plan vector:
if (bestPath.size() > 0){
for (int i = bestPath.size()-1; i >=0; i--){
GridCell current = bestPath[i];
GridCell previous;
if (i != (bestPath.size()-1))
previous = bestPath[i + 1];
else
previous = current;
//Orient the bot towards target
tf::Vector3 vectorToTarget;
vectorToTarget.setValue(current.x - previous.x, current.y - previous.y, 0.0);
float angle = atan2((double)vectorToTarget.y(), (double)vectorToTarget.x());
geometry_msgs::PoseStamped pose = goal;
pose.pose.position.x = current.x;
pose.pose.position.y = current.y;
pose.pose.position.z = 0.0;
pose.pose.orientation = tf::createQuaternionMsgFromYaw(angle);
plan.push_back(pose);
}
ROS_DEBUG("Plan empty: %d", plan.empty());
return true;
}
And the warning I'm getting is: [WARN]: Received an empty transformed plan.
Any help will be greatly appreciated.