rodrigoqueiroz / geoscenarioserver

9 stars 1 forks source link

Vehicle "Gets Stuck" On Stop Line After Red Light #73

Closed mchlswyr closed 2 years ago

mchlswyr commented 3 years ago

In scenarios like scenarios/test_scenarios/gs_intersection_redlight.osm and scenarios/test_scenarios/gs_intersection_redlight_follow.osm, the vehicle sometimes "gets stuck" on the stop line after the red light. In the frenet plot in the dashboard, all of the "stuck" vehicle's trajectories are red (invalid), and new red ones keep being generated. The reason the vehicle "gets stuck" is because all of the trajectories being planned are invalid, so the vehicle just stays where it was when it had stopped.

To resolve this issue, we'll need to know why all of the trajectories being planned after the light turns green are invalid.

mchlswyr commented 3 years ago
mchlswyr commented 3 years ago

In sv/CostFunctions.py, added:

def direction_cost(frenet_traj:FrenetTrajectory, start_state):
    ''' Rejects trajectories that have a backwards component. '''
    T = frenet_traj.T
    # if end state is before start state
    if start_state[0] > frenet_traj.fs(T):
        print("End before start.")
        return 1
    # if velocity is negative at any point
    dt = float(T) / 100.0
    for i in range(100):
        t = dt * i
        if frenet_traj.fs_vel(t) < 0:
            print("Negative vel.")
            return 1
    return 0
mchlswyr commented 3 years ago
mchlswyr commented 3 years ago

@rodrigoqueiroz in direction_cost() can we add some room for very small values? So if frenet_traj.fs_vel(t) <= -0.001, for example? What would be a good value?