-
Notifications
You must be signed in to change notification settings - Fork 0
/
Robot2014.cpp
82 lines (70 loc) · 2.42 KB
/
Robot2014.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
#include "WPILib.h"
#include "Commands/Command.h"
#include "Commands/ExampleCommand.h"
#include "Commands/Autonomous.h"
#include "CommandBase.h"
#include "Commands/MoveGrabberArms.h"
#include "Commands/MoveGrabberWheels.h"
#include "Potentiometers.h"
#include <iostream>
#include "Robotmap.h"
class Robot2014 : public IterativeRobot {
private:
Command *autonomousCommand;
LiveWindow *lw;
virtual void RobotInit() {
std::cout<<"Start RobotInit\n";
std::cout<<"Init CommandBase (Subsystems and OI)\n";
CommandBase::init();
std::cout<<"Init AutonomousDrive\n";
autonomousCommand = new AutonomousDrive();
std::cout<<"Init LiveWindow reference\n";
lw = LiveWindow::GetInstance();
Compressor * c = new Compressor(kPressureSwitchChannel, kCompressorRelayChannel);
c->Start();
std::cout<<"End of RobotInit"<<std::endl;
}
virtual void AutonomousInit() {
autonomousCommand->Start();
}
virtual void AutonomousPeriodic() {
Scheduler::GetInstance()->Run();
}
virtual void TeleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
autonomousCommand->Cancel();
std::cout<<"Start Teleop\r\n";
}
virtual void TeleopPeriodic() {
SmartDashboard::PutNumber("Grabber Pot Value", GrabberPotentiometer().Get());
SmartDashboard::PutNumber("Launcher Pot Value", LauncherPotentiometer().Get());
Scheduler::GetInstance()->Run();
}
virtual void TestPeriodic() {
lw->Run();
}
virtual void DisabledInit(){
std::cout<<"Start Disabled";
static bool grabberInitialized = false;
double samplesTotal;
double averageSample;
const int numSamples = 10;
for(int i = 0; i < numSamples; ++i)
{
samplesTotal+= GrabberPotentiometer().Get();
}
averageSample = samplesTotal / numSamples;
const double angleRange = 65;
const double upRegisteringOffset = 5;
const double downRegisteringOffset = 20;
MoveGrabberArms::armUpAngle = averageSample - upRegisteringOffset;
MoveGrabberArms::armDownAngle = (averageSample - angleRange) + downRegisteringOffset;
grabberInitialized = true;
std::cout<<"Disabled Initialized\nArmUpAngle:"<<MoveGrabberArms::armUpAngle<<"\n";
std::cout<<"ArmDownAngle:"<<MoveGrabberArms::armDownAngle<<"\n";
}
};
START_ROBOT_CLASS(Robot2014);