This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeleop.c
86 lines (77 loc) · 2.94 KB
/
Teleop.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(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo)
#pragma config(Sensor, S1, motors, sensorNone)
#pragma config(Sensor, S2, SMUX, sensorI2CCustom9V)
#pragma config(Sensor, S3, gyroSensor, sensorI2CHiTechnicGyro)
#pragma config(Sensor, S4, liftTS, sensorTouch)
#pragma config(Motor, motorA, , tmotorNXT, openLoop, encoder)
#pragma config(Motor, motorB, , tmotorNXT, openLoop, reversed, encoder)
#pragma config(Motor, motorC, , tmotorNXT, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_1, leftFrontMotor, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C1_2, leftRearMotor, tmotorTetrix, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C2_1, rightFrontMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_2, rightRearMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Motor, mtr_S1_C3_1, liftMotor, tmotorTetrix, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C3_2, spinnerMotor, tmotorTetrix, openLoop, encoder)
#pragma config(Servo, srvo_S1_C4_1, goalHook, tServoStandard)
#pragma config(Servo, srvo_S1_C4_2, hopperTilt, tServoStandard)
#pragma config(Servo, srvo_S1_C4_3, highGoal, tServoStandard)
#pragma config(Servo, srvo_S1_C4_4, unusedS3C14, tServoStandard)
#pragma config(Servo, srvo_S1_C4_5, unusedS3C15, tServoStandard)
#pragma config(Servo, srvo_S1_C4_6, unusedS3C16, tServoStandard)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma debuggerWindows("joystickGame");
#include "includes.h"
void stopAndDump(LiftState cmd) {
setLiftCmd(cmd);
hopperAutoDump();
}
task main()
{
bool incrLHeight = false, decrLHeight = false;
programPeriod = TELEOP;
initializeRobot();
waitForStart();
StartTask(DriveMec);
StartTask(Lift);
StartTask(Hopper);
servoHighDrop();
wait1Msec(500);
servoHighHold();
DriveSpinnerMotor(SPINNER_IN);
while(true)
{
getJoystickSettings(joystick);
//Goal Hook Servo
if(joy1Btn(5) || joy1Btn(7)) {
servoHookCapture();
} else if (joy1Btn(6) || joy1Btn(8)) {
servoHookRelease();
}
// Lift position control
if (joy2Btn(4)) {
stopAndDump(HIGH);
} else if(joy2Btn(7)) {
setLiftCmd(COLLECT);
} else if(joy2Btn(8)) {
setLiftCmd(DRIVE);
} else if(joy2Btn(2)) {
stopAndDump(LOW);
} else if(joy2Btn(1) || joy2Btn(3)) {
stopAndDump(MED);
}
/* Uncomment if this becomes necessary to use
// Lift height tuning
if(joystick.joy2_TopHat == 0) {
incrLHeight = true;
} else if(incrLHeight && joystick.joy2_TopHat == -1) {
incrLHeight = false;
incrLiftHeightHigh();
} else if(joystick.joy2_TopHat == 4) {
decrLHeight = true;
} else if(decrLHeight && joystick.joy2_TopHat == -1) {
decrLHeight = false;
decrLiftHeightHigh();
}
*/
}
}