Commit 67f1d3d7 authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

adapted to new math grammar, missing brackets in grammar seem to cause issues

parent c9bdbd58
...@@ -26,9 +26,9 @@ component SteeringAngleCalculator{ ...@@ -26,9 +26,9 @@ component SteeringAngleCalculator{
//calculate base steering angle //calculate base steering angle
Q globalOrientation = orientation*(M_PI/180); Q globalOrientation = orientation*(M_PI/180);
if (globalOrientation > M_PI) { if (globalOrientation > M_PI)
globalOrientation -= 2 * M_PI; globalOrientation -= 2 * M_PI;
}
end end
Q orientedDistance = distance; Q orientedDistance = distance;
...@@ -41,11 +41,11 @@ component SteeringAngleCalculator{ ...@@ -41,11 +41,11 @@ component SteeringAngleCalculator{
Q cosineAngle = v2 / sqrt(v1 * v1 + v2 * v2); Q cosineAngle = v2 / sqrt(v1 * v1 + v2 * v2);
Q angle = acos(cosineAngle); Q angle = acos(cosineAngle);
if (v1 > 0) { if (v1 > 0)
orientationOfTrajectory = -angle; orientationOfTrajectory = -angle;
} else { else
orientationOfTrajectory = angle; orientationOfTrajectory = angle;
}
end end
Q angleTrajectoryAndCarDirection = orientationOfTrajectory - globalOrientation; Q angleTrajectoryAndCarDirection = orientationOfTrajectory - globalOrientation;
...@@ -54,23 +54,21 @@ component SteeringAngleCalculator{ ...@@ -54,23 +54,21 @@ component SteeringAngleCalculator{
Q finalAngle = angleTrajectoryAndCarDirection + angleTowardsTrajectory; Q finalAngle = angleTrajectoryAndCarDirection + angleTowardsTrajectory;
//correct angle //correct angle
if (finalAngle > M_PI){ if (finalAngle > M_PI)
finalAngle -= 2 * M_PI; finalAngle -= 2 * M_PI;
}elseif (finalAngle < -M_PI){ elseif (finalAngle < -M_PI)
finalAngle += 2 * M_PI; finalAngle += 2 * M_PI;
}
end end
newSteeringAngle = finalAngle*(180/M_PI); newSteeringAngle = finalAngle*(180/M_PI);
//correct angle depending on car //correct angle depending on car
angle = newSteeringAngle; angle = newSteeringAngle;
if angle < minSteeringAngle{ if angle < minSteeringAngle
angle = minSteeringAngle; angle = minSteeringAngle;
} elseif angle > maxSteeringAngle
elseif angle > maxSteeringAngle{
angle = maxSteeringAngle; angle = maxSteeringAngle;
}
end end
newSteeringAngle = -angle; newSteeringAngle = -angle;
} }
......
...@@ -5,15 +5,15 @@ component BasicPortsMath{ ...@@ -5,15 +5,15 @@ component BasicPortsMath{
out (0:1:100) result; out (0:1:100) result;
implementation Math{ implementation Math{
if counter < 0{ if counter < 0
result = 0; result = 0;
}
elseif counter < 100{ elseif counter < 100
result = counter; result = counter;
}
else{ else
result = 100; result = 100;
}
end end
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment