-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmoeAuto.c
66 lines (62 loc) · 2.08 KB
/
moeAuto.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
#pragma config(Hubs, S1, HTMotor, HTMotor, none, none)
#pragma config(Hubs, S2, HTMotor, none, none, none)
#pragma config(Sensor, S3, GYRO, sensorI2CHiTechnicGyro)
#pragma config(Sensor, S4, HTIRS2, sensorI2CCustom)
#pragma config(Motor, motorC, autoArm, tmotorNXT, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_1, leftDrive, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C1_2, winch, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, flag, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, unused2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S2_C1_1, rightDrive, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S2_C1_2, collector, tmotorTetrix, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "drivers/hitechnic-irseeker-v2.h"
#include "lib/FTC_PID.c"
#include "lib/FTC_Gyro.c"
#include "constants.c"
#include "subsystems/Drivetrain.c"
#include "JoystickDriver.c"
void throwCube()
{
while ( nMotorEncoder[autoArm] < 150 )
{
motor[autoArm] = 100;
}
motor[autoArm] = -100;
wait1Msec(500);
motor[autoArm] = 0;
wait1Msec(200);
}
task main()
{
initGyro();
drivetrainInit();
drivetrainGyroDrivestraight = false;
bDisplayDiagnostics = false;
HTIRS2setDSPMode(HTIRS2, DSP_1200);
while (nPgmTime < 5000 )
{break;
int v1,v2,v3,v4,v5;
HTIRS2readAllACStrength(HTIRS2, v1,v2,v3,v4,v5);
nxtDisplayString(0, "%i ", gyroData.offset);
nxtDisplayString(1, "%2.4f ", getGyroAngle());
nxtDisplayString(2, "%2.4f ", gyroData.degsec);
nxtDisplayString(3, "%i ", v3);
updateGyro();
}
gyroData.deg = 0;
bDisplayDiagnostics = true;
//waitForStart();
resetDrivetrainDistance();
nMotorEncoder[autoArm] = 0;
int counter = 0;
synchronousDriveTo(-2100);
throwCube();
resetDrivetrainDistance();
synchronousDriveTo(-1000);
synchronousDriveTurn(30);
synchronousDriveTo(-2000);
synchronousDriveTurn(-90);
resetDrivetrainDistance();
synchronousDriveTo(-5000);
}