go to competition
This commit is contained in:
parent
326a85abd8
commit
a01ad16f28
@ -1 +1 @@
|
|||||||
{"title":"38535A-4","description":"Empty V5 C++ Project","icon":"USER921x.bmp","version":"19.10.1015","sdk":"20200203_11_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":2,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":true,"isVexFileImport":false,"robotconfig":[],"neverUpdate":null}
|
{"title":"38535A-4","description":"Empty V5 C++ Project","icon":"USER921x.bmp","version":"19.10.1015","sdk":"20200203_11_00_00","language":"cpp","competition":false,"files":[{"name":"include/robot-config.h","type":"File","specialType":"device_config"},{"name":"include/vex.h","type":"File","specialType":""},{"name":"makefile","type":"File","specialType":""},{"name":"src/main.cpp","type":"File","specialType":""},{"name":"src/robot-config.cpp","type":"File","specialType":"device_config"},{"name":"vex/mkenv.mk","type":"File","specialType":""},{"name":"vex/mkrules.mk","type":"File","specialType":""},{"name":"include","type":"Directory"},{"name":"src","type":"Directory"},{"name":"vex","type":"Directory"}],"device":{"slot":3,"uid":"276-4810","options":{}},"isExpertMode":true,"isExpertModeRC":true,"isVexFileImport":false,"robotconfig":[],"neverUpdate":null}
|
Binary file not shown.
Binary file not shown.
1515
build/38535A4.map
1515
build/38535A4.map
File diff suppressed because it is too large
Load Diff
BIN
build/src/main.o
BIN
build/src/main.o
Binary file not shown.
56
src/main.cpp
56
src/main.cpp
@ -43,8 +43,9 @@ drivetrain Drivetrain =
|
|||||||
motor LiftMotor = motor(PORT18, ratio18_1, true);
|
motor LiftMotor = motor(PORT18, ratio18_1, true);
|
||||||
motor LiftMotor2 = motor(PORT12, ratio18_1, false);
|
motor LiftMotor2 = motor(PORT12, ratio18_1, false);
|
||||||
motor TiltMotor = motor(PORT3, ratio18_1, false);
|
motor TiltMotor = motor(PORT3, ratio18_1, false);
|
||||||
|
motor TiltMotor2 = motor(PORT10, ratio18_1, true);
|
||||||
controller Controller1 = controller(primary);
|
controller Controller1 = controller(primary);
|
||||||
motor IntakeR = motor(PORT17, ratio18_1, false);
|
motor IntakeR = motor(PORT15, ratio18_1, false);
|
||||||
motor IntakeL = motor(PORT8, ratio18_1, true);
|
motor IntakeL = motor(PORT8, ratio18_1, true);
|
||||||
|
|
||||||
bool Controller1LeftShoulderControlMotorsStopped = true;
|
bool Controller1LeftShoulderControlMotorsStopped = true;
|
||||||
@ -87,6 +88,7 @@ void pre_auton(void) {
|
|||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
void goToPos(motor m, double vel, double pos);
|
void goToPos(motor m, double vel, double pos);
|
||||||
void playback();
|
void playback();
|
||||||
|
int filenum = 1;
|
||||||
std::string instructions;
|
std::string instructions;
|
||||||
void autonomous(void) {
|
void autonomous(void) {
|
||||||
// ..........................................................................
|
// ..........................................................................
|
||||||
@ -111,7 +113,11 @@ void autonomous(void) {
|
|||||||
// uint8_t * instructions = nullptr;
|
// uint8_t * instructions = nullptr;
|
||||||
// Brain.SDcard.loadfile("recording.bin", instructions, 2500); // size in
|
// Brain.SDcard.loadfile("recording.bin", instructions, 2500); // size in
|
||||||
// bytes
|
// bytes
|
||||||
ifs.open("recording.txt", std::ofstream::in);
|
char filename[1] = "";
|
||||||
|
snprintf(filename, 2, "%d", filenum);
|
||||||
|
std::string fn = filename;
|
||||||
|
fn += ".txt";
|
||||||
|
ifs.open(fn, std::ofstream::in);
|
||||||
Controller1.Screen.print("File opened");
|
Controller1.Screen.print("File opened");
|
||||||
timer tim;
|
timer tim;
|
||||||
tim.clear();
|
tim.clear();
|
||||||
@ -226,6 +232,7 @@ void playback() {
|
|||||||
y = instructions.find(" ", 5);
|
y = instructions.find(" ", 5);
|
||||||
pos = strtod(instructions.substr(0, y).c_str(), NULL);
|
pos = strtod(instructions.substr(0, y).c_str(), NULL);
|
||||||
goToPos(TiltMotor, vel, pos);
|
goToPos(TiltMotor, vel, pos);
|
||||||
|
goToPos(TiltMotor2, -vel, pos);
|
||||||
//TiltMotor.rotateTo(pos, degrees, vel, velocityUnits::pct, false);
|
//TiltMotor.rotateTo(pos, degrees, vel, velocityUnits::pct, false);
|
||||||
//wait(10, msec);
|
//wait(10, msec);
|
||||||
}
|
}
|
||||||
@ -241,9 +248,19 @@ void playback() {
|
|||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
|
|
||||||
void usercontrol(void) {
|
void usercontrol(void) {
|
||||||
|
Controller1.Screen.setCursor(4, 0);
|
||||||
|
// Controller1.Screen.clearLine();
|
||||||
|
Controller1.Screen.print(filenum);
|
||||||
LiftMotor.setVelocity(100, percent);
|
LiftMotor.setVelocity(100, percent);
|
||||||
|
LiftMotor.stop();
|
||||||
LiftMotor2.setVelocity(100, percent);
|
LiftMotor2.setVelocity(100, percent);
|
||||||
|
LiftMotor2.stop();
|
||||||
TiltMotor.setVelocity(30, percent);
|
TiltMotor.setVelocity(30, percent);
|
||||||
|
TiltMotor2.setVelocity(30, percent);
|
||||||
|
TiltMotor.stop();
|
||||||
|
TiltMotor2.stop();
|
||||||
|
LeftDriveSmart.stop();
|
||||||
|
RightDriveSmart.stop();
|
||||||
Controller1.Screen.clearScreen();
|
Controller1.Screen.clearScreen();
|
||||||
Controller1.Screen.setCursor(0, 0);
|
Controller1.Screen.setCursor(0, 0);
|
||||||
Controller1.Screen.clearLine();
|
Controller1.Screen.clearLine();
|
||||||
@ -304,17 +321,36 @@ void usercontrol(void) {
|
|||||||
LiftMotor.resetRotation();
|
LiftMotor.resetRotation();
|
||||||
LiftMotor2.resetRotation();
|
LiftMotor2.resetRotation();
|
||||||
TiltMotor.resetRotation();
|
TiltMotor.resetRotation();
|
||||||
|
TiltMotor2.resetRotation();
|
||||||
IntakeL.resetRotation();
|
IntakeL.resetRotation();
|
||||||
IntakeR.resetRotation();
|
IntakeR.resetRotation();
|
||||||
if (Brain.SDcard.isInserted()) {
|
if (Brain.SDcard.isInserted()) {
|
||||||
// create a file with long filename
|
// create a file with long filename
|
||||||
ofs.open("recording.txt", std::ofstream::out);
|
char filename[1] = "";
|
||||||
|
snprintf(filename, 2, "%d", filenum);
|
||||||
|
std::string fn = filename;
|
||||||
|
fn += ".txt";
|
||||||
|
ofs.open(fn, std::ofstream::out);
|
||||||
}
|
}
|
||||||
tim2.clear();
|
tim2.clear();
|
||||||
}
|
}
|
||||||
if (Controller1.ButtonRight.pressing()) {
|
if (Controller1.ButtonRight.pressing()) {
|
||||||
donerecording = true;
|
donerecording = true;
|
||||||
}
|
}
|
||||||
|
if (Controller1.ButtonUp.pressing()) {
|
||||||
|
filenum ++;
|
||||||
|
Controller1.Screen.setCursor(4, 0);
|
||||||
|
// Controller1.Screen.clearLine();
|
||||||
|
Controller1.Screen.print(filenum);
|
||||||
|
wait(250, msec);
|
||||||
|
}
|
||||||
|
if (Controller1.ButtonDown.pressing()) {
|
||||||
|
filenum --;
|
||||||
|
Controller1.Screen.setCursor(4, 0);
|
||||||
|
// Controller1.Screen.clearLine();
|
||||||
|
Controller1.Screen.print(filenum);
|
||||||
|
wait(250, msec);
|
||||||
|
}
|
||||||
controllerBaseInput();
|
controllerBaseInput();
|
||||||
if (recording) {
|
if (recording) {
|
||||||
while (tim2.value() < 0.075) {
|
while (tim2.value() < 0.075) {
|
||||||
@ -420,6 +456,7 @@ void STOPCODE_DEBUG() {
|
|||||||
IntakeR.stop();
|
IntakeR.stop();
|
||||||
IntakeL.stop();
|
IntakeL.stop();
|
||||||
TiltMotor.stop();
|
TiltMotor.stop();
|
||||||
|
TiltMotor2.stop();
|
||||||
while (true)
|
while (true)
|
||||||
wait(20, msec);
|
wait(20, msec);
|
||||||
}
|
}
|
||||||
@ -521,14 +558,18 @@ void controllerBaseInput() {
|
|||||||
Controller1.Screen.setCursor(2, 0);
|
Controller1.Screen.setCursor(2, 0);
|
||||||
// Controller1.Screen.clearLine();
|
// Controller1.Screen.clearLine();
|
||||||
Controller1.Screen.print("Fast intake");
|
Controller1.Screen.print("Fast intake");
|
||||||
|
Controller1.Screen.setCursor(4, 0);
|
||||||
|
Controller1.Screen.print(filenum);
|
||||||
} else {
|
} else {
|
||||||
Controller1.Screen.setCursor(2, 0);
|
Controller1.Screen.setCursor(2, 0);
|
||||||
// Controller1.Screen.clearLine();
|
// Controller1.Screen.clearLine();
|
||||||
Controller1.Screen.print("Slow intake");
|
Controller1.Screen.print("Slow intake");
|
||||||
|
Controller1.Screen.setCursor(4, 0);
|
||||||
|
Controller1.Screen.print(filenum);
|
||||||
IntakeSpeed /= 4;
|
IntakeSpeed /= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Controller1.ButtonDown.pressing()) {
|
/*if (Controller1.ButtonDown.pressing()) {
|
||||||
drivetrainLeftSideSpeed = -20;
|
drivetrainLeftSideSpeed = -20;
|
||||||
drivetrainRightSideSpeed = -20;
|
drivetrainRightSideSpeed = -20;
|
||||||
IntakeStop = true;
|
IntakeStop = true;
|
||||||
@ -538,10 +579,10 @@ void controllerBaseInput() {
|
|||||||
drivetrainRightSideSpeed = 20;
|
drivetrainRightSideSpeed = 20;
|
||||||
IntakeStop = true;
|
IntakeStop = true;
|
||||||
IntakeSpeed = 20;
|
IntakeSpeed = 20;
|
||||||
} else {
|
} else {*/
|
||||||
drivetrainLeftSideSpeed *= driveMultiplier;
|
drivetrainLeftSideSpeed *= driveMultiplier;
|
||||||
drivetrainRightSideSpeed *= driveMultiplier;
|
drivetrainRightSideSpeed *= driveMultiplier;
|
||||||
}
|
//}
|
||||||
if (IntakeStop) {
|
if (IntakeStop) {
|
||||||
IntakeL.setVelocity(IntakeSpeed, percent);
|
IntakeL.setVelocity(IntakeSpeed, percent);
|
||||||
IntakeR.setVelocity(IntakeSpeed, percent);
|
IntakeR.setVelocity(IntakeSpeed, percent);
|
||||||
@ -626,11 +667,14 @@ void controllerBaseInput() {
|
|||||||
// check the Right Shoulder Buttons status to control TiltMotor
|
// check the Right Shoulder Buttons status to control TiltMotor
|
||||||
if (Controller1.ButtonR1.pressing()) {
|
if (Controller1.ButtonR1.pressing()) {
|
||||||
TiltMotor.spin(forward);
|
TiltMotor.spin(forward);
|
||||||
|
TiltMotor2.spin(forward);
|
||||||
Controller1UpDownButtonsControlMotorsStopped = false;
|
Controller1UpDownButtonsControlMotorsStopped = false;
|
||||||
} else if (Controller1.ButtonR2.pressing()) {
|
} else if (Controller1.ButtonR2.pressing()) {
|
||||||
TiltMotor.spin(reverse);
|
TiltMotor.spin(reverse);
|
||||||
|
TiltMotor2.spin(reverse);
|
||||||
Controller1UpDownButtonsControlMotorsStopped = false;
|
Controller1UpDownButtonsControlMotorsStopped = false;
|
||||||
} else if (!Controller1UpDownButtonsControlMotorsStopped) {
|
} else if (!Controller1UpDownButtonsControlMotorsStopped) {
|
||||||
|
TiltMotor.stop(hold);
|
||||||
TiltMotor.stop(hold);
|
TiltMotor.stop(hold);
|
||||||
// set the toggle so that we don't constantly tell the motor to stop when
|
// set the toggle so that we don't constantly tell the motor to stop when
|
||||||
// the buttons are released
|
// the buttons are released
|
||||||
|
Loading…
x
Reference in New Issue
Block a user