-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getPolygon with 0 points #1122
Comments
I think CatmullRomSpline class cannot construct with 0 control points. scenario_simulator_v2/common/math/geometry/src/spline/catmull_rom_spline.cpp Lines 129 to 133 in c4b7daa
So, I think it would not be a problem. |
I am sorry if my explanation was not clear enough. scenario_simulator_v2/common/math/geometry/src/spline/catmull_rom_spline.cpp Lines 30 to 50 in c4b7daa
takes num_points as an argument. This argument is used to construct a polygon (or rather pairs of triangles) approximating the surface of the spline with a given width. It is independent from the number of control points that were used to construct the CatmullRomSpline .This num_points argument is not checked anywhere, and when it is set to 0, then the behavior I have described above is triggered (which leads to an exception).I have created an example test case to showcase the bug here. To see the problem:
|
@hakuturu583 |
Sorry for my late reply. |
Describe the bug
The
CatmullRomSpline
member functiongetPolygon
when called withnum_points = 0
raises an error with a descriptionfailed to calculate curve index
.This description does not say where the real error is in this case. It is thrown deep from the call stack by member function
getCurveIndexAndS
in the call order presented below:getPolygon -> getLeftBounds -> getNormalVector -> getCurveIndexAndS
This happens because the
num_points
(= 0) is used ingetLeftBounds
to calculatestep_size
(which is then equal to infinity).scenario_simulator_v2/common/math/geometry/src/spline/catmull_rom_spline.cpp
Line 81 in c4b7daa
This leads to a NaN
s
value which then is not matched to any component curve and a mentioned exception is being thrown bygetCurveIndexAndS
.scenario_simulator_v2/common/math/geometry/src/spline/catmull_rom_spline.cpp
Line 83 in c4b7daa
In my opinion there are three ways to improve the behavior in this situation:
getPolygon
function and thrown another exception with more informative descriptiongetPolygon
whennum_points == 0
getPolygon
to return an empty vector whennum_points == 0
Context:
I am adding unit tests for the geometry package and wanted to add tests for the
getPolygon
function.To Reproduce
Steps to reproduce the behavior:
CatmullRomSpline
getPolygon
member function withnum_points
argument set to 0Expected behavior
Either an exception with an appropriate description or the return of an empty vector.
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: