Example Teleop
This is an example teleop taken from the Pedro Pathing Beginner Quickstart
It serves as a template for a robot-centric teleop. It can also be viewed here on Github
package pedroPathing.examples;
import com.pedropathing.follower.Follower;
import com.pedropathing.localization.Pose;
import com.pedropathing.util.Constants;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import pedroPathing.constants.FConstants;
import pedroPathing.constants.LConstants;
/**
* This is an example teleop that showcases movement and robot-centric driving.
*
* @author Baron Henderson - 20077 The Indubitables
* @version 2.0, 12/30/2024
*/
@TeleOp(name = "Example Robot-Centric Teleop", group = "Examples")
public class ExampleRobotCentricTeleop extends OpMode {
private Follower follower;
private final Pose startPose = new Pose(0,0,0);
/** This method is call once when init is played, it initializes the follower **/
@Override
public void init() {
Constants.setConstants(FConstants.class, LConstants.class);
follower = new Follower(hardwareMap);
follower.setStartingPose(startPose);
}
/** This method is called continuously after Init while waiting to be started. **/
@Override
public void init_loop() {
}
/** This method is called once at the start of the OpMode. **/
@Override
public void start() {
follower.startTeleopDrive();
}
/** This is the main loop of the opmode and runs continuously after play **/
@Override
public void loop() {
/* Update Pedro to move the robot based on:
- Forward/Backward Movement: -gamepad1.left_stick_y
- Left/Right Movement: -gamepad1.left_stick_x
- Turn Left/Right Movement: -gamepad1.right_stick_x
- Robot-Centric Mode: true
*/
follower.setTeleOpMovementVectors(-gamepad1.left_stick_y, -gamepad1.left_stick_x, -gamepad1.right_stick_x, true);
follower.update();
/* Telemetry Outputs of our Follower */
telemetry.addData("X", follower.getPose().getX());
telemetry.addData("Y", follower.getPose().getY());
telemetry.addData("Heading in Degrees", Math.toDegrees(follower.getPose().getHeading()));
/* Update Telemetry to the Driver Hub */
telemetry.update();
}
/** We do not use this because everything automatically should disable **/
@Override
public void stop() {
}
}