This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRobot.cpp
191 lines (168 loc) · 4.24 KB
/
Robot.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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include "WPILib.h"
#include <math.h>
#include "OmniDriveTrain.h"
#include "Elevator.h"
#include "Accumulator.h"
#include "RobotMap.h"
#include "IMU.h"
#include "IMUAdvanced.h"
#include "AHRS.h"
class Robot: public SampleRobot
{
OmniDriveTrain ODT;//look at header files.
Elevator toteMover;
Accumulator toteGrabber;
Elevator toteStacker;
Elevator canMover;
Joystick l_stick;
Joystick r_stick;
Joystick c_stick; //smash moves for the totes
Solenoid ArmWheels;
Solenoid TheDrawBridgeOfDeath;
PowerDistributionPanel PDP;
float rollerSpeed;
float elevatorSpeed;
float throttle;
float motorStall;
float Encoderval;
bool NotAtRobotPos;
bool NotAtStackPos;
bool StayDown;
bool Auto;
float Pos;
float Pos4StackTop;
float Pos4StackBot;
unsigned int brightness = 16;
public:
Robot() :
ODT(), //make sure these values match...
toteMover(CAN_ELEVATOR_MOTOR,DIGITAL_ROBOT_LIFTA,DIGITAL_ROBOT_LIFTB),
toteGrabber(CAN_LEFT_GRABBER_MOTOR,CAN_RIGHT_GRABBER_MOTOR),
toteStacker(CAN_ONLY_STACKER_MOTOR,DIGITAL_STACKER_LIFTA,DIGITAL_STACKER_LIFTB),
canMover(CAN_CAN_MOTOR,DIGITAL_CAN_LIFTA,DIGITAL_CAN_LIFTB),
l_stick(0),
r_stick(1),
c_stick(2),
ArmWheels(0),
TheDrawBridgeOfDeath(1),
PDP()
{
NotAtRobotPos=false;
NotAtStackPos=false;
rollerSpeed = 1;
elevatorSpeed = 0.5;
throttle = 1;
motorStall = 0.1;
StayDown = false;
TheDrawBridgeOfDeath.Set(0);
//toteStacker.eleMotor.SetVoltageRampRate(120);
}
void Autonomous()
{
while(1)
SmartDashboard::PutNumber("DB/Slider 1",toteStacker.ArmInCoder.Get());
}
void OperatorControl()
{
NotAtStackPos=0;
while (IsOperatorControl() && IsEnabled())
{
/*
* *********************************************************************************************
* DRIVE TRAIN
* *********************************************************************************************
*/
ODT.TankDrive(l_stick.GetY(), r_stick.GetY());
/*
* ********************************************************************************************
* ELEVATOR STUFF
* ********************************************************************************************
*/
//robot
Encoderval=toteMover.ArmInCoder.Get();
SmartDashboard::PutNumber("DB/Slider 3",PDP.GetCurrent(13));
if(l_stick.GetRawButton(6))
{
Pos = POS_PICK_UP;
NotAtRobotPos=true;
}
else if(r_stick.GetRawButton(11))
{
Pos = POS_DROP_IT;
NotAtRobotPos=true;
}
else if(r_stick.GetRawButton(9))
{
Pos = POS_COOP_IT;
NotAtRobotPos=true;
}
SmartDashboard::PutNumber("DB/Slider 2",Pos);
//stacker
if(c_stick.GetRawButton(1))
{
Pos4StackTop=POS_TOP;
Pos4StackBot=POS_MID;
NotAtStackPos = true;
StayDown = false;
TheDrawBridgeOfDeath.Set(0);
if(!toteStacker.FirstIt)
{
toteStacker.LastIt = false;
toteStacker.FirstIt = true;
}
}
if(c_stick.GetRawButton(2)){
NotAtStackPos = true;
StayDown = true;
TheDrawBridgeOfDeath.Set(1);
Pos4StackBot=POS_BOT;
}
if(NotAtStackPos&&!StayDown)
{
//toteStacker.liftToPos(Pos4StackBot);
toteStacker.Stack(Pos4StackTop,Pos4StackBot);
}
else if(StayDown)
{
toteStacker.liftToPos(Pos4StackBot);
}
if(NotAtRobotPos)
{
toteMover.liftToPos(Pos);
}
//can mover
/*
* ********************************************************************************************
* ACCUMULATOR STUFF
* ********************************************************************************************
*/
//for the rollers
if(c_stick.GetRawButton(8))
{
toteGrabber.rollLeftIn(rollerSpeed);
toteGrabber.rollRightIn(rollerSpeed);
ArmWheels.Set(1);
}
else if(c_stick.GetRawButton(7))
{
toteGrabber.rollLeftIn(-rollerSpeed);
toteGrabber.rollRightIn(-rollerSpeed);
ArmWheels.Set(1);
}
else
{
toteGrabber.rollLeftIn(.1);
toteGrabber.rollRightIn(.1);
ArmWheels.Set(0);
}
Wait(0.005);// wait for a motor update time
}
}
/**
* Runs during test mode
*/
void Test()//hello world im pointless!
{
}
};
START_ROBOT_CLASS(Robot);