TUMFTM / global_racetrajectory_optimization

This repository contains multiple approaches for generating global racetrajectories.
GNU Lesser General Public License v3.0
473 stars 194 forks source link

Compute trajectory for non-closed roads #1

Closed alessiogambi closed 4 years ago

alessiogambi commented 4 years ago

Hi, I am trying to compute the optimal trajectory for a generic road. Since this is not a track, the road is not closed. This case is considered in the script that generates the friction map, but it might not be contemplated for computing optimal trajectories.

When I run main_globaltraj.py I get the following message: OSError: At least two spline normals are crossed, check input or increase smoothing factor!

The plot shows the road as expected, but also an additional connection between the first and last point (see the attached screenshot) that causes the above error.

Screen Shot 2020-10-20 at 11 40 49
alessiogambi commented 4 years ago

A note inside spline_approximation.py says: "The function can only be used for closable tracks, i.e. track is closed at the beginning!"

So I guess that this explains why it does not work. But maybe @StahlTim or someone else can suggest how to solve this?

alessiogambi commented 4 years ago

Since the coordinates that I provide are already interpolated using a spline, for the moment I can skip spline_approximation. This avoids stumbling on the problem of intersecting splines, but the resulting trajectory still shows some "weirdness:"

Screen Shot 2020-10-20 at 12 09 01
heilmeiera commented 4 years ago

Hi, as you have already noted, the approach is currently only implemented for closed tracks. It is certainly possible to include the case of unclosed tracks, as in your case, but this would require reworking several parts of the code. Since the global trajectory planner is currently not actively developed (simply because of limited capacity), we do not plan to include this feature in the near future. A quick and dirty solution for your problem could be to remove the checks in the code, temporarily add points before and after your road segment, and cut them away after optimization (mostly, the optimization still works).

alessiogambi commented 4 years ago

@heilmeiera Thanks for the clarification and the suggestion. This is exactly what I am doing right now, working my way inside the code and tweaking it or setting is_close flags to false here and there. T

alessiogambi commented 4 years ago

FYI, I managed to tweak the code enough to get what I needed. In case someone else needs it, tag me here.

berlala commented 3 years ago

@alessiogambi I got this issue solved by adapt the matrix for start and end points. (Refer to @heilmeiera 's paper Eq.[16], Minimum Curvature Trajectory Planning and Control for an Autonomous Racecar, VSD 2019). If you or anyone still need it pls. let me know.

alessiogambi commented 3 years ago

@berlala Yes, I am still interested. I have a couple of ideas I would like to discuss, but maybe we can do this by email.

heilmeiera commented 3 years ago

For the future:

I just merged the following PR in our helper functions repository: https://github.com/TUMFTM/trajectory_planning_helpers/pull/2 The updated version of that repository is made available via Pypi as version 0.76.

The function opt_min_curv of that repository (which is ultimately what is used within global_racetrajectory_optimization for the minimum curvature optimization) is now able to handle open tracks. The pre-processing within global_racetrajectory_optimization must still be adapted, i.e. it does not work out of the box. However, it makes things much easier if you want to optimize open tracks.

ChristinaPrigge commented 2 years ago

Hello, I'm struggling with getting a curvature minimization for open tracks. What exactly do I have to adapt or what's the best way to adapt the pre-processing within global_racetrajectory_optimization? Thanks for your help!

GabrieleRini commented 2 years ago

FYI, I managed to tweak the code enough to get what I needed. In case someone else needs it, tag me here. I am really interested in what you did @alessiogambi
Would it be possible for you to talk about it? Many thanks!

alessiogambi commented 2 years ago

@GabrieleRini I need to dig up the changes and it might take a while. Did you check @berlala solution?