Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasketToPark1 is done! #52

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e1b18a2
added encoders but still need to tweak actual encoder values
JustinBustinOACodin Oct 21, 2024
db7d58f
Created AutoLongBasket.java
lmaoNebula Oct 21, 2024
d37b2fd
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
lmaoNebula Oct 21, 2024
915cb20
Moved AutoLongBasket.java into IntoTheDeep folder
lmaoNebula Oct 21, 2024
3262cd5
fixed the actual encoder values. Me and adnan did math.
JustinBustinOACodin Oct 22, 2024
4b0ce22
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
JustinBustinOACodin Oct 22, 2024
bed846b
Finished Basket-side AutoLongBasket
lmaoNebula Oct 22, 2024
4bcf01c
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
lmaoNebula Oct 22, 2024
7d72c06
this time i actually fixed the encoder values. also what is our game …
JustinBustinOACodin Oct 22, 2024
6237d19
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
JustinBustinOACodin Oct 22, 2024
817922a
observation auto:
Garuda101 Oct 22, 2024
429be97
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
Garuda101 Oct 22, 2024
3221977
fixed the encoder values
JustinBustinOACodin Oct 23, 2024
835bfae
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
JustinBustinOACodin Oct 23, 2024
46dcf6c
finally fixed encoder values but still need to actually know how to d…
JustinBustinOACodin Oct 23, 2024
2340364
added intake and outtake and did the servo set position
JustinBustinOACodin Oct 23, 2024
b3bdd78
Added clawState = 1 before running loop, created and defined servo va…
lmaoNebula Oct 23, 2024
8270cb4
CRServo Update
lmaoNebula Oct 24, 2024
3451726
added servo variables
JustinBustinOACodin Oct 24, 2024
d929c21
woops forgot the CRServo
JustinBustinOACodin Oct 24, 2024
b5066c1
added set powers
JustinBustinOACodin Oct 24, 2024
7af1d71
cheese
Garuda101 Oct 28, 2024
b63bbfd
anticheese
Garuda101 Oct 28, 2024
0e89490
sigma sam is not so sigma he said hes gonna rap also this was nav not…
Garuda101 Oct 28, 2024
edec252
sam did all the work
JustinBustinOACodin Oct 28, 2024
215a2b5
added intake pivot dcmotor
JustinBustinOACodin Oct 29, 2024
109e80d
AutoLongBasket updated to sam assignment
lmaoNebula Oct 29, 2024
8967348
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
lmaoNebula Oct 29, 2024
db3ab6f
Finished AutoLongBasket Basket-Side ruthvik hurry up and do your part…
lmaoNebula Oct 30, 2024
fd321e3
Took inspiration from autolongbasket and used it to create basket side
JustinBustinOACodin Oct 30, 2024
02ceaed
i think this is what he asked for
lmaoNebula Nov 13, 2024
9dd9477
benny did all the work
JustinBustinOACodin Nov 14, 2024
1f2a897
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
JustinBustinOACodin Nov 14, 2024
e65e57f
gg
JustinBustinOACodin Nov 14, 2024
4cc1146
Added Observation Side from Ruthvik
lmaoNebula Nov 14, 2024
544b7dd
Merge branch 'Team-19812-IntoTheDeep' of https://github.com/OASTEM/ft…
lmaoNebula Nov 14, 2024
5f8f4c4
Added offset to basket side BasketToPark1
lmaoNebula Nov 14, 2024
ff2958f
ruthvik did his thing
lmaoNebula Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion FTC_Team1/LinearSlideTest1.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package org.firstinspires.ftc.robotcontroller.external.samples;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
Expand Down Expand Up @@ -50,9 +49,16 @@ public class LinearSlideTest1 extends LinearOpMode {
private DcMotor rightFrontDrive = null;
private DcMotor rightBackDrive = null;
private DcMotor slideArm = null;
private CRServo upperServo = null;
private CRServo lowerServo = null;
private DcMotor clawState = null;
private double slideArmCD = 0.0;
private double clawCD = 0.0;
LinearSlideStates slideArmState = LinearSlideStates.HoldingTwo;
private double motorPosition = 0.0;
private DcMotor intakePivotMotor = null;
private DcMotor intakeState = null;
private DcMotor intakeCD = null;

slideArm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
slideArm.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODERS);
Expand All @@ -65,13 +71,17 @@ public void runOpMode() {
rightFrontDrive = hardwareMap.get(DcMotor.class, "fRight");
rightBackDrive = hardwareMap.get(DcMotor.class, "bRight");
slideArm = hardwareMap.get(DcMotor.class, "slideMotor");
upperServo = hardwareMap.get(CRServo.class, "topIntake");
lowerServo = hardwareMap.get(CRServo.class, "bottomIntake");

leftFrontDrive.setDirection(DcMotor.Direction.REVERSE);
leftBackDrive.setDirection(DcMotor.Direction.REVERSE);

telemetry.addData("Status", "Initialized");
telemetry.update();

clawState = 1;

waitForStart();
runtime.reset();

Expand Down Expand Up @@ -109,6 +119,59 @@ public void runOpMode() {
slideArmCD = runtime.time();
}

clawState = 1

if(gamepad1.a && runtime.time()-clawCD >= 0.2){
if(clawState == 1){
clawState = 2;
clawCD = runtime.time();
} else if(clawState >= 2) {
clawState = 1;
clawCD = runtime.time();
}

if(clawState == 1){
upperServo.setPower(1.0);
lowerServo.setPower(-1.0);
} else if(clawState == 2){
lowerServo.setPower(1.0);
upperServo.setPower(-1.0);
}

if(gamepad1.y && runtime.time()-intakeCD >= 0.2){
intakeState = intakeState(1);
intakeCD = runtime.time();
}
if(gamepad1.x && runtime.time()-intakeCD >= 0.2){
intakeState = intakeState(2);
intakeCD = runtime.time();
}

intakeState = 0

if(gamepad1.y){
intakeState = 1;
intakeCD = runtime.time();
}

if (gamepad1.x) {
intakeState = 2;
intakeCD = runtime.time();
}
if (!gamepad1.y && !gamepad1.x) {
intakeState = 0
intakeCD = runtime.time();
}


if(intakeState == 0){
intakePivotMotor.setPower(0.3);
} else if (intakeState == 1) {
intakePivotMotor.setPower(0.5);
} else if (intakeState == 2) {
intakePivotMotor.setPower(-0.3);
}

checkAndSetSlideState(); // So this is jus thte switch states code but turned neater

// Send calculated power to wheels
Expand Down
215 changes: 215 additions & 0 deletions FTC_Team1/RobotCode/Into The Deep/AutoLongBasket.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
package RobotCode;

import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotorEx;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.util.ElapsedTime;

//@Disabled haha you thought I would do it again lol
@Autonomous(name="Autonomous Long Basket", group="Linear Opmode")

public class AutoLongBasket extends LinearOpMode {
private final double wheelCircumference = 75*3.14;
private final double gearReduction = 3.61*5.23;
private final double counts = 28.0;

private final double rev = counts*gearReduction;
private final int revPerMM = (int)rev/(int)wheelCircumference;
private final double inches = revPerMM*25.4;

// Declare OpMode members for each of the 4 motors.
private ElapsedTime runtime = new ElapsedTime();
private DcMotorEx leftFrontDrive = null;
private DcMotorEx leftBackDrive = null;
private DcMotorEx rightFrontDrive = null;
private DcMotorEx rightBackDrive = null;
private DcMotor clawPivotMotor = null;
private CRServo upperServo = null;
private CRServo lowerServo = null;

@Override

public void runOpMode() {
leftFrontDrive = hardwareMap.get(DcMotorEx.class, "fLeft");
leftBackDrive = hardwareMap.get(DcMotorEx.class, "bLeft");
rightFrontDrive = hardwareMap.get(DcMotorEx.class, "fRight");
rightBackDrive = hardwareMap.get(DcMotorEx.class, "bRight");
clawPivotMotor = hardwareMap.get(DcMotor.class, "intakePivotMotor");
upperServo = hardwareMap.get(CRServo.class, "topIntake");
lowerServo = hardwareMap.get(CRServo.class, "bottomIntake");


leftFrontDrive.setDirection(DcMotorEx.Direction.REVERSE);
leftBackDrive.setDirection(DcMotorEx.Direction.REVERSE);

// Wait for the game to start (driver presses PLAY)
telemetry.addData("Status", "Initialized");
telemetry.update();
int runCount=0;
waitForStart();
runtime.reset();


}

// vvvvvvvvvvvvvvvvvvvv THIS IS WHERE THE FUNCTIONS ARE vvvvvvvvvvvvvvvvvvvv

public void input(double leftFront, double rightFront, double leftBack, double rightBack)
{
leftFrontDrive.setPower(leftFront);
rightFrontDrive.setPower(rightFront);
leftBackDrive.setPower(leftBack);
rightBackDrive.setPower(rightBack);
sleep(500);
}
public void turnLeft(int angle)
{
int convert=revPerMM*angle*(38/10)+(angle*12/10);
encoders(-convert, convert, -convert, convert);
}
public void turnRight(int angle)
{
int convert=revPerMM*angle*(38/10)+(angle*12/10);
encoders(convert, -convert, convert, -convert);
}
public void driveEncoders(int target)
{
encoders(target, target, target, target);
}
public void backEncoders(int target)
{
encoders(-target, -target, -target, -target);
}
public void rightEncoders(int target)
{
encoders(target, -target, -target, target);
}
public void leftEncoders(int target)
{
encoders(-target, target, target, -target);
}
public void leftTopDiagonal(int target)
{
encoders(0, target, target, 0);
}
public void rightTopDiagonal(int target)
{
encoders(target, 0, 0, target);
}
public void leftBottomDiagonal(int target)
{
encoders(-target, 0, 0, -target);
}
public void rightBottomDiagonal(int target)
{
encoders(0, -target, -target, 0);
}
public void encoders(int leftFront, int rightFront, int leftBack, int rightBack)
{
leftFrontDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightFrontDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
leftBackDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
rightBackDrive.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);

leftFrontDrive.setTargetPosition(leftFront*revPerMM);
rightFrontDrive.setTargetPosition(rightFront*revPerMM);
leftBackDrive.setTargetPosition(leftBack*revPerMM);
rightBackDrive.setTargetPosition(rightBack*revPerMM);

leftFrontDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightFrontDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
leftBackDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);
rightBackDrive.setMode(DcMotor.RunMode.RUN_TO_POSITION);

double power=0.2;
leftFrontDrive.setVelocity(1500);
rightFrontDrive.setVelocity(1500);
leftBackDrive.setVelocity(1500);
rightBackDrive.setVelocity(1500);
while (opModeIsActive()&&leftFrontDrive.isBusy()||rightFrontDrive.isBusy()||leftBackDrive.isBusy()||rightBackDrive.isBusy())
{
}
leftFrontDrive.setPower(0);
rightFrontDrive.setPower(0);
leftBackDrive.setPower(0);
rightBackDrive.setPower(0);
}
public void drive()
{
leftFrontDrive.setPower(1.0);
rightFrontDrive.setPower(1.0);
leftBackDrive.setPower(1.0);
rightBackDrive.setPower(1.0);
//input(0.4, 0.4, 0.4, 0.4);
}
public void topRight()
{
input(0.4, 0, 0, 0.4);
}
public void right()
{
input(0.4, -0.4, -0.4, 0.4);
}
public void bottomRight()
{
input(0, -0.4, -0.4, 0);
}
public void back()
{
input(-0.4, -0.4, -0.4, -0.4);
}
public void bottomLeft()
{
input(-0.4, 0, 0, -0.4);
}
public void left()
{
input(-0.4, 0.4, 0.4, -0.4);
}
public void topLeft()
{
input(0, 0.4, 0.4, 0);
}
public void stop(double time)
{
input(0, 0, 0, 0);
}
public void basket(){
turnLeft(90);
driveEncoders(610);
// arm to score thing here
slideMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER); //idk sam said to put it
slideMotor.setTargetPosition(2505); // arm up to basket
slideMotor.setVelocity(1500); //idk sam said to put it
while (slideMotor.isBusy()){
}
slideArm.setPower(0);
intakePivotMotor.setPower(0.5);
while(intakePivotMotor.isBusy()){
}
upperServo.setPower(1.0);
lowerServo.setPower(-1.0);
sleep(3000);
intakePivotMotor.setPower(0.3);
//this is where the scoring thing stops
turnLeft(180);
driveEncoders(2440);
turnLeft(90);
driveEncoders(1220);
rightEncoders(610);
backEncoders(1220);
}
public void observation(){
driveEncoders(300);
turnLeft(90);
driveEncoders(1371.6);
turnLeft(45);
sleep(3000)
turnRight(45);
backEncoders(1676.2);
leftEncoders(300);
}
}
Loading