Trajectory Tutorial Overview

הערה

Before following this tutorial, it is helpful (but not strictly necessary) to have a baseline familiarity with WPILib’s PID control, feedforward, and trajectory features.

הערה

The robot code in this tutorial uses the command-based framework. The command-based framework is strongly recommended for beginning and intermediate teams.

The goal of this tutorial is to provide ”end-to-end“ instruction on implementing a trajectory-following autonomous routine for a differential-drive robot. By following this tutorial, readers will learn how to:

  1. Accurately characterize their robot’s drivetrain to obtain accurate feedforward calculations and approximate feedback gains.

  2. Configure a drive subsystem to track the robot’s pose using WPILib’s odometry library.

  3. Generate a simple trajectory through a set of waypoints using WPILib’s TrajectoryGenerator class.

  4. Follow the generated trajectory in an autonomous routine using WPILib’s RamseteCommand class with the calculated feedforward/feedback gains and pose.

This tutorial is intended to be approachable for teams without a great deal of programming expertise. While the WPILib library offers significant flexibility in the manner in which its trajectory-following features are implemented, closely following the implementation outlined in this tutorial should provide teams with a relatively-simple, clean, and repeatable solution for autonomous movement.

The full robot code for this tutorial can be found in the RamseteCommand Example Project (Java, C++).

Why Trajectory Following?

FRC® games often feature autonomous tasks that require a robot to effectively and accurately move from a known starting location to a known scoring location. Historically, the most common solution for this sort of task in FRC has been a ”drive-turn-drive“ approach - that is, drive forward by a known distance, turn by a known angle, and drive forward by another known distance.

While the ”drive-turn-drive“ approach is certainly functional, in recent years teams have begun tracking smooth trajectories which require the robot to drive and turn at the same time. While this is a fundamentally more-complicated technical task, it offers significant benefits: in particular, since the robot no longer has to stop to change directions, the paths can be driven much faster, allowing a robot to score more game pieces during the autonomous period.

Beginning in 2020, WPILib now supplies teams with working, advanced code solutions for trajectory generation and tracking, significantly lowering the ”barrier-to-entry“ for this kind of advanced and effective autonomous motion.

Required Equipment

To follow this tutorial, you will need ready access to the following materials:

  1. A differential-drive robot (such as the AndyMark AM14U5), equipped with:

  • Quadrature encoders for measuring the wheel rotation of each side of the drive.

  • A gyroscope for measuring robot heading.

  1. A driver-station computer configured with: