Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Train' into Train
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickT209 committed Oct 24, 2024
2 parents 04324ff + 455807e commit cc0f37d
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.firstinspires.ftc.teamcode.opmode;

import com.acmerobotics.dashboard.config.Config;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;

@Config
@TeleOp
public class nickpidloop extends LinearOpMode {

private DcMotor leftFrontMotor;
private DcMotor rightFrontMotor;
private DcMotor leftBackMotor;
private DcMotor rightBackMotor;
private DcMotor Arm;
double refrence;

public void runOpMode() throws InterruptedException {

leftFrontMotor = hardwareMap.get(DcMotor.class, "front_left");
rightFrontMotor = hardwareMap.get(DcMotor.class, "front_right");
leftBackMotor = hardwareMap.get(DcMotor.class, "back_left");
rightBackMotor = hardwareMap.get(DcMotor.class, "back_right");
Arm = hardwareMap.get(DcMotor.class, "arm");
double encoderPosition = 0;
waitForStart();
double error = 1.1;
double power = 0;

refrence = 300;
Arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
Arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);

while (opModeIsActive()) {

while (gamepad1.b)


// obtaining encoder position
encoderPosition = Arm.getCurrentPosition();
// calculate error
error = refrence - encoderPosition;
power = (error/250)*.7;
if(power>0.7){
power = 0.7;
}
else if(power<-.7){
power = -0.7;
}

}
}


}

0 comments on commit cc0f37d

Please sign in to comment.