mirror of
https://github.com/TimeCrafters/FTC_2022
synced 2025-12-16 04:12:34 +00:00
Adding semi-autonomous functions, variable names are *NOT* inspired by the story of Spirit and Opportunity, the names are a coincidence.
This commit is contained in:
@@ -5,6 +5,7 @@ import org.cyberarm.engine.V2.CyberarmState;
|
|||||||
public class PhoenixTeleOPv2 extends CyberarmState {
|
public class PhoenixTeleOPv2 extends CyberarmState {
|
||||||
private double drivePower = 1;
|
private double drivePower = 1;
|
||||||
PhoenixBot1 robot;
|
PhoenixBot1 robot;
|
||||||
|
|
||||||
public PhoenixTeleOPv2(PhoenixBot1 robot) {
|
public PhoenixTeleOPv2(PhoenixBot1 robot) {
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
}
|
}
|
||||||
@@ -15,7 +16,6 @@ public class PhoenixTeleOPv2 extends CyberarmState {
|
|||||||
addParallelState(new TeleOPTankDriver(robot));
|
addParallelState(new TeleOPTankDriver(robot));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,9 +45,8 @@ public class PhoenixTeleOPv2 extends CyberarmState {
|
|||||||
robot.backRightDrive.setPower(BRPower);
|
robot.backRightDrive.setPower(BRPower);
|
||||||
robot.frontLeftDrive.setPower(FLPower);
|
robot.frontLeftDrive.setPower(FLPower);
|
||||||
robot.frontRightDrive.setPower(FRPower);
|
robot.frontRightDrive.setPower(FRPower);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (engine.gamepad1.right_stick_x )
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,15 @@ import com.qualcomm.robotcore.hardware.Servo;
|
|||||||
|
|
||||||
import org.cyberarm.engine.V2.CyberarmState;
|
import org.cyberarm.engine.V2.CyberarmState;
|
||||||
import org.cyberarm.engine.V2.GamepadChecker;
|
import org.cyberarm.engine.V2.GamepadChecker;
|
||||||
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||||
|
|
||||||
public class TeleOPArmDriver extends CyberarmState {
|
public class TeleOPArmDriver extends CyberarmState {
|
||||||
private final PhoenixBot1 robot;
|
private final PhoenixBot1 robot;
|
||||||
private long lastStepTime = 0;
|
private long lastStepTime = 0;
|
||||||
private int CyclingArmUpAndDown = 0;
|
private int CyclingArmUpAndDown = 0;
|
||||||
private GamepadChecker gamepad2Checker;
|
private GamepadChecker gamepad2Checker;
|
||||||
|
private int Opportunity, Endeavour;
|
||||||
|
private double drivePower;
|
||||||
|
|
||||||
public TeleOPArmDriver(PhoenixBot1 robot) {
|
public TeleOPArmDriver(PhoenixBot1 robot) {
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
@@ -34,6 +37,8 @@ public class TeleOPArmDriver extends CyberarmState {
|
|||||||
robot.LowRiserRight.setPosition(0.45);
|
robot.LowRiserRight.setPosition(0.45);
|
||||||
robot.HighRiserLeft.setPosition(0.45);
|
robot.HighRiserLeft.setPosition(0.45);
|
||||||
robot.HighRiserRight.setPosition(0.45);
|
robot.HighRiserRight.setPosition(0.45);
|
||||||
|
Opportunity = 0;
|
||||||
|
Endeavour = 10;
|
||||||
|
|
||||||
|
|
||||||
gamepad2Checker = new GamepadChecker(engine, engine.gamepad2);
|
gamepad2Checker = new GamepadChecker(engine, engine.gamepad2);
|
||||||
@@ -41,6 +46,15 @@ public class TeleOPArmDriver extends CyberarmState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
|
if (robot.collectorDistance.getDistance(DistanceUnit.MM) < 275 && robot.collectorDistance.getDistance(DistanceUnit.MM) > 100) {
|
||||||
|
Endeavour = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (robot.collectorDistance.getDistance(DistanceUnit.MM) < 550 && robot.collectorDistance.getDistance(DistanceUnit.MM) > 275) {
|
||||||
}
|
Endeavour = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,10 +9,12 @@ import org.cyberarm.engine.V2.GamepadChecker;
|
|||||||
public class TeleOPTankDriver extends CyberarmState {
|
public class TeleOPTankDriver extends CyberarmState {
|
||||||
|
|
||||||
private final PhoenixBot1 robot;
|
private final PhoenixBot1 robot;
|
||||||
|
private long lastStepTime = 0;
|
||||||
private double drivePower = 0.3;
|
private double drivePower = 0.3;
|
||||||
private double RobotRotation;
|
private double RobotRotation;
|
||||||
private double RotationTarget, DeltaRotation;
|
private double RotationTarget, DeltaRotation;
|
||||||
private double MinimalPower = 0.2;
|
private double MinimalPower = 0.2;
|
||||||
|
private int DeltaOdometerR, Endeavour, Spirit;
|
||||||
private GamepadChecker gamepad1Checker;
|
private GamepadChecker gamepad1Checker;
|
||||||
public TeleOPTankDriver(PhoenixBot1 robot) {
|
public TeleOPTankDriver(PhoenixBot1 robot) {
|
||||||
this.robot = robot;
|
this.robot = robot;
|
||||||
@@ -34,6 +36,10 @@ public class TeleOPTankDriver extends CyberarmState {
|
|||||||
@Override
|
@Override
|
||||||
public void exec() {
|
public void exec() {
|
||||||
|
|
||||||
|
if (drivePower > 0.1 && ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void CalculateDeltaRotation() {
|
public void CalculateDeltaRotation() {
|
||||||
if (RotationTarget >= 0 && RobotRotation >= 0) {
|
if (RotationTarget >= 0 && RobotRotation >= 0) {
|
||||||
@@ -49,6 +55,16 @@ public class TeleOPTankDriver extends CyberarmState {
|
|||||||
DeltaRotation = Math.abs(RobotRotation + RotationTarget);
|
DeltaRotation = Math.abs(RobotRotation + RotationTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getDeltaOdometerR() {
|
||||||
|
Spirit = robot.OdometerEncoder.getCurrentPosition();
|
||||||
|
if (System.currentTimeMillis() - lastStepTime >= 1000) {
|
||||||
|
lastStepTime = System.currentTimeMillis();
|
||||||
|
DeltaOdometerR = robot.OdometerEncoder.getCurrentPosition() - Spirit;
|
||||||
|
}
|
||||||
|
return DeltaOdometerR;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void buttonUp(Gamepad gamepad, String button) {
|
public void buttonUp(Gamepad gamepad, String button) {
|
||||||
if (engine.gamepad1 == gamepad && button.equals("start")) {
|
if (engine.gamepad1 == gamepad && button.equals("start")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user