-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsmokeAuto.c
72 lines (66 loc) · 2.16 KB
/
smokeAuto.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
#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(900);
throwCube();
resetDrivetrainDistance();
synchronousDriveTo(1000);
synchronousDriveTurn(-10);
resetDrivetrainDistance();
synchronousDriveTo(2000);
synchronousDriveTurn(-90);
resetDrivetrainDistance();
setDrivetrainSpeeds(-100, -100);
wait1Msec(1500);
setDrivetrainSpeeds(0, 0);
}