How do you go about making an autonomous routine?

I’m going to be the program lead (and possibly only programmer) on my team. My team has never had a reliable autonomous with any driving; we simply position the robot on the field so it drives in the correct direction. Last year we got vision for aiming, but I want to make a better routine that can reliably drive around. We currently use a time-based system that is horribly unreliable. We have encoders on the drivetrain, and I can read them, but I don’t understand how to lay out an autonomous using them, particularly one that involves turning. We use command based, if that matters. As we have very limited manpower, I’m looking for something fairly easy to implement.
Thank you!

There are so many resources. Here’s one of them
Start with this and let us know what questions you may have

1 Like

That linked “zero to autonomous” series is a great resource for sure.

As a reasonable next step, “drive for X distance” as measured by encoders would be a straightforward and accomplishable step.

One further step after that, look into mounting a gyroscope and doing a similar “turn X degrees”.

Having a way to string many of those drive and turn operations together, along with the ability to run intakes, shoot balls, etc., will make for a some really great auto routines.

Once you have a good grip on making things like that work well, path planning might be the next step up in auto routine complexity.


I would look into PID controllers. The Proportional term, kP, acts like a spring: output is proportional to the error. Think of it like a spring: your force is proportional to your distance, as the spring pulls/pushes back the more you push/pull on it. The Integral term, kI, applies power to the running sum of your error. So if you sit just a few inches off of setpoint, over time the robot will creep towards the goal. I don’t think there’s a real-life analog to this one (someone please prove me wrong!) The Derivative term, kD, applies power based on the rate of change. This dampens the motion out, so if you come screaming at the target it stops you from overshooting. Think of it like waving your palmed hand in a pool of water: the water ‘pushes back’ harder on your hand the faster you move it.

Here’s a video to explain how they work:

You can use PID controllers to drive forward/backwards for a certain distance based on the encoders and the gyro. Drive forwards/backwards for some distance X. Encoders track the distance driven, and the gyro corrects for any veering off track the robot does. Next you can use the gyro to turn on the dot left or right. You can even use the angle data from your vision camera and turn towards the goal.

Now, my advice for you as the programmer for your team that is new to autonomous routines is this:

  • The very first autos you should write, regardless of what sensors you have on your robot, are a timed drive auto. Ideally wait for X seconds then drive forwards/backwards for Y seconds. This is so that no matter what fails on your robot, you can at least get a few points (most games have a bonus for simply driving in auto).
  • Learn about how PID controllers work. Maybe write your own from scratch before kickoff just so you understand how the values work, but use the built-in ones from wpilib during the season. Its tried and tested to work. Don’t catch NIH.
  • Next, work on the drive-a-distance and turn-an-angle commands. Get those down solid. Try to get these as consistent as possible when you create your autonomous routines for next year. IMO you can be in the top-percentile of teams with simple and consistent drive and turn commands.
  • IMO don’t go for path planning until you finish a season with this autonomous code. The community has done amazing work to make path planning accessible to all teams, and it certainly has the cool factor, but you don’t need it to be successful. There’s more overhead that needs to be done, like path generation, and trajectory generation if you go down that route, that I’d advise waiting until the offseason for.

If it were me the next progression after the drive and turn commands I would go to is pure pursuit. It is a very elegant approach to path following. Again, don’t go for it until you’ve got a successful season with the drive and turn commands. Master the fundamentals first.

Feel free to shoot me a PM if you have any questions! Love to chat about this stuff.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.