Skip to content
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

Error when the spline_approximation.py function is called in the scope of prep_track.py #11

Open
pedrocalorio opened this issue Oct 25, 2022 · 2 comments

Comments

@pedrocalorio
Copy link

I was trying to use this API to get the track yaw angle and curvature based on GPS data to run my laptime sims.

Then I was trying to use your algorithm to understand how you import the track data and get the racing line from it. However, when I try to run the main_globaltraj.py I have this error.

It seems that there is a optimization function being called in line 95 of the spline_approximation function, and the data size of the arguments are wrong.

This was the very same error I had when trying to use only the functions I needed to calculate the curvature analytically.

Here is the error log:

Traceback (most recent call last):
File "/home/pedroc/dev/global_racetrajectory_optimization/main_globaltraj.py", line 243, in
helper_funcs_glob.src.prep_track.prep_track(reftrack_imp=reftrack_imp,
File "/home/pedroc/dev/global_racetrajectory_optimization/helper_funcs_glob/src/prep_track.py", line 39, in prep_track
reftrack_interp = tph.spline_approximation.
File "/home/pedroc/dev/global_racetrajectory_optimization/venv/lib/python3.10/site-packages/trajectory_planning_helpers/spline_approximation.py", line 95, in spline_approximation
closest_t_glob_cl[i] = optimize.fmin(dist_to_p,
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/optimize/_optimize.py", line 622, in fmin
res = _minimize_neldermead(func, x0, args, callback=callback, **opts)
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/optimize/_optimize.py", line 772, in _minimize_neldermead
fsim[k] = func(sim[k])
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/optimize/_optimize.py", line 496, in function_wrapper
fx = function(np.copy(x), *(wrapper_args + args))
File "/home/pedroc/dev/global_racetrajectory_optimization/venv/lib/python3.10/site-packages/trajectory_planning_helpers/spline_approximation.py", line 146, in dist_to_p
return spatial.distance.euclidean(p, s)
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/spatial/distance.py", line 518, in euclidean
return minkowski(u, v, p=2, w=w)
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/spatial/distance.py", line 462, in minkowski
v = _validate_vector(v)
File "/home/pedroc/.local/lib/python3.10/site-packages/scipy/spatial/distance.py", line 301, in _validate_vector
raise ValueError("Input vector should be 1-D.")
ValueError: Input vector should be 1-D.

Process finished with exit code 1

@rs38
Copy link

rs38 commented Sep 14, 2023

did you find a reason/solution for that error?

    s = interpolate.splev(t_glob, path) # s will be an array of arrays
    return spatial.distance.euclidean(p, s) #1-D error for s

https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.euclidean.html
but this is too old :
https://docs.scipy.org/doc/scipy/release/0.11.0-notes.html#minor-change-in-behavior-of-splev

@ahmad12hamdan99
Copy link

I had the sam error, I solved it by installing the same versions mentiond in the requirements file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants