mirror of
https://github.com/TimeCrafters/FreightFrenzy.git
synced 2025-12-13 05:02:34 +00:00
Added Cayden's DriveTrain test program
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user