go to competition

master
Cole Deck 4 years ago
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.

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -43,8 +43,9 @@ drivetrain Drivetrain =
motor LiftMotor = motor(PORT18, ratio18_1, true);
motor LiftMotor2 = motor(PORT12, ratio18_1, false);
motor TiltMotor = motor(PORT3, ratio18_1, false);
motor TiltMotor2 = motor(PORT10, ratio18_1, true);
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);
bool Controller1LeftShoulderControlMotorsStopped = true;
@ -87,6 +88,7 @@ void pre_auton(void) {
std::ifstream ifs;
void goToPos(motor m, double vel, double pos);
void playback();
int filenum = 1;
std::string instructions;
void autonomous(void) {
// ..........................................................................
@ -111,7 +113,11 @@ void autonomous(void) {
// uint8_t * instructions = nullptr;
// Brain.SDcard.loadfile("recording.bin", instructions, 2500); // size in
// 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");
timer tim;
tim.clear();
@ -226,6 +232,7 @@ void playback() {
y = instructions.find(" ", 5);
pos = strtod(instructions.substr(0, y).c_str(), NULL);
goToPos(TiltMotor, vel, pos);
goToPos(TiltMotor2, -vel, pos);
//TiltMotor.rotateTo(pos, degrees, vel, velocityUnits::pct, false);
//wait(10, msec);
}
@ -241,9 +248,19 @@ void playback() {
std::ofstream ofs;
void usercontrol(void) {
Controller1.Screen.setCursor(4, 0);
// Controller1.Screen.clearLine();
Controller1.Screen.print(filenum);
LiftMotor.setVelocity(100, percent);
LiftMotor.stop();
LiftMotor2.setVelocity(100, percent);
LiftMotor2.stop();
TiltMotor.setVelocity(30, percent);
TiltMotor2.setVelocity(30, percent);
TiltMotor.stop();
TiltMotor2.stop();
LeftDriveSmart.stop();
RightDriveSmart.stop();
Controller1.Screen.clearScreen();
Controller1.Screen.setCursor(0, 0);
Controller1.Screen.clearLine();
@ -304,17 +321,36 @@ void usercontrol(void) {
LiftMotor.resetRotation();
LiftMotor2.resetRotation();
TiltMotor.resetRotation();
TiltMotor2.resetRotation();
IntakeL.resetRotation();
IntakeR.resetRotation();
if (Brain.SDcard.isInserted()) {
// 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();
}
if (Controller1.ButtonRight.pressing()) {
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();
if (recording) {
while (tim2.value() < 0.075) {
@ -420,6 +456,7 @@ void STOPCODE_DEBUG() {
IntakeR.stop();
IntakeL.stop();
TiltMotor.stop();
TiltMotor2.stop();
while (true)
wait(20, msec);
}
@ -521,14 +558,18 @@ void controllerBaseInput() {
Controller1.Screen.setCursor(2, 0);
// Controller1.Screen.clearLine();
Controller1.Screen.print("Fast intake");
Controller1.Screen.setCursor(4, 0);
Controller1.Screen.print(filenum);
} else {
Controller1.Screen.setCursor(2, 0);
// Controller1.Screen.clearLine();
Controller1.Screen.print("Slow intake");
Controller1.Screen.setCursor(4, 0);
Controller1.Screen.print(filenum);
IntakeSpeed /= 4;
}
if (Controller1.ButtonDown.pressing()) {
/*if (Controller1.ButtonDown.pressing()) {
drivetrainLeftSideSpeed = -20;
drivetrainRightSideSpeed = -20;
IntakeStop = true;
@ -538,10 +579,10 @@ void controllerBaseInput() {
drivetrainRightSideSpeed = 20;
IntakeStop = true;
IntakeSpeed = 20;
} else {
} else {*/
drivetrainLeftSideSpeed *= driveMultiplier;
drivetrainRightSideSpeed *= driveMultiplier;
}
//}
if (IntakeStop) {
IntakeL.setVelocity(IntakeSpeed, percent);
IntakeR.setVelocity(IntakeSpeed, percent);
@ -626,11 +667,14 @@ void controllerBaseInput() {
// check the Right Shoulder Buttons status to control TiltMotor
if (Controller1.ButtonR1.pressing()) {
TiltMotor.spin(forward);
TiltMotor2.spin(forward);
Controller1UpDownButtonsControlMotorsStopped = false;
} else if (Controller1.ButtonR2.pressing()) {
TiltMotor.spin(reverse);
TiltMotor2.spin(reverse);
Controller1UpDownButtonsControlMotorsStopped = false;
} else if (!Controller1UpDownButtonsControlMotorsStopped) {
TiltMotor.stop(hold);
TiltMotor.stop(hold);
// set the toggle so that we don't constantly tell the motor to stop when
// the buttons are released

Loading…
Cancel
Save