Massive upgrade and shift of files
This commit is contained in:
@ -1,8 +0,0 @@
|
|||||||
package nbRedAutoV1;
|
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
|
||||||
|
|
||||||
public class Java {
|
|
||||||
}
|
|
@ -0,0 +1,24 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.teamcode.cometbots.CometBotAutoDevelopment;
|
||||||
|
|
||||||
|
@TeleOp(name = "CometBot Auto", group = "Development")
|
||||||
|
public class CometBotDevAuto extends OpMode {
|
||||||
|
|
||||||
|
public CometBotAutoDevelopment runMode;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
this.runMode = new CometBotAutoDevelopment(hardwareMap, telemetry, gamepad1, gamepad2);
|
||||||
|
this.runMode.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
this.runMode.update();
|
||||||
|
telemetry.update();
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,11 @@ public class PedroConstants {
|
|||||||
public static final Direction FRONT_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
public static final Direction FRONT_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
||||||
public static final Direction BACK_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
public static final Direction BACK_RIGHT_MOTOR_DIRECTION = Direction.FORWARD;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Motor Max Power
|
||||||
|
*/
|
||||||
|
public static final double MAX_POWER = .75;
|
||||||
|
|
||||||
// Robot IMU configuration
|
// Robot IMU configuration
|
||||||
public static final String IMU = "imu";
|
public static final String IMU = "imu";
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
|
||||||
|
|
||||||
public class BluenbAutov1 {
|
|
||||||
}
|
|
@ -0,0 +1,122 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.MAX_POWER;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.acmerobotics.roadrunner.SequentialAction;
|
||||||
|
import com.acmerobotics.roadrunner.SleepAction;
|
||||||
|
import com.acmerobotics.roadrunner.ftc.Actions;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
|
import org.firstinspires.ftc.teamcode.states.FieldStates;
|
||||||
|
import org.firstinspires.ftc.teamcode.subsystem.MotorsSubsystem;
|
||||||
|
|
||||||
|
public class CometBotAutoDevelopment {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Subsystems
|
||||||
|
*/
|
||||||
|
private MotorsSubsystem motors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Controllers
|
||||||
|
*/
|
||||||
|
public Gamepad GP1;
|
||||||
|
public Gamepad GP2;
|
||||||
|
public Gamepad currentGP1;
|
||||||
|
public Gamepad previousGP1;
|
||||||
|
public Gamepad currentGP2;
|
||||||
|
public Gamepad previousGP2;
|
||||||
|
private Telemetry telemetry;
|
||||||
|
public FieldStates fieldStates;
|
||||||
|
|
||||||
|
private Follower follower;
|
||||||
|
private HardwareMap hardwareMap;
|
||||||
|
private double currentPower = MAX_POWER;
|
||||||
|
|
||||||
|
public CometBotAutoDevelopment(HardwareMap hardwareMap, Telemetry telemetry, Gamepad gp1, Gamepad gp2) {
|
||||||
|
this.motors = new MotorsSubsystem(hardwareMap, telemetry);
|
||||||
|
this.GP1 = gp1;
|
||||||
|
this.GP2 = gp2;
|
||||||
|
this.hardwareMap = hardwareMap;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.currentGP1 = new Gamepad();
|
||||||
|
this.currentGP2 = new Gamepad();
|
||||||
|
this.previousGP1 = new Gamepad();
|
||||||
|
this.previousGP2 = new Gamepad();
|
||||||
|
this.fieldStates = new FieldStates();
|
||||||
|
this.follower = new Follower(hardwareMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ZeroOutPower implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
follower.setMaxPower(0);
|
||||||
|
System.out.println("Running ZeroOutPower");
|
||||||
|
return follower.isBusy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReturnToMaxPower implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(@NonNull TelemetryPacket telemetryPacket) {
|
||||||
|
follower = new Follower(hardwareMap);
|
||||||
|
follower.setMaxPower(MAX_POWER);
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
System.out.println("Running ReturnToMaxPower");
|
||||||
|
return follower.isBusy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action zeroOutPower() {
|
||||||
|
return new ZeroOutPower();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action returnToMaxPower() {
|
||||||
|
return new ReturnToMaxPower();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.motors.init();
|
||||||
|
this.fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
follower.setMaxPower(MAX_POWER);
|
||||||
|
follower.startTeleopDrive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
this.previousGP1.copy(currentGP1);
|
||||||
|
this.currentGP1.copy(this.GP1);
|
||||||
|
this.previousGP2.copy(currentGP2);
|
||||||
|
this.currentGP2.copy(this.GP2);
|
||||||
|
|
||||||
|
this.toFixMotorBlockingIssuer();
|
||||||
|
|
||||||
|
follower.setTeleOpMovementVectors(-this.GP1.left_stick_y, -this.GP1.left_stick_x, -this.GP1.right_stick_x, false);
|
||||||
|
follower.update();
|
||||||
|
this.telemetry.addData("Field State", this.fieldStates.getFieldLocation());
|
||||||
|
this.telemetry.addData("Current Power", currentPower);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toFixMotorBlockingIssuer() {
|
||||||
|
if (this.currentGP1.cross && !this.previousGP1.cross) {
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.BUCKET);
|
||||||
|
Actions.runBlocking(new SequentialAction(
|
||||||
|
new SleepAction(2.5),
|
||||||
|
this.zeroOutPower(),
|
||||||
|
new SleepAction(2.5),
|
||||||
|
this.returnToMaxPower(),
|
||||||
|
new SleepAction(2.5)
|
||||||
|
));
|
||||||
|
fieldStates.setFieldLocation(FieldStates.FieldLocation.TRAVELING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -27,7 +27,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.acmerobotics.dashboard.FtcDashboard;
|
import com.acmerobotics.dashboard.FtcDashboard;
|
||||||
import com.acmerobotics.dashboard.config.Config;
|
import com.acmerobotics.dashboard.config.Config;
|
@ -0,0 +1,4 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
|
public class BluenbAutov1 {
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
@ -1,4 +1,4 @@
|
|||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -27,11 +27,10 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.qualcomm.hardware.bosch.BNO055IMU;
|
import com.qualcomm.hardware.bosch.BNO055IMU;
|
||||||
import com.qualcomm.hardware.bosch.JustLoggingAccelerationIntegrator;
|
import com.qualcomm.hardware.bosch.JustLoggingAccelerationIntegrator;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
|
|
@ -27,10 +27,9 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.firstinspires.ftc.teamcode;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.qualcomm.hardware.bosch.BNO055IMU;
|
import com.qualcomm.hardware.bosch.BNO055IMU;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
|
||||||
import com.qualcomm.robotcore.util.ReadWriteFile;
|
import com.qualcomm.robotcore.util.ReadWriteFile;
|
@ -27,7 +27,7 @@
|
|||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.firstinspires.ftc.teamcode.cometbots;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER;
|
||||||
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_ENCODER_DIRECTION;
|
@ -1,15 +1,16 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
|
||||||
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
import org.firstinspires.ftc.teamcode.pedroPathing.follower.Follower;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Path;
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathChain;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.Point;
|
||||||
|
|
||||||
@Autonomous(name = "bBlueAutoV1", group = "V1")
|
@Autonomous(name = "org.firstinspires.ftc.teamcode.cometbots.projects.bBlueAutoV1", group = "V1")
|
||||||
public class bBlueAutoV1 extends OpMode {
|
public class bBlueAutoV1 extends OpMode {
|
||||||
|
|
||||||
public Telemetry telemetry;
|
public Telemetry telemetry;
|
@ -1,4 +1,4 @@
|
|||||||
package nbRedAutoV1;
|
package org.firstinspires.ftc.teamcode.cometbots.projects;
|
||||||
|
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.BezierLine;
|
||||||
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
import org.firstinspires.ftc.teamcode.pedroPathing.pathGeneration.PathBuilder;
|
@ -0,0 +1,18 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.states;
|
||||||
|
|
||||||
|
public class FieldStates {
|
||||||
|
|
||||||
|
public enum FieldLocation {
|
||||||
|
BUCKET, SUBMARINE, FLOATING, TRAVELING
|
||||||
|
}
|
||||||
|
|
||||||
|
private FieldLocation fieldLocation;
|
||||||
|
|
||||||
|
public FieldLocation getFieldLocation() {
|
||||||
|
return fieldLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldLocation(FieldLocation fieldLocation) {
|
||||||
|
this.fieldLocation = fieldLocation;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
package org.firstinspires.ftc.teamcode.subsystem;
|
||||||
|
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_LEFT_MOTOR_DIRECTION;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.BACK_RIGHT_MOTOR_DIRECTION;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_LEFT_MOTOR_DIRECTION;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.FRONT_RIGHT_MOTOR_DIRECTION;
|
||||||
|
import static org.firstinspires.ftc.teamcode.PedroConstants.MAX_POWER;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.acmerobotics.dashboard.telemetry.TelemetryPacket;
|
||||||
|
import com.acmerobotics.roadrunner.Action;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
import com.qualcomm.robotcore.hardware.Gamepad;
|
||||||
|
import com.qualcomm.robotcore.hardware.HardwareMap;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.Telemetry;
|
||||||
|
|
||||||
|
public class MotorsSubsystem {
|
||||||
|
|
||||||
|
public HardwareMap hardwareMap;
|
||||||
|
public Telemetry telemetry;
|
||||||
|
|
||||||
|
public DcMotor frontLeftMotor;
|
||||||
|
public DcMotor backLeftMotor;
|
||||||
|
public DcMotor frontRightMotor;
|
||||||
|
public DcMotor backRightMotor;
|
||||||
|
|
||||||
|
public enum TravelState {
|
||||||
|
STOPPED, MOVING
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelState travelState;
|
||||||
|
|
||||||
|
public double power;
|
||||||
|
|
||||||
|
public MotorsSubsystem(HardwareMap hardwareMap, Telemetry telemetry) {
|
||||||
|
this.hardwareMap = hardwareMap;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.power = MAX_POWER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MotorsSubsystem(HardwareMap hardwareMap, Telemetry telemetry, double power) {
|
||||||
|
this.hardwareMap = hardwareMap;
|
||||||
|
this.telemetry = telemetry;
|
||||||
|
this.power = power;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
frontLeftMotor = hardwareMap.get(DcMotor.class, FRONT_LEFT_MOTOR);
|
||||||
|
backLeftMotor = hardwareMap.get(DcMotor.class, BACK_LEFT_MOTOR);
|
||||||
|
frontRightMotor = hardwareMap.get(DcMotor.class, FRONT_RIGHT_MOTOR);
|
||||||
|
backRightMotor = hardwareMap.get(DcMotor.class, BACK_RIGHT_MOTOR);
|
||||||
|
|
||||||
|
frontLeftMotor.setDirection(FRONT_LEFT_MOTOR_DIRECTION);
|
||||||
|
backLeftMotor.setDirection(BACK_LEFT_MOTOR_DIRECTION);
|
||||||
|
frontRightMotor.setDirection(FRONT_RIGHT_MOTOR_DIRECTION);
|
||||||
|
backRightMotor.setDirection(BACK_RIGHT_MOTOR_DIRECTION);
|
||||||
|
|
||||||
|
frontLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
backLeftMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
frontRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
backRightMotor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
|
||||||
|
|
||||||
|
this.setState(TravelState.STOPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrontLeftMotorPower(double power) {
|
||||||
|
frontLeftMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackLeftMotorPower(double power) {
|
||||||
|
backLeftMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFrontRightMotorPower(double power) {
|
||||||
|
frontRightMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackRightMotorPower(double power) {
|
||||||
|
backRightMotor.setPower(power);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setState(TravelState travelState) {
|
||||||
|
this.travelState = travelState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TravelState getState() {
|
||||||
|
return this.travelState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPower(DcMotor motor, double power) {
|
||||||
|
motor.setPower(power);
|
||||||
|
if (power < 0.05) {
|
||||||
|
this.setState(TravelState.MOVING);
|
||||||
|
} else {
|
||||||
|
this.setState(TravelState.STOPPED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,9 @@ dependencies {
|
|||||||
implementation 'org.firstinspires.ftc:Vision:10.1.0'
|
implementation 'org.firstinspires.ftc:Vision:10.1.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
|
|
||||||
implementation 'com.acmerobotics.dashboard:dashboard:0.4.5'
|
implementation "com.acmerobotics.roadrunner:ftc:0.1.14"
|
||||||
|
implementation "com.acmerobotics.roadrunner:core:1.0.0"
|
||||||
|
implementation "com.acmerobotics.roadrunner:actions:1.0.0"
|
||||||
|
implementation "com.acmerobotics.dashboard:dashboard:0.4.16"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user