diff --git a/README.md b/README.md new file mode 100644 index 0000000..69eb328 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# ROBOSOUTĚŽ 2023 diff --git a/app b/app index 6aae6a0..c4f3e08 100644 Binary files a/app and b/app differ diff --git a/app.cpp b/app.cpp index e861c2c..5cbd715 100644 --- a/app.cpp +++ b/app.cpp @@ -3,6 +3,7 @@ #include #include #include +#include /* Change notes: @@ -104,7 +105,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens { const int LEFT_THRESHOLD = -3; const int RIGHT_THRESHOLD = 3; - const int CORRECTION_MULTIPLIER = 3; + const int CORRECTION_MULTIPLIER = 2; const int CYCLE_LIMIT = 0;//75; gyro.resetHard(); @@ -151,7 +152,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens if (angle > LEFT_THRESHOLD) { //ev3_speaker_play_tone(NOTE_A5, 250); int correction = angle - LEFT_THRESHOLD; - motor_powers.lMotorPWR += correction * CORRECTION_MULTIPLIER; + motor_powers.lMotorPWR += (int)pow(CORRECTION_MULTIPLIER, correction); ev3_speaker_play_tone(correction*1000,50); // Check if the motor is stuck if(lPower == 0){ @@ -166,7 +167,11 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens // If 5 problems occured than try to fix the problem if(lCounter == 6){ ev3_speaker_play_tone(NOTE_C4, 250); - ev3cxx::setColor(RED); + ev3cxx::statusLight.setColor(ev3cxx::StatusLightColor::RED); + motors.on(-motor_powers.rMotorPWR, -motor_powers.lMotorPWR); + tslp_tsk(250); + motors.off(); + lCounter = 0; } // Reset counter } else { @@ -179,7 +184,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens } else if (angle < RIGHT_THRESHOLD) { //ev3_speaker_play_tone(NOTE_A4, 250); int correction = angle - RIGHT_THRESHOLD; - motor_powers.rMotorPWR += correction * CORRECTION_MULTIPLIER; + motor_powers.rMotorPWR += (int)pow(CORRECTION_MULTIPLIER, correction);//correction * CORRECTION_MULTIPLIER; ev3_speaker_play_tone(correction*1000,50); // Check if the motor is stuck if(rPower == 0){ @@ -194,7 +199,11 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens // If 5 problems occured than try to fix the problem if(rCounter == 6){ ev3_speaker_play_tone(NOTE_C5, 250); - ev3cxx::setColor(ORANGE); + ev3cxx::statusLight.setColor(ev3cxx::StatusLightColor::ORANGE); + motors.on(-motor_powers.rMotorPWR, -motor_powers.lMotorPWR); + tslp_tsk(250); + motors.off(); + rCounter = 0; } // Reset counter } else { @@ -248,7 +257,7 @@ void main_task(intptr_t unused) // Set up motor powers MPWRS idealMPWRS; - idealMPWRS.lMotorPWR = 87; + idealMPWRS.lMotorPWR = 85; idealMPWRS.rMotorPWR = 50; MPWRS motor_powers;