Adding the autonomous, day 1

This commit is contained in:
Sodi
2022-10-20 20:31:06 -05:00
parent 326064991b
commit 32dc029ac5

View File

@@ -0,0 +1,34 @@
package org.timecrafters.Autonomous.States;
import org.cyberarm.engine.V2.CyberarmState;
import org.timecrafters.testing.states.PrototypeBot1;
public class DriverState extends CyberarmState {
PrototypeBot1 robot;
public DriverState(PrototypeBot1 robot, String groupName, String actionName) {
this.robot = robot;
this.drivePower = robot.configuration.variable(groupName, actionName, "drivePower").value();
}
private float RobotRotation;
private double drivePower;
private int RobotPosition,RobotStartingPosition;
@Override
public void exec() {
if (RobotPosition - RobotStartingPosition < 2500){
drivePower = 1;
robot.backLeftDrive.setPower(drivePower);
robot.backRightDrive.setPower(drivePower);
robot.frontLeftDrive.setPower(drivePower);
robot.frontRightDrive.setPower(drivePower);
} else {
robot.backLeftDrive.setPower(0);
robot.backRightDrive.setPower(0);
robot.frontLeftDrive.setPower(0);
robot.frontRightDrive.setPower(0);
}
}
}