-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoDriveByDistanceSensor7935.java
50 lines (32 loc) · 1.64 KB
/
AutoDriveByDistanceSensor7935.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
@Autonomous(name = "AutoDriveByDistanceSensor7935", group = "Official")
//@Disabled
public class AutoDriveByDistanceSensor7935 extends LinearOpMode {
//basic set up code for search: 1001
private static final double DRIVE_SPEED = .5, TURN_SPEED = .5, ARM_SPEED = .8, SIDE_SPEED = .5;
private Config7935 robot = new Config7935(this);
public void runOpMode() {
double error=0;
double setPosition=30;
//basic set up code1001
robot.ConfigureRobtHardware();
robot.ConfigureVision();
robot.resetMotorsForAutonomous(robot.left_back, robot.left_front, robot.right_back, robot.right_front);
robot.status("ready");
waitForStart();
robot.DriveForward(DRIVE_SPEED,-35,3);
while(robot.distance_sensor.getDistance(DistanceUnit.INCH)>40){
robot.DriveForward(DRIVE_SPEED,-35,3);
}
telemetry.addData("position",robot.distance_sensor.getDistance(DistanceUnit.INCH));
error=setPosition-robot.distance_sensor.getDistance(DistanceUnit.INCH);
robot.DriveForward(DRIVE_SPEED,error,3);
telemetry.addData("error",error)
.addData("final position",robot.distance_sensor.getDistance(DistanceUnit.INCH));
telemetry.update();
}
}