Added Cayden's DriveTrain test program

This commit is contained in:
2021-10-16 12:20:25 -05:00
parent 33fde6917b
commit 365a7ca7a7
2 changed files with 63 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package org.timecrafters.FreightFrenzy.HardwareTesting.Engines;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import org.cyberarm.engine.V2.CyberarmEngine;
import org.timecrafters.FreightFrenzy.HardwareTesting.States.DriveTrainTestState;
@TeleOp(name = "DriveTrain Test", group = "testing")
public class DriveTrainTestEngine extends CyberarmEngine {
@Override
public void setup() {
addState(new DriveTrainTestState());
}
}

View File

@@ -0,0 +1,49 @@
package org.timecrafters.FreightFrenzy.HardwareTesting.States;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import org.cyberarm.engine.V2.CyberarmState;
import org.timecrafters.TimeCraftersConfigurationTool.library.TimeCraftersConfiguration;
public class DriveTrainTestState extends CyberarmState {
//here, you'll find some of your variables. you can add more as you need them.
DcMotor driveFrontRight;
DcMotor driveBackRight;
DcMotor driveFrontLeft;
DcMotor driveBackLeft;
TimeCraftersConfiguration configuration;
double maxSpeed;
//This is the constructor. It lets other code bits run use the code you put here
public DriveTrainTestState() {
configuration = new TimeCraftersConfiguration();
maxSpeed = configuration.variable("testing", "teleop", "maxSpeed").value();
}
@Override
public void init() {
driveFrontRight = engine.hardwareMap.dcMotor.get("driveFrontRight");
driveFrontLeft = engine.hardwareMap.dcMotor.get("driveFrontLeft");
driveBackRight = engine.hardwareMap.dcMotor.get("driveBackRight");
driveBackLeft = engine.hardwareMap.dcMotor.get("driveBackLeft");
driveFrontLeft.setDirection(DcMotorSimple.Direction.REVERSE);
driveBackLeft.setDirection(DcMotorSimple.Direction.REVERSE);
}
//This is a method. methods are bits of code that can be run elsewhere.
//This one is set up to repeat every few milliseconds
@Override
public void exec() {
driveFrontRight.setPower(-engine.gamepad1.right_stick_y * maxSpeed);
driveBackRight.setPower(-engine.gamepad1.right_stick_y * maxSpeed);
driveFrontLeft.setPower(-engine.gamepad1.left_stick_y * maxSpeed);
driveBackLeft.setPower(-engine.gamepad1.left_stick_y * maxSpeed);
}
}