-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDentRobot.cpp
84 lines (84 loc) · 2.88 KB
/
DentRobot.cpp
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
#include "DentRobot.h"
#include "OI.h"
#include "RobotMap.h"
#include "Commands/Autonomous/Autonomous.h"
OI* DentRobot::oi = NULL;
Collector* DentRobot::collector = NULL;
Drivetrain* DentRobot::drivetrain = NULL;
Elevator* DentRobot::elevator = NULL;
BinElevator* DentRobot::binElevator = NULL;
CommandGroup* DentRobot::aut = NULL;
Pneumatics* DentRobot::pneumatics = NULL;
DentRobot::DentRobot(){
oi = new OI();
collector = new Collector();
drivetrain = new Drivetrain();
elevator = new Elevator();
binElevator = new BinElevator();
pneumatics = new Pneumatics();
//CameraServer::GetInstance()->SetQuality(25);
//CameraServer::GetInstance()->StartAutomaticCapture("cam0");
printf("The robot is on\n");
}
void DentRobot::RobotInit(){
SmartDashboard::PutNumber("CodeVersion", CODE_VERSION);
// Autonomous
// Calibration
// Amount to turn while collecting the initial tote in auto 4
SmartDashboard::PutNumber("CollectToteTurn", 0.25);
// Amount of time to collect a tote
SmartDashboard::PutNumber("DriveTime", 1.3);
// Sequence of autonomous command
SmartDashboard::PutNumber("Auto Sequence", 9.0);
SmartDashboard::PutNumber("Auto Wait Time", 0.5);
// If the robot will be picking up three totes in sequence 3
SmartDashboard::PutBoolean("Two totes", false);
SmartDashboard::PutBoolean("Three totes", false);
// Distance (in time) to auto zone
SmartDashboard::PutNumber("Auto Zone Distance", 2.1);
// Distance (in time) to auto tote (used in sequence 3)
SmartDashboard::PutNumber("Two Tote Distance", 1.0);
SmartDashboard::PutNumber("Three Tote Distance", 2.5);
SmartDashboard::PutNumber("Auto Tote Distance", 0.5);
SmartDashboard::PutNumber("TurnAmount", 2.6);
// Elevators
SmartDashboard::PutBoolean("Bin Elevator Bottom", false);
SmartDashboard::PutBoolean("Bin Elevator Top", false);
SmartDashboard::PutBoolean("Elevator Bottom", false);
SmartDashboard::PutBoolean("Elevator Top", false);
//Drive speed
SmartDashboard::PutNumber("DriveSpeedReductionThresh", 2.0);
//Gyro
SmartDashboard::PutNumber("Gyro kP", -0.02);
}
void DentRobot::DisabledPeriodic(){
Scheduler::GetInstance()->Run();
}
void DentRobot::AutonomousInit(){
aut = new Autonomous(SmartDashboard::GetNumber("Auto Sequence"));
printf("Enabling Auto Sequence %f\n", SmartDashboard::GetNumber("Auto Sequence"));
if(aut != NULL){
aut->Start();
}
}
void DentRobot::AutonomousPeriodic(){
printf("Running auto.\n");
Scheduler::GetInstance()->Run();
}
void DentRobot::TeleopInit(){
if(aut != NULL){
aut->Cancel();
}
}
void DentRobot::TeleopPeriodic(){
Scheduler::GetInstance()->Run();
if(elevator->GetUseEncoder()&&elevator->GetHeight() <= -1.0){
// Raise the elevator if it dips below elevatorTop
oi->raise->Start();
}
SmartDashboard::PutNumber("CollectorThrottle", oi->GetLeftThrottle());
}
void DentRobot::TestPeriodic(){
}
START_ROBOT_CLASS(DentRobot);
// vim: ts=2:sw=2:et