Denk proof backup #2

This commit is contained in:
Blboun3 2023-11-10 10:07:39 +01:00
parent 9b52e0a9dc
commit 42af19d4ce
3 changed files with 16 additions and 6 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# ROBOSOUTĚŽ 2023

BIN
app

Binary file not shown.

21
app.cpp
View File

@ -3,6 +3,7 @@
#include <ctime> #include <ctime>
#include <functional> #include <functional>
#include <sstream> #include <sstream>
#include <math.h>
/* /*
Change notes: Change notes:
@ -104,7 +105,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
{ {
const int LEFT_THRESHOLD = -3; const int LEFT_THRESHOLD = -3;
const int RIGHT_THRESHOLD = 3; const int RIGHT_THRESHOLD = 3;
const int CORRECTION_MULTIPLIER = 3; const int CORRECTION_MULTIPLIER = 2;
const int CYCLE_LIMIT = 0;//75; const int CYCLE_LIMIT = 0;//75;
gyro.resetHard(); gyro.resetHard();
@ -151,7 +152,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
if (angle > LEFT_THRESHOLD) { if (angle > LEFT_THRESHOLD) {
//ev3_speaker_play_tone(NOTE_A5, 250); //ev3_speaker_play_tone(NOTE_A5, 250);
int correction = angle - LEFT_THRESHOLD; 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); ev3_speaker_play_tone(correction*1000,50);
// Check if the motor is stuck // Check if the motor is stuck
if(lPower == 0){ 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 5 problems occured than try to fix the problem
if(lCounter == 6){ if(lCounter == 6){
ev3_speaker_play_tone(NOTE_C4, 250); 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 // Reset counter
} else { } else {
@ -179,7 +184,7 @@ bool run_short_side(ev3cxx::MotorTank motors, MPWRS idealMPWRS, ev3cxx::GyroSens
} else if (angle < RIGHT_THRESHOLD) { } else if (angle < RIGHT_THRESHOLD) {
//ev3_speaker_play_tone(NOTE_A4, 250); //ev3_speaker_play_tone(NOTE_A4, 250);
int correction = angle - RIGHT_THRESHOLD; 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); ev3_speaker_play_tone(correction*1000,50);
// Check if the motor is stuck // Check if the motor is stuck
if(rPower == 0){ 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 5 problems occured than try to fix the problem
if(rCounter == 6){ if(rCounter == 6){
ev3_speaker_play_tone(NOTE_C5, 250); 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 // Reset counter
} else { } else {
@ -248,7 +257,7 @@ void main_task(intptr_t unused)
// Set up motor powers // Set up motor powers
MPWRS idealMPWRS; MPWRS idealMPWRS;
idealMPWRS.lMotorPWR = 87; idealMPWRS.lMotorPWR = 85;
idealMPWRS.rMotorPWR = 50; idealMPWRS.rMotorPWR = 50;
MPWRS motor_powers; MPWRS motor_powers;