Browse Source

Bugs found during tests

master
Tim Zeuner 1 year ago
parent
commit
6da9bfff54
1 changed files with 13 additions and 5 deletions
  1. 13
    5
      AutonomousMode/ControlModule/control_module.cpp

+ 13
- 5
AutonomousMode/ControlModule/control_module.cpp View File

@@ -36,7 +36,7 @@ void ControlModule::adjustSpeed(){

for(int i = 0; i < 4; i++)
{
motors[i] *= maxSpeed;
motors[i] *= factor;
}
};

@@ -85,7 +85,7 @@ void ControlModule::calcSpeeds(int imageColumsMiddle, int contourColumsMiddle, d
std::unique_lock<std::mutex> lock(mtx);
double rotationRatio = ratio(angle);
rotate(rotationRatio);
drive(1.0-rotationRatio);
drive(1.0-std::fabs(rotationRatio));
unit();
adjustSpeed();
}
@@ -102,13 +102,21 @@ double ControlModule::ratio(double angle)
double maxAngularSpeed = 1.0;
double speedRange = maxAngularSpeed - minAngularSpeed;

double minAngle = -90.0;
double maxAngle = 90.0;
double minAngle = -20.0;
double maxAngle = 20.0;
double angularRange = maxAngle - minAngle;

if(angle < minAngle)
{
angle = minAngle;
}
if(angle > maxAngle)
{
angle = maxAngle;
}
double progress = angle - minAngle;
double progressPercent = progress/angularRange;

double speed = minAngularSpeed + progressPercent*speedRange;
return std::fabs(speed);
return speed;
}

Loading…
Cancel
Save