forked from AlexMaxseiner/FTC-Team4592-2012
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemCheck.c
107 lines (107 loc) · 3.17 KB
/
systemCheck.c
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
#pragma config(Hubs, S3, HTMotor, HTMotor, HTServo, HTMotor)
#pragma config(Sensor, S1, irSeek, sensorHiTechnicIRSeeker1200)
#pragma config(Sensor, S2, light, sensorLightActive)
#pragma config(Sensor, S3, , sensorI2CMuxController)
#pragma config(Sensor, S4, liftSafetyTouch, sensorTouch)
#pragma config(Motor, mtr_S3_C1_1, leftDrive, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S3_C1_2, rightDrive, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S3_C2_1, lift, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S3_C2_2, slide, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S3_C4_1, greenlight, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S3_C4_2, redlight, tmotorTetrix, openLoop)
#pragma config(Servo, srvo_S3_C3_1, claw, tServoStandard)
#pragma config(Servo, srvo_S3_C3_2, LeftBooster, tServoStandard)
#pragma config(Servo, srvo_S3_C3_3, RightBooster, tServoStandard)
#pragma config(Servo, srvo_S3_C3_4, ClawRelease, tServoNone)
#pragma config(Servo, srvo_S3_C3_5, leftgrab, tServoNone)
#pragma config(Servo, srvo_S3_C3_6, rightgrab, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
#include "globalVariables.h"
#include "globalFunctions.c"
bool goingToTarget = false;
int targetLiftPos = 0;
const int liftUpPower = 80;
const int liftDownPower = 80;
task btnLiftControl();
task main()
{
nMotorEncoder[lift] = 0;
/* Testing order
*1. batteryTest
*2. Lift up
*3. Claw Close
*4. Claw Open
*5. Lift Down
*6. leftDrive forward
*7. rightDrive forward
*8. leftDrive backward
*9. rightDrive backward
*10. both sides stop
*11. autonomous claw left and right move
*/
batteryTest();
wait10Msec(200);
targetLiftPos = 4;
StartTask(btnLiftControl);
while(goingToTarget)
{}
StopTask(btnLiftControl);
motor[lift] = 0;
wait1Msec(2000);
//claw open - claw close
servo[claw] = 200;
wait1Msec(1000);
servo[claw] = 255;
wait1Msec(1000);
servo[claw] = 200;
wait1Msec(2000);
while(nMotorEncoder[lift] > 0)
{
liftAssignSafety(-80);
}
wait1Msec(30000);
/*
motor[leftDrive] = 100;
motor[rightDrive] = 100;
wait1Msec(5000);
motor[leftDrive] = -100;
motor[rightDrive] = -100;
wait1Msec(5000);
motor[leftDrive] = 0;
motor[rightDrive] = 0;
wait1Msec(2000);
servo[leftgrab] = 150;
servo[rightgrab] = 150;
wait10Msec(200);*/
}
task btnLiftControl() {
int pos = targetLiftPos;
const int TOLERANCE = 100;
goingToTarget = true;
int targetPosition;
switch (pos)
{
case 1:
targetPosition = 50;
break;
case 2:
targetPosition = 175;
break;
case 3:
targetPosition = 2200;
break;
case 4:
targetPosition = 7600;
break;
}
while(abs(nMotorEncoder[lift] - targetPosition) > TOLERANCE)
{
if(nMotorEncoder[lift] > targetPosition)
liftAssignSafety(-1*liftDownPower);
else
liftAssignSafety(liftUpPower);
}
liftAssignSafety(0);
goingToTarget = false;
}