This repository has been archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
1900A X-Drive Test.c
86 lines (74 loc) · 2.95 KB
/
1900A X-Drive Test.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
#pragma config(Motor, port1, , tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port2, , tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, , tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, , tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port7, , tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port9, , tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port10, , tmotorVex393TurboSpeed_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*------------------------------------------------------
Motor Pin Diagram:
2. LI - left intake motor
3. RI - right intake motor
4. FL - front left motor
5. FR - front right motor
6. BR - back right motor
7. BL - back left motor
8. LFB - left four-bar motor
9. RFB - right four-bar motor
Motion / Mechanics Notes
Entire left side is reversed so that robot can go forward
List (FL Speed, BL speed, BR speed, FR) - remember FL and BL are reversed
Forward: 127, 127, 127, 127 - both joysticks forward
Backwards: -127, -127, -127, -127 - both joysticks backwards
Strafe Left: -127, 127, 127, -127 - both joysticks left
Strafe Right: 127, -127, -127, 127 - both joysticks right
Rotate Left: -127, -127, 127, 127 - left joystick down right joystick up
Rotate Right: 127, 127, -127,-127 - left joystick up right joystick down
------------------------------------------------------*/
int threshold = 15; //minimum joystick value
int intakeStatusValue = 1; //used to keep track of status of intake (on/off)
bool intakeStatus = false; //current status is false(off)
int armSpeed = 127;
task main()
{
//Assign some starter values to the four movement integers
int LY = 0;
int LX = 0;
int RY = 0;
int RX = 0;
while(true )
{
/*
Ternary Statement: value = (true boolean) ? (false boolean) : value
If the absolute value of one of these vexRT Channels is greater than the threshold, assign the value
If it is NOT greater than threshold, make it 0
*/
LX = (abs(vexRT[Ch4]) > threshold) ? vexRT[Ch4] : 0;
LY = (abs(vexRT[Ch3]) > threshold) ? vexRT[Ch3] : 0;
RY = (abs(vexRT[Ch2]) > threshold) ? vexRT[Ch2] : 0;
RX = (abs(vexRT[Ch1]) > threshold) ? vexRT[Ch1] : 0;
motor[FL] = LY + LX;
motor[FR] = RY - RX;
motor[BR] = RY + RX;
motor[BL] = LY - LX;
if(vexRT[Btn6U] == 1 && vexRT[Btn6D] == 0){
motor[rightArm] = armSpeed;
}
else if (vexRT[Btn6D] == 1 && vexRT[Btn6U] == 0){
motor[rightArm] = -armSpeed;
}
else if (vexRT[Btn6D]== 0 && vexRT[Btn6U] == 0){
motor[rightArm] = 0;
}
if(vexRT[Btn5U] == 1 && vexRT[Btn5D] == 0){
motor[rightArmHook] = 127;
}
else if (vexRT[Btn5U] == 0 && vexRT[Btn5D] == 1){
motor[rightArmHook] = -127;
}
else if (vexRT[Btn5U] == 0 && vexRT[Btn5D] == 0){
motor[rightArmHook] = 0;
}
}
}