-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTWAAutoDriver.java
73 lines (63 loc) · 1.98 KB
/
TWAAutoDriver.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.firstinspires.ftc.teamcode.RobotCoreExtensions;
/**
* Filename: AutoDriver.java
*
* Description:
* This extension is the parent for all other Autodrivers called by all autonomous movements.
* This class defines the beginning and end of each movement.
*
* Methods:
* setWaitTimeBetweenMovements(int milliseconds)
* setupMotion(String motion_description)
* endMotion()
* eStop()
*
*
* Requirements:
* - Hardware configuration
*
* Changelog:
* -Created by Jacob on 2/24/16
* -Edited file description and documentation 7/24/17
*
*/
public abstract class TWAAutoDriver {
AutoTWAHardwareConfiguration hw;
private TWAStallMonitor stallMonitor = new TWAStallMonitor(this);
protected double power = 1.0D;
private int wait_time_ms = 500;
protected boolean eStop = false;
public TWAAutoDriver(AutoTWAHardwareConfiguration hw)
{
this.hw = hw;
}
public void setWaitTimeBetweenMovements(int milliseconds)
{
if (milliseconds < 0) throw new IllegalArgumentException("the wait time should always be positive");
this.wait_time_ms = milliseconds;
}
// Creates setupMotion method - Resets encoders and then starts monitoring the robot for stalling.
protected void setupMotion(String motion_description)
{
eStop = false;
hw.opMode.telemetry.addData("AutoDriver", motion_description);
hw.opMode.telemetry.update();
hw.drivetrain.resetMotorEncoders();
stallMonitor.startMonitoring();
}
// Creates endMotion method - Stops monitoring the robot for stalling.
protected void endMotion()
{
hw.drivetrain.haltDrive();
stallMonitor.stopMonitoring();
hw.opMode.telemetry.addData("AutoDriver", "Halting");
hw.opMode.telemetry.update();
// hw.opMode.sleep(wait_time_ms);
}
// Creates the eStop method to halt program.
protected void eStop()
{
eStop = true;
endMotion();
}
}