5.5.1.1. Go To Goal¶
The Go-to-goal behavior uses the robot’s pose in the global frame from our
odometry calculations and the coordinate for the location of
a goal or target,
. Simple trigonometry calculations give us the
target direction,
. The robot heading is then simply
.
When the robot is close to the goal, it may be desired for the robot to go
slower. We will consider that we have arrived at the goal when the pose
indicates that we are within a small distance of the goal, .
The robot will sometimes drive slightly past the goal before stopping. A
simple way to detect that it has driven past the goal is that
will become close to
rather than close to zero, as it should be
when it is approaching the goal. If no adjustment is made, the steering
controller will attempt turn the robot around to go back to the goal, which
gives an undesired behavior of spinning. It would be better to back into the
goal position. Rather than trying to modify the steering controller to deal
with this scenario, it is simpler to just change the inputs to the steering
controller to get the desired result. Since we are using our forward driving
controller, it might seem like we should orient the robot towards
and drive in reverse (
). However,
this will not work because when we reference the velocities of the right and
left wheels, we do so with regard to driving forward. We would need to switch
which velocity goes to each wheel to drive in the desired direction. The
correct solution is to set
and
.