move_base.wait_for_result always returns false
Hi, I'm using move_base.wait_for_result(rospy.Duration) to set a time limit for robot motion. But this function always returns "false" and indicates a timeout even though the robot has actually reached the goal. I use move_base.get_state() to check the robot suatus and it shows status: 3 and text: "Goal reached.". I put the code block below for reference. Thanks in advance!
finished_within_time = self.move_base.wait_for_result(rospy.Duration(60))
if not finished_within_time:
self.move_base.cancel_goal()
rospy.loginfo("Timed out achieving goal")
else:
state = self.move_base.get_state()
if state == GoalStatus.SUCCEEDED:
rospy.loginfo("Goal succeeded!")
n_successes += 1
distance_traveled += distance
rospy.loginfo("State:" + str(state))
else:
rospy.loginfo("Goal failed with error code: " + str(goal_states[state]))