Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ToborUser committed Jan 26, 2024
1 parent 79d1b20 commit 6bc58a4
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EachMotorSet.drive;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.backwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.forwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeLeftAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.turnLeftAuto;

import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.codec.Encoder;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.hardware.Servo;

import org.firstinspires.ftc.teamcode.operations.Target_operations;
Expand Down Expand Up @@ -54,8 +56,14 @@ public void runInitLoop(){}

@Override
public void runStart() {
// guess that team prop is in middle
forwardAuto(30,3,500);
backwardAuto(30,3,500);

// park
forwardAuto(3,1,500);
strafeLeftAuto(37,1,500);
// pixel pushed
}
@Override
public void runStop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EachMotorSet.drive;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.backwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.forwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeLeftAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeRightAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.Target_definingDriveMovements.ticksPerInch;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;

Expand All @@ -21,6 +23,7 @@
@Autonomous(name="Blue, Far Side", group="auto")
public class BlueFarSide extends Target_operations {

double inches;
@Override
public void runOpMode() {

Expand Down Expand Up @@ -49,17 +52,25 @@ public void runInitLoop() {

@Override
public void runStart() {
forwardAuto(3,3,500); //
// guess that team prop is in middle
forwardAuto(30,3,500);
backwardAuto(30,3,500);

// park
// grab pixel
forwardAuto(3, 3,500); //
strafeRightAuto(8,3,500); //
forwardAuto(15,3,500); //
strafeRightAuto(17,3,500); //
forwardAuto(58,3,500);
strafeLeftAuto(110,3,500);
strafeLeftAuto(123,3,500);
// let go of pixel

}

@Override
public void runLoop() {

telemetry.addData("target ", 500);
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 @@ -8,6 +8,7 @@
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EachMotorSet.drive;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.backwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.forwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeRightAuto;

Expand Down Expand Up @@ -48,8 +49,14 @@ public void runInitLoop() {

@Override
public void runStart() {
// guess that team prop is in middle
forwardAuto(30,3,500);
backwardAuto(30,3,500);

// park
forwardAuto(3,1,500);
strafeRightAuto(39,1,500);
// pixel pushed
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,19 @@ public void runInitLoop() {

@Override
public void runStart() {
// guess that team prop is in middle
forwardAuto(30,3,500);
backwardAuto(30,3,500);

// park
// grab pixel
forwardAuto(3, 3,500); //
strafeLeftAuto(8,3,500); //
forwardAuto(15,3,500); //
strafeLeftAuto(17,3,500); //
forwardAuto(58,3,500);
strafeRightAuto(123,3,500);
// let go of pixel
}

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

import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.Target_inputs.imu;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.CentricMovements.fieldCentric.turn;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EachMotorSet.drive;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.backwardAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.forwardAuto;

import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeLeftAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.strafeRightAuto;

import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.turnLeftAuto;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.turnRightAuto;

import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.codec.Encoder;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.IMU;

import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import org.firstinspires.ftc.teamcode.operations.Target_operations;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Wheels;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Wheels;

@Autonomous(name="Team Props", group="auto")
public class TeamProps extends Target_operations {
@Autonomous(name="Blue, Board Side 2 -> Team Props", group="auto")
public class TeamProp_Find extends Target_operations {

DcMotor arm;
DistanceSensor sensorRange;
Expand All @@ -53,37 +50,43 @@ public void runInit() {
sensorRange = hardwareMap.get(DistanceSensor.class, "eye");
// ^ set motor directions
initAprilTag(hardwareMap, "Webcam 1", telemetry);
imu = hardwareMap.get(IMU.class, "imu");
Encoders.use();
Encoders.clear();



}

@Override
public void runInitLoop(){}

@Override
public void runStart() {
backwardAuto(13,3,200); // away from wall.
turnRightAuto(580+45+22,3,500);
// styles said 290 should = 45 degrees so 45 + 45 is 90 so 580 because 290 + 290 = 580
// close claw
forwardAuto(21,3,500);
if (sensorRange.getDistance(DistanceUnit.INCH) < 7) { // zone 2
// open claw
}
else {
turnLeftAuto(180*20, 3,500); // zone 1
if (sensorRange.getDistance(DistanceUnit.INCH) < 7) {
// open claw
}
else {
turnLeftAuto(180*20*2, 3,500);
forwardAuto(3,3,500);
// open claw
}
}
}


/*sleep(2500);
backwardAuto(5,1,500);
sleep(2500);
strafeRightAuto(3, 1,500);
if (sensorRange.getDistance(DistanceUnit.INCH) <= 20) {
backwardAuto(5,1,500);
}*/
}
@Override
public void runStop() {
stopAll();
}
@Override
public void runLoop() {
telemetry.addData("distance ", sensorRange.getDistance(DistanceUnit.INCH));

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
@@ -0,0 +1,81 @@
package org.firstinspires.ftc.teamcode.gamecode.autonomous;

import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.Target_inputs.imu;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EncoderTickDefinitions.forwardAuto;

import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DistanceSensor;
import com.qualcomm.robotcore.hardware.IMU;

import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import org.firstinspires.ftc.teamcode.operations.Target_operations;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Wheels;
import org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Encoders;

@Autonomous(name="Chance Program (Team Prop)", group="auto")
public class TeamProp_Guessed extends Target_operations {

DcMotor arm;
DistanceSensor sensorRange;
double degrees;

@Override
public void runOpMode() throws InterruptedException {
// LinearOpMode that calls a different form of OpMode:
runInit();
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();} // stop OpMode if the button is pressed
while (opModeIsActive()) {runLoop();}
}

@Override
public void runInit() {
//arm = hardwareMap.dcMotor.get("arm");
mapMotors(hardwareMap, Wheels.FRONT_LEFT.abbreviation(),Wheels.FRONT_RIGHT.abbreviation(),Wheels.BACK_LEFT.abbreviation(),Wheels.BACK_RIGHT.abbreviation());
forwardMotors(true,false,true,false);
sensorRange = hardwareMap.get(DistanceSensor.class, "eye");
// ^ set motor directions
initAprilTag(hardwareMap, "Webcam 1", telemetry);
imu = hardwareMap.get(IMU.class, "imu");
Encoders.use();
Encoders.clear();



}

@Override
public void runInitLoop(){}

@Override
public void runStart() {
forwardAuto(30,5,100); // push pixel onto guessed tape

}
@Override
public void runStop() {
stopAll();
}
@Override
public void runLoop() {
telemetry.addData("distance ", sensorRange.getDistance(DistanceUnit.INCH));
telemetry.addData("position FL ", fl.getCurrentPosition());
telemetry.addData("position FR ", fr.getCurrentPosition());
telemetry.addData("position BL ", bl.getCurrentPosition());
telemetry.addData("position BR ", br.getCurrentPosition());
telemetry.addData("degree ", imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.DEGREES));
telemetry.update();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.LogoFacingDirection.UP;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.BACKWARD;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.LEFT;
import static com.qualcomm.hardware.rev.RevHubOrientationOnRobot.UsbFacingDirection.RIGHT;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.initAprilTag;
import static org.firstinspires.ftc.teamcode.operations.inputs.AprilTag.visionPortal;
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuGet;
import static org.firstinspires.ftc.teamcode.operations.inputs.Imu.imuReset;
import static org.firstinspires.ftc.teamcode.operations.inputs.Target_inputs.cameraConnected;
import static org.firstinspires.ftc.teamcode.operations.inputs.Target_inputs.imu;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.bl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.br;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fl;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.forwardMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.fr;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.ConfigureMotors.mapMotors;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.botHeading;
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.Mecanum.dpadMovements;
Expand All @@ -18,24 +24,32 @@
import static org.firstinspires.ftc.teamcode.operations.outputs.motors.drive.definingDriveMovements.EachMotorSet.driveStop;

import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DistanceSensor;

import org.firstinspires.ftc.robotcore.external.navigation.AngleUnit;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import org.firstinspires.ftc.teamcode.operations.inputs.DeviceNames;
import org.firstinspires.ftc.teamcode.operations.Target_operations;

@TeleOp
public class DriverControlled extends Target_operations {
double speed = 0.5; // speed used when using hardcore mode
DistanceSensor sensorRange;
boolean rangePluggedIn;

@Override
public void runOpMode() {
runInit();
if (isStopRequested()){runStop();}
while(opModeInInit()){runInitLoop();}
waitForStart();
runStart();
if (isStopRequested()){runStop();}
while (opModeIsActive()) {runLoop();}
}



@Override
public void runInit() {
mapMotors(hardwareMap, "fl","fr","bl","br");
Expand All @@ -44,8 +58,15 @@ public void runInit() {
// this is commented because it might show an error sense this motor is not configured and can't be because the motor is not yet connected.
// ConfigureMotorPixel.mapMotor("pixel");
// (hardwareMap, imu device name, logo, USB)
imuGet(hardwareMap, DeviceNames.DEFAULT_IMU.hardwareMapName(), LEFT.name(), UP.name());
imuGet(hardwareMap, DeviceNames.DEFAULT_IMU.hardwareMapName(), RIGHT.name(), UP.name());
initAprilTag(hardwareMap, DeviceNames.DEFAULT_CAMERA.hardwareMapName(), telemetry);
try {
sensorRange = hardwareMap.get(DistanceSensor.class, "eye");
rangePluggedIn = true;
}
catch (Exception E){
rangePluggedIn = false;
}

// ConfigureMotorPixel.mapMotor(hardwareMap, "pixel");
// PixelMotorMovements.motorEncoder(); // pixel motor not connected
Expand All @@ -67,7 +88,18 @@ public void runLoop() {

imuReset(gamepad1.options); // resets imu case of accidents or incidences
fieldCentricMath(); // does the required math for Mecanum drive as well as getting imu for field centric
telemetry.addData("", botHeading);

telemetry.addData("bot heading: ", botHeading);
if (rangePluggedIn) {
telemetry.addData("distance ", sensorRange.getDistance(DistanceUnit.INCH));
}
telemetry.addData("position FL ", fl.getCurrentPosition());
telemetry.addData("position FR ", fr.getCurrentPosition());
telemetry.addData("position BL ", bl.getCurrentPosition());
telemetry.addData("position BR ", br.getCurrentPosition());
telemetry.addData("degrees ", imu.getRobotYawPitchRollAngles().getYaw(AngleUnit.DEGREES));
telemetry.update();

//convertPowerToEncoderUse();
//runPixelMotor(gamepad2.a);
//runBarMotor(gamepad2.y);
Expand Down
Loading

0 comments on commit 6bc58a4

Please sign in to comment.