|
| 1 | +package org.mrpsvt.capital_robotics.teleop; |
| 2 | + |
| 3 | +import com.qualcomm.robotcore.eventloop.opmode.OpMode; |
| 4 | +import com.qualcomm.robotcore.eventloop.opmode.TeleOp; |
| 5 | +import com.qualcomm.robotcore.hardware.IMU; |
| 6 | +import com.seattlesolvers.solverslib.drivebase.MecanumDrive; |
| 7 | +import com.seattlesolvers.solverslib.hardware.RevIMU; |
| 8 | + |
| 9 | +import org.mrpsvt.capital_robotics.control.ControlMap; |
| 10 | +import org.mrpsvt.capital_robotics.robot_core.DriveBase; |
| 11 | +import org.mrpsvt.capital_robotics.robot_core.DriveConstants; |
| 12 | + |
| 13 | +import java.util.Objects; |
| 14 | + |
| 15 | +@TeleOp(name = "Default Opmode", group = "TeleOp") |
| 16 | +public class DefaultOpmode extends OpMode { |
| 17 | + private ControlMap controls; |
| 18 | + private MecanumDrive drive; |
| 19 | + private DriveConstants driveConstants; |
| 20 | + private RevIMU imu; // Assuming you have an IMU class for field-centric driving |
| 21 | + |
| 22 | + @Override |
| 23 | + public void init() { |
| 24 | + DriveBase driveBase = new DriveBase(hardwareMap); |
| 25 | + controls = new ControlMap(); |
| 26 | + drive = driveBase.mecanum; |
| 27 | + imu = driveBase.imu; |
| 28 | + driveConstants = new DriveConstants(); |
| 29 | + } |
| 30 | + |
| 31 | + @Override |
| 32 | + public void loop() { |
| 33 | + if (Objects.equals(driveConstants.robotDriveMode, DriveConstants.ROBOT_CENTRIC)) { |
| 34 | + drive.driveRobotCentric( |
| 35 | + controls.driver1.getLeftY() * driveConstants.forwardSpeed, |
| 36 | + controls.driver1.getLeftX() * driveConstants.strafeSpeed, |
| 37 | + controls.driver1.getRightX() * driveConstants.turnSpeed |
| 38 | + ); |
| 39 | + } else if (Objects.equals(driveConstants.robotDriveMode, DriveConstants.FIELD_CENTRIC)) { |
| 40 | + drive.driveFieldCentric( |
| 41 | + controls.driver1.getLeftY() * driveConstants.forwardSpeed, |
| 42 | + controls.driver1.getLeftX() * driveConstants.strafeSpeed, |
| 43 | + controls.driver1.getRightX() * driveConstants.turnSpeed, |
| 44 | + imu.getRotation2d().getDegrees() // IMU heading would go here |
| 45 | + ); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments