Build a Self Driving Car With the GoPiGo3

7. Add a Destination Function

The code we've used before simply finds the destination and stops. However, what if we wanted to keep going? This seems like a really important function for a self driving car: it has to go to a destination, turn around and be ready to go somewhere else.

Let's add in the code to do that, and make one more function. Once we do this, our car will be pretty useful: it can go to many different places!

We add a function called "GoToDestination". This is going to look a lot like our previous function "GoToTurn". However, instead of finding the black line and moving forward, this will find the black line, move forward, and turn 180 degrees. It's like the GoPiGo will enter your driveway, and turn around, ready to pull out into the street and go to the next destination.




Tags: