Skip to content

Commit

Permalink
2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ToborUser committed Feb 12, 2024
1 parent c3a5e7e commit 76f78d4
Show file tree
Hide file tree
Showing 19 changed files with 183 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection.UP;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.RIGHT;
import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuGet;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
Expand Down Expand Up @@ -79,11 +80,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);
TouchSensorButton.mapDigital(hardwareMap); // button


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.arm.Target_arm.arm;
Expand Down Expand Up @@ -62,11 +63,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);
TouchSensorButton.mapDigital(hardwareMap); // button

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection.UP;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.RIGHT;
import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuGet;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
Expand Down Expand Up @@ -79,11 +80,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);
TouchSensorButton.mapDigital(hardwareMap); // button


Expand Down Expand Up @@ -136,7 +133,7 @@ public void runStart() {
telemetry.update();

closeClaw(); // close
rotateArm(800, 1);
rotateArm(1000, 1);


if (teamprop == 2) { // if the middle team prop is found then go to it and drop the pixel
Expand Down Expand Up @@ -193,21 +190,22 @@ public void runStart() {
forwardAuto(17, 1, 1000);
strafeRightAuto(5, 1, 1000);
turnLeftAuto(500 * 3 / 2, 1, 1000);
forwardAuto(2,1,1000);
forwardAuto(10,2,1000);
openClaw();
backwardAuto(2,1,1000);
backwardAuto(5,1,1000);
turnRightAuto(500 * 3, 1, 1000);
backwardAuto(30,1,1000);
backwardAuto(30,5,1000);
}
}

// park
forwardAuto(3, 1,1000); //
strafeRightAuto(5,1,1000); //
forwardAuto(15,1,1000); //
strafeRightAuto(17,1,1000); //
forwardAuto(38,4,1000);
strafeLeftAuto(150,10,1000);
forwardAuto(3, 3,500); //
strafeLeftAuto(5,3,500);
strafeRightAuto(8,3,500); //
forwardAuto(15,3,500); //
strafeRightAuto(13,3,500); //
forwardAuto(30,5,500);
strafeLeftAuto(123,10,1000);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.shaft.Target_shaft.shaft;
Expand Down Expand Up @@ -64,11 +65,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);

fl.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
fr.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Expand Down Expand Up @@ -103,23 +100,24 @@ public void runStart() {
openClaw(0.5);

// guess that team prop is in middle
strafeRightAuto(3,3,500); // away from rigging
forwardAuto(25,3,500);
backwardAuto(25,3,500);
strafeRightAuto(3,3,100); // away from rigging
forwardAuto(25,3,100);
backwardAuto(25,3,100);

// park
forwardAuto(3, 3,500); //
strafeRightAuto(8,3,500); //
forwardAuto(15,3,500); //
strafeRightAuto(17,3,500); //
forwardAuto(48,4,500);
strafeLeftAuto(123,5,500);
forwardAuto(3, 3,100); //
strafeLeftAuto(10,3,100);
strafeRightAuto(8,3,100); //
forwardAuto(15,3,100); //
strafeRightAuto(17,3,100); //
forwardAuto(48,4,100);
strafeLeftAuto(123,5,100);

}

@Override
public void runLoop() {
telemetry.addData("target ", 500);
telemetry.addData("target ", 100);
telemetry.addData("position FL ", fl.getCurrentPosition());
telemetry.addData("position FR ", fr.getCurrentPosition());
telemetry.addData("position BL ", bl.getCurrentPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection.UP;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.RIGHT;
import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuGet;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
Expand Down Expand Up @@ -79,11 +80,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);
TouchSensorButton.mapDigital(hardwareMap); // button


Expand Down Expand Up @@ -136,28 +133,25 @@ public void runStart() {
telemetry.update();

closeClaw(); // close
sleep(700);
// lift arm above ground, holding 1 pixel
rotateArm(100, 1);
sleep(1000);
rotateArm(1000, 1);


if (teamprop == 2) { // if the middle team prop is found then go to it and drop the pixel
telemetry.addData("", "found!");
telemetry.addData("teamprop", teamprop);
telemetry.addData("distance", sensorRange.getDistance(DistanceUnit.INCH));
telemetry.update();
forwardAuto(26, 5, 800);
forwardAuto(26, 2, 1000);
openClaw();
// park
backwardAuto(26, 5, 800);
backwardAuto(27,1,1000);


} else {
scanTimes = 0;
found = false;
// if the middle team prop is not found then search for the team prop on zone 1
forwardAuto(8,1,10000);
strafeRightAuto(5, 1, 800);
forwardAuto(14,1,1000);
strafeRightAuto(10, 1, 1000);
/*turnLeftAuto(500 * 3, 2, 500); // 90 degrees
openClaw();*/

Expand All @@ -179,37 +173,33 @@ public void runStart() {
}

if (teamprop == 3) {
sleep(10000);
telemetry.addData("", "found!");
telemetry.addData("teamprop", teamprop);
telemetry.addData("distance", sensorRange.getDistance(DistanceUnit.INCH));
telemetry.update();
forwardAuto(23, 5, 800);
strafeRightAuto(10, 1, 800);
forwardAuto(16, 1, 1000);
strafeRightAuto(5, 1, 1000);
openClaw(0.5);
// park
strafeLeftAuto(5,1,800);
backwardAuto(26, 5, 800);
backwardAuto(10,1,1000);
strafeLeftAuto(20,1,1000);
backwardAuto(30,1,1000);
} else {
// zone 1
strafeLeftAuto(10, 1, 800);
forwardAuto(25, 5, 800);
strafeRightAuto(5, 1, 800);
turnLeftAuto(500 * 3, 1, 800);
forwardAuto(2,1,800);
strafeLeftAuto(10, 1, 1000);
forwardAuto(17, 1, 1000);
strafeRightAuto(5, 1, 1000);
turnLeftAuto(500 * 3 / 2, 1, 1000);
forwardAuto(10,2,1000);
openClaw();
// park
turnRightAuto(500 * 3,1,800);
backwardAuto(26, 5, 800);
backwardAuto(5,1,1000);
turnRightAuto(500 * 3, 1, 1000);
backwardAuto(30,5,1000);
}
}

// park
forwardAuto(3, 3,500); //
strafeLeftAuto(8,3,500); //
forwardAuto(15,3,500); //
strafeLeftAuto(17,3,500); //
forwardAuto(48,4,500);
strafeRightAuto(123,5,500);
strafeRightAuto(30,5,1000);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.arm.Target_arm.arm;
Expand Down Expand Up @@ -62,11 +63,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);
TouchSensorButton.mapDigital(hardwareMap); // button

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.arm.Target_arm.arm;
Expand Down Expand Up @@ -67,11 +68,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);

fl.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
fr.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.mapOtherThings;
import static org.firstinspires.ftc.teamcode.operations.inOut.Configs.sensorRange;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.TouchSensorButton.button;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.arm.Target_arm.arm;
Expand Down Expand Up @@ -63,11 +64,7 @@ public void runInit() {
initAprilTag(hardwareMap, "Webcam 1", telemetry);
Encoders.clear();

sensorRange = hardwareMap.get(DistanceSensor.class, "left_eye");

arm = hardwareMap.get(DcMotorEx.class, "arm");
shaft = hardwareMap.get(DcMotor.class, "shaft");
claw = hardwareMap.get(Servo.class, "claw");
mapOtherThings(hardwareMap);

fl.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
fr.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import static org.firstinspires.ftc.teamcode.operations.inOut.driverControlled.RobotCentric.initRobotCentric;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.visionPortal;
import static org.firstinspires.ftc.teamcode.operations.inputs.Target_inputs.cameraConnected;
import static org.firstinspires.ftc.teamcode.operations.outputs.driverStation.DriverStation.output;
import static org.firstinspires.ftc.teamcode.operations.outputs.driverStation.DriverStation.outputMake;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.arm.Target_arm.arm;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.armLift.shaft.Target_shaft.shaft;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl;
Expand Down Expand Up @@ -42,15 +44,18 @@ public void runOpMode() {

@Override
public void runInit() {
outputMake(telemetry,"running init");
initFieldCentric(hardwareMap,telemetry);
}

@Override
public void runInitLoop() {
outputMake(telemetry,"running init loop");
}

@Override
public void runStart() {
outputMake(telemetry,"running start");
//claw.setPosition(claw.getPosition()+2000);
fl.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
fr.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
Expand All @@ -64,13 +69,14 @@ public void runStart() {

@Override
public void runLoop() {

output(telemetry, "running loop");
runLoopFieldCentric(telemetry,gamepad1,gamepad2,speed);

}

@Override
public void runStop() {
outputMake(telemetry,"running stop");
if (cameraConnected) {
visionPortal.close();
}
Expand Down
Loading

0 comments on commit 76f78d4

Please sign in to comment.