Skip to content

Commit cc0f37d

Browse files
committed
Merge remote-tracking branch 'origin/Train' into Train
2 parents 04324ff + 455807e commit cc0f37d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.firstinspires.ftc.teamcode.opmode;
2+
3+
import com.acmerobotics.dashboard.config.Config;
4+
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
5+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
6+
import com.qualcomm.robotcore.hardware.DcMotor;
7+
import com.qualcomm.robotcore.hardware.DcMotorSimple;
8+
9+
@Config
10+
@TeleOp
11+
public class nickpidloop extends LinearOpMode {
12+
13+
private DcMotor leftFrontMotor;
14+
private DcMotor rightFrontMotor;
15+
private DcMotor leftBackMotor;
16+
private DcMotor rightBackMotor;
17+
private DcMotor Arm;
18+
double refrence;
19+
20+
public void runOpMode() throws InterruptedException {
21+
22+
leftFrontMotor = hardwareMap.get(DcMotor.class, "front_left");
23+
rightFrontMotor = hardwareMap.get(DcMotor.class, "front_right");
24+
leftBackMotor = hardwareMap.get(DcMotor.class, "back_left");
25+
rightBackMotor = hardwareMap.get(DcMotor.class, "back_right");
26+
Arm = hardwareMap.get(DcMotor.class, "arm");
27+
double encoderPosition = 0;
28+
waitForStart();
29+
double error = 1.1;
30+
double power = 0;
31+
32+
refrence = 300;
33+
Arm.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
34+
Arm.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
35+
36+
while (opModeIsActive()) {
37+
38+
while (gamepad1.b)
39+
40+
41+
// obtaining encoder position
42+
encoderPosition = Arm.getCurrentPosition();
43+
// calculate error
44+
error = refrence - encoderPosition;
45+
power = (error/250)*.7;
46+
if(power>0.7){
47+
power = 0.7;
48+
}
49+
else if(power<-.7){
50+
power = -0.7;
51+
}
52+
53+
}
54+
}
55+
56+
57+
}

0 commit comments

Comments
 (0)