2022PythonExamples/11 - Timer Based Autonomous/README.md

2.5 KiB

11 - Timer Based Autonomous

Why should I care about making my robot do things on its own?

Because generally, the beginning 15 seconds of the match have a decent number of points up for grabs, and having an interesting and consistent autonomous will make your team more likely to be picked for playoffs, and open the door to a couple of different awards.

On top of that, autonomy is everything in industry, understanding how to use sensors and environmental data to make decisions in software is crucial in many different programming fields, not just robotics exclusively.

So how do I make my robot do things on its own?

There's a lot of different options, but we're going to start off small and simple, and work our way up. Timers are a good place to start. Essentially, we base our autonomous code on the 15 second timeline we have to get work done, before we switch to teleoperated.

We can observe how much time has passed by asking the timer, and then use if statements to perform certain actions during different spans of time. Maybe while the timer is less than 2 seconds, we drive forward, maybe when the timer is greater than or equal to 2 seconds, but less than three seconds, we turn left, and so on. We ask questions about how much time has passed, to determine what the next action should be.

Timers are very simple to implement, but they do have there drawbacks, but if you're looking for a quick autonomous to perform one or two simple actions, timers can work well.

So wait, what are the drawbacks of timers?

There are really two big ones that will influence your robot's autonomous behavior.

  • Environmental obstacles - Because you're not really using a sensor, just basing what you're doing on time, you can't react to changes in the environment that may influence how your robot works. Maybe the field carpet isn't completely flat in spots, maybe testing on cement and playing on carpet causes the robot to do different things, maybe there's another robot in the way. Timers can't really help you with this.
  • Battery - Motors don't always behave exactly as you would expect them to. It depends on a lot of factors, but two of the bigger ones are the voltage and current available to the motor when it's time to do work. If the battery your using is older or newer, or more or less charged than what you were last testing with, your autonomous may behave differently because the motors aren't getting as far or going further because of differences in the amount of power being applied.