You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug CatmullRomSpline member function getMaximum2DCurvature calculates the wrong value.
The member function finds the greatest max 2D curvature value from all curves that are included in the spline. This is done in the line below.
However the max 2D curvature can be a positive as well as a negative value. The curvature magnitude is determined by the absolute value of the curvature value, which is considered in the function below.
if (std::fabs(values.first) > std::fabs(values.second)) {
return values.first;
}
return values.second;
}
This means that the CatmullRomSpline member function getMaximum2DCurvature having two values: -10 and 2 will choose 2, however the value -10 corresponds to a much greater curvature, just in the other direction. For a spline having all component curves bending in one way (when all component max 2D curvatures are negative) this member function actually does the opposite of what is should - it selects the smallest curvature.
The logic present in HermiteCurve member function should be applied to a CatmullRomSpline member function as well.
Context:
I am adding unit tests for the geometry package and wanted to add tests for the getMaximum2DCurvature function, but it generates the wrong result in a case similar to the example above.
To Reproduce
Steps to reproduce the behavior:
Edit any existing source code file or create a new one
Create a CatmullRomSpline passing through points (0, 0), (0.5, 0.5), (1, 0), (2, -1) and (3, 0)
Call the getMaximum2DCurvature member function
Print and see the incorrect result
Expected behavior
Greatest absolute value should be selected instead of the greatest one.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: [e.g. iOS]: Ubuntu
Browser [e.g. chrome, safari]: Firefox
Version [e.g. 22]: 22
ROS 2 version: Humble
DDS: CycloneDDS
The text was updated successfully, but these errors were encountered:
Describe the bug
CatmullRomSpline
member functiongetMaximum2DCurvature
calculates the wrong value.The member function finds the greatest max 2D curvature value from all curves that are included in the spline. This is done in the line below.
scenario_simulator_v2/common/math/geometry/src/spline/catmull_rom_spline.cpp
Line 570 in 173a8c1
However the max 2D curvature can be a positive as well as a negative value. The curvature magnitude is determined by the absolute value of the curvature value, which is considered in the function below.
scenario_simulator_v2/common/math/geometry/src/spline/hermite_curve.cpp
Lines 303 to 310 in 173a8c1
This means that the
CatmullRomSpline
member functiongetMaximum2DCurvature
having two values: -10 and 2 will choose 2, however the value -10 corresponds to a much greater curvature, just in the other direction. For a spline having all component curves bending in one way (when all component max 2D curvatures are negative) this member function actually does the opposite of what is should - it selects the smallest curvature.The logic present in
HermiteCurve
member function should be applied to aCatmullRomSpline
member function as well.Context:
I am adding unit tests for the
geometry
package and wanted to add tests for thegetMaximum2DCurvature
function, but it generates the wrong result in a case similar to the example above.To Reproduce
Steps to reproduce the behavior:
CatmullRomSpline
passing through points (0, 0), (0.5, 0.5), (1, 0), (2, -1) and (3, 0)getMaximum2DCurvature
member functionExpected behavior
Greatest absolute value should be selected instead of the greatest one.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: