1
1
#pragma config(Sensor, dgtl1, rightDrive, sensorQuadEncoder)
2
2
#pragma config(Sensor, dgtl3, leftDrive, sensorQuadEncoder)
3
- #pragma config(Motor, port1, rightDrive1, tmotorVex393_HBridge, openLoop, reversed)
4
- #pragma config(Motor, port2, rightDrive2, tmotorVex393_MC29, openLoop)
5
- #pragma config(Motor, port3, rightDrive3, tmotorVex393_MC29, openLoop)
6
- #pragma config(Motor, port8, leftDrive1, tmotorVex393_MC29, openLoop)
7
- #pragma config(Motor, port9, leftDrive2, tmotorVex393_MC29, openLoop)
8
- #pragma config(Motor, port10, leftDrive3, tmotorVex393_HBridge, openLoop, reversed)
3
+ #pragma config(Motor, port1, mongoLeft, tmotorVex393_HBridge, openLoop, reversed)
4
+ #pragma config(Motor, port2, leftDrive1, tmotorVex393_MC29, openLoop, reversed)
5
+ #pragma config(Motor, port3, leftDrive2, tmotorVex393_MC29, openLoop)
6
+ #pragma config(Motor, port4, leftDrive3, tmotorVex393_MC29, openLoop, reversed)
7
+ #pragma config(Motor, port5, rightLift, tmotorVex393_MC29, openLoop, reversed)
8
+ #pragma config(Motor, port6, leftLift, tmotorVex393_MC29, openLoop, reversed)
9
+ #pragma config(Motor, port7, rightDrive3, tmotorVex393_MC29, openLoop)
10
+ #pragma config(Motor, port8, rightDrive2, tmotorVex393_MC29, openLoop, reversed)
11
+ #pragma config(Motor, port9, rightDrive1, tmotorVex393_MC29, openLoop, reversed)
12
+ #pragma config(Motor, port10, mongoRight, tmotorVex393_HBridge, openLoop)
9
13
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
10
14
11
15
/*---------------------------------------------------------------------------*/
@@ -55,6 +59,70 @@ void pre_auton()
55
59
/*---------------------------------------------------------------------------*/
56
60
57
61
// Declaring functions for auton
62
+ void moveForward ()
63
+ {
64
+ motor [leftDrive1 ] = 127 ;
65
+ motor [leftDrive2 ] = 127 ;
66
+ motor [leftDrive3 ] = 127 ;
67
+ motor [rightDrive3 ] = 127 ;
68
+ motor [rightDrive2 ] = 127 ;
69
+ motor [rightDrive1 ] = 127 ;
70
+ }
71
+
72
+ // Stop all drive motors
73
+ void stopDrive ()
74
+ {
75
+ motor [leftDrive1 ] = 0 ;
76
+ motor [leftDrive2 ] = 0 ;
77
+ motor [leftDrive3 ] = 0 ;
78
+ motor [rightDrive3 ] = 0 ;
79
+ motor [rightDrive2 ] = 0 ;
80
+ motor [rightDrive1 ] = 0 ;
81
+ }
82
+
83
+ void rotateLeft ()
84
+ {
85
+ motor [leftDrive1 ] = -127 ;
86
+ motor [leftDrive2 ] = -127 ;
87
+ motor [leftDrive3 ] = -127 ;
88
+ motor [rightDrive3 ] = 127 ;
89
+ motor [rightDrive2 ] = 127 ;
90
+ motor [rightDrive1 ] = 127 ;
91
+ }
92
+
93
+ void rotateRight ()
94
+ {
95
+ motor [leftDrive1 ] = 127 ;
96
+ motor [leftDrive2 ] = 127 ;
97
+ motor [leftDrive3 ] = 127 ;
98
+ motor [rightDrive3 ] = -127 ;
99
+ motor [rightDrive2 ] = -127 ;
100
+ motor [rightDrive1 ] = -127 ;
101
+ }
102
+
103
+ void moveBackward ()
104
+ {
105
+ motor [leftDrive1 ] = -127 ;
106
+ motor [leftDrive2 ] = -127 ;
107
+ motor [leftDrive3 ] = -127 ;
108
+ motor [rightDrive3 ] = -127 ;
109
+ motor [rightDrive2 ] = -127 ;
110
+ motor [rightDrive1 ] = -127 ;
111
+ }
112
+
113
+ void mongoUp ()
114
+ {
115
+ motor [mongoRight ] = 127 ;
116
+ motor [mongoLeft ] = 127 ;
117
+ }
118
+
119
+ void mongoDown ()
120
+ {
121
+ motor [mongoRight ] = -127 ;
122
+ motor [mongoLeft ] = -127 ;
123
+ }
124
+
125
+
58
126
void blueFlagSide ()
59
127
{
60
128
@@ -77,6 +145,9 @@ void redFarSide()
77
145
78
146
task autonomous ()
79
147
{
148
+ //flag
149
+ moveBackward ();
150
+ wait1Msec (1750 );
80
151
// Chooses which auton to run based on where jumper clips are placed
81
152
if (vexRT [dgtl5 ] != vexRT [dgtl6 ] == 1 )
82
153
{
@@ -129,24 +200,67 @@ task usercontrol()
129
200
motor [leftDrive2 ] = vexRT [Ch3 ];
130
201
motor [leftDrive3 ] = vexRT [Ch3 ];
131
202
132
- // PID Parking Brake
203
+ // Six bar controls
204
+ if (vexRT [Btn6U ] == 1 )
205
+ {
206
+ motor [rightLift ] = 127 ;
207
+ motor [leftLift ] = 127 ;
208
+ }
209
+ else if (vexRT [Btn6D ] == 1 )
210
+ {
211
+ motor [rightLift ] = -127 ;
212
+ motor [leftLift ] = -127 ;
213
+ }
214
+ else
215
+ {
216
+ motor [rightLift ] = 0 ;
217
+ motor [leftLift ] = 0 ;
218
+ }
219
+
220
+ // Four bar controls
221
+ if (vexRT [Btn5U ] == 1 )
222
+ {
223
+ motor [mongoRight ] = 127 ;
224
+ motor [mongoLeft ] = 127 ;
225
+ }
226
+ else if (vexRT [Btn5D ] == 1 )
227
+ {
228
+ motor [mongoRight ] = -127 ;
229
+ motor [mongoLeft ] = -127 ;
230
+ }
231
+ else
232
+ {
233
+ motor [mongoRight ] = 0 ;
234
+ motor [mongoLeft ] = 0 ;
235
+ }
133
236
237
+ // PID Parking Brake
134
238
if (vexRT [Btn8D ] == 1 )
135
239
{
136
240
brakes = !brakes ;
137
241
}
138
242
139
243
while (brakes == true)
140
244
{
245
+ // PID Parking Brake
246
+ if (vexRT [Btn8D ] == 1 )
247
+ {
248
+ brakes = !brakes ;
249
+ }
250
+
141
251
// Right side
142
252
errorR = targetSpeedR - SensorValue [rightDrive ]; // Currently just P, we can add on in the future
143
253
drivePowerR += (int )(KpR * errorR );
144
254
//
145
255
// Limit the drive power range to 0
146
256
//
147
- if (drivePowerR > 0 )
257
+ if (SensorValue [ rightDrive ] < drivePowerR )
148
258
{
149
- drivePowerR = 0 ;
259
+ while (SensorValue [rightDrive ] < drivePowerR )
260
+ {
261
+ moveForward ();
262
+ }
263
+ stopDrive ();
150
264
}
151
265
else if (drivePowerR < 0 )
152
266
{
0 commit comments