-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobotHardware.java
More file actions
119 lines (97 loc) · 2.57 KB
/
RobotHardware.java
File metadata and controls
119 lines (97 loc) · 2.57 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package org.scotsbots.robotbase;
import java.util.ArrayList;
import java.util.List;
import edu.wpi.first.wpilibj.BuiltInAccelerometer;
//import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
/**
* Base class for creating a robot.
* @author Domenic
*
*/
public abstract class RobotHardware
{
public RobotHardware bot;
//universal hardware
public RobotDrive drivetrain;
public BuiltInAccelerometer accelerometer;
public Encoder leftDriveEncoder;
public Encoder rightDriveEncoder;
/**
* Single encoder for measuring driving.
*/
public Encoder forwardDriveEncoder;
public Encoder sideDriveEncoder;
//public static DigitalInput switch1;
//public static DigitalInput switch2;
//public static DigitalInput switch3;
public RobotVision vision;
public RobotVisionDualUSB dualUSBVision;
public List<AutonStrategy>autons = new ArrayList<AutonStrategy>();
public abstract void initialize();
public abstract void teleopInit();
public abstract void teleop();
public abstract String getName();
/**
* Logs data to Smartdashboard. override and call super.logSmartDashboard() to use.
*/
public void logSmartDashboard()
{
if(Robot.bot.getName() != null)
{
SmartDashboard.putString("Current Robot", Robot.bot.getName());
}
if(Robot.bot.forwardDriveEncoder != null && Robot.bot.sideDriveEncoder != null)
{
SmartDashboard.putNumber("Forward Drive Encoder", Robot.bot.forwardDriveEncoder.getDistance());
SmartDashboard.putNumber("Side Drive Encoder", Robot.bot.sideDriveEncoder.getDistance());
}
if(accelerometer != null)
{
Robot.bot.accelerometer.startLiveWindowMode();
}
if(accelerometer != null)
{
SmartDashboard.putNumber("Accelerometer X", Robot.bot.accelerometer.getX());
SmartDashboard.putNumber("Accelerometer Y", Robot.bot.accelerometer.getY());
}
}
/**
* Only needed for custom (drawing stuff on screen). IP Camera will still work without calling this.
* @return
*/
public boolean usesIPCamera()
{
return false;
}
/**
* Call for using the USB camera. Intializes the CameraServer for showing it on the SmartDashboard.
* @return
*/
public boolean usesSingleUSBCamera()
{
return false;
}
public boolean usesDualUSBCameras()
{
return false;
}
public RobotHardware()
{
bot = this;
}
public RobotHardware getBot()
{
return bot;
}
public RobotHardware setBot(RobotHardware r)
{
return bot = r;
}
public void addAuton(AutonStrategy a)
{
autons.add(a);
}
}