|
|
@@ -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; |
|
|
|
} |