Following a path with MQTT
Now for the first behavior that will make our robot seem like one. Let's make a quick sketch of a path for our robot to follow. For an example, see Figure 6.6:
In Figure 6.7, I've drawn a path. The straight lines are for driving forward for 1 second. We don't yet have a way to consider distance traveled, only time. We can guess at times relative to distances, but this isn't precise or repeatable. We will see later how to improve that repeatability. The curves are a turn where we slow one motor down more than the other.The final spiral means a victory spin on the spot when the path is complete—we can do this by putting one motor in reverse while the other drives forward.Let's write this code. First, we want the imports: sleep and robot. But before we do anything, let's make some helper functions for this behavior. I called my file behavior_path.py, and the code is shown in...