Setting Up Your Autonomous
What you need before you start pathing
This guide will walk you through making an autonomous OpMode using PedroPathing. We will break it down into several sections so it is easy for you to understand.
Before creating our paths, we first need a Follower.
The follower controls the drivetrain, keeps track of the robot's position using the localizer, and runs the path following algorithm configured in your Constants file.
If you haven't configured your robot yet, see the Constants page first.
Tuning
This guide assumes you have tuned your robot already. If you haven't, please tune your robot first.
Creating the OpMode
This process is the same as how you make any autonomous or TeleOp.
package org.firstinspires.ftc.teamcode.autos.ExampleAuto; // This should match the file location. This is auto generated by Android Studio
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
@Autonomous
public class ExampleAuto extends OpMode {
@Override
public void init() {
}
@Override
public void start() {
}
@Override
public void loop() {
}
}Package statement
Your package statement must match your file location and may not be the same as in this code. Android Studio automatically generates this when you create a class. Simply use the auto generated package statement or adjust this one to fit your codebase
Creating the Follower
First, import the Follower and your Constants file:
import com.pedropathing.follower.Follower;
import org.firstinspires.ftc.teamcode.pedro.Constants;Then, create a follower variable inside your OpMode:
public class ExampleAuto extends OpMode {
private Follower follower; // Add thisThe create() method in your Constants class creates a follower using the drivetrain, localizer, and algorithm you configured.
Create the follower inside your init() method:
@Override
public void init() {
follower = Constants.create(hardwareMap);
}init() runs when the OpMode is initialized, but before the Start button is pressed.
Note
Ensure your Constants import matches where the file is located in your project. This example uses the location in the quickstart.
Next Step
Now that the follower is created, we can start pathing. The next step is to define where the robot starts and where we want it to go.
Continue to Creating a Pose.
Last updated on