Skip to content
This repository was archived by the owner on Aug 19, 2019. It is now read-only.

Commit f1379a0

Browse files
committed
skills and bug fixes
skills auton added and driver controls fixed
1 parent a1d2411 commit f1379a0

File tree

2 files changed

+412
-9
lines changed

2 files changed

+412
-9
lines changed

72832B - Push Bot.c

+123-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
#pragma config(Sensor, dgtl1, rightDrive, sensorQuadEncoder)
22
#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)
913
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
1014

1115
/*---------------------------------------------------------------------------*/
@@ -55,6 +59,70 @@ void pre_auton()
5559
/*---------------------------------------------------------------------------*/
5660

5761
// 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+
58126
void blueFlagSide()
59127
{
60128

@@ -77,6 +145,9 @@ void redFarSide()
77145

78146
task autonomous()
79147
{
148+
//flag
149+
moveBackward();
150+
wait1Msec(1750);
80151
// Chooses which auton to run based on where jumper clips are placed
81152
if (vexRT[dgtl5] != vexRT[dgtl6] == 1)
82153
{
@@ -129,24 +200,67 @@ task usercontrol()
129200
motor[leftDrive2] = vexRT[Ch3];
130201
motor[leftDrive3] = vexRT[Ch3];
131202

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+
}
133236

237+
// PID Parking Brake
134238
if (vexRT[Btn8D] == 1)
135239
{
136240
brakes = !brakes;
137241
}
138242

139243
while (brakes == true)
140244
{
245+
// PID Parking Brake
246+
if (vexRT[Btn8D] == 1)
247+
{
248+
brakes = !brakes;
249+
}
250+
141251
// Right side
142252
errorR = targetSpeedR - SensorValue[rightDrive]; // Currently just P, we can add on in the future
143253
drivePowerR += (int)(KpR*errorR);
144254
//
145255
// Limit the drive power range to 0
146256
//
147-
if (drivePowerR > 0)
257+
if (SensorValue[rightDrive] < drivePowerR)
148258
{
149-
drivePowerR = 0;
259+
while (SensorValue[rightDrive] < drivePowerR)
260+
{
261+
moveForward();
262+
}
263+
stopDrive();
150264
}
151265
else if (drivePowerR < 0)
152266
{

0 commit comments

Comments
 (0)