MCZhi / Driving-IRL-NGSIM

[T-ITS] Driving Behavior Modeling using Naturalistic Human Driving Data with Inverse Reinforcement Learning
MIT License
192 stars 37 forks source link

what does the parameter "self.overtaken" use in the class NGSIMVehicle? #3

Closed Joe12138 closed 2 years ago

Joe12138 commented 2 years ago

Hi! Thanks for your excellent work! But I am confused when I read the source code. Can you answer my question?

Question 1

In Class NGSIMVehicle, there is one class parameter "self.overtake", what does it use for? Because I noticed that it was always False. And, NSIMVehicle should be follow the trajectory recorded in the NGSIM dataset. Does it use to control if the vehicle overtaken other vehicles or not when NGSIMVehicle change to IDMVehicle? Here is the source code:

class NGSIMVehicle(IDMVehicle):
    """
    Use NGSIM human driving trajectories.
    """
    # Longitudinal policy parameters
    ACC_MAX = 5.0 # [m/s2]  """Maximum acceleration."""
    COMFORT_ACC_MAX = 3.0 # [m/s2]  """Desired maximum acceleration."""
    COMFORT_ACC_MIN = -3.0 # [m/s2] """Desired maximum deceleration."""
    DISTANCE_WANTED = 1.0 # [m] """Desired jam distance to the front vehicle."""
    TIME_WANTED = 0.5 # [s]  """Desired time gap to the front vehicle."""
    DELTA = 4.0  # [] """Exponent of the velocity term."""

    # Lateral policy parameters [MOBIL]
    POLITENESS = 0.1  # in [0, 1]
    LANE_CHANGE_MIN_ACC_GAIN = 0.2 # [m/s2]
    LANE_CHANGE_MAX_BRAKING_IMPOSED = 2.0 # [m/s2]
    LANE_CHANGE_DELAY = 1.0  # [s]

    # Driving scenario
    SCENE = 'us-101'

    def __init__(self, road, position,
                 heading=0,
                 velocity=0,
                 target_lane_index=None,
                 target_velocity=None,
                 route=None,
                 enable_lane_change=False, # only changed here
                 timer=None,
                 vehicle_ID=None, v_length=None, v_width=None, ngsim_traj=None):
        super(NGSIMVehicle, self).__init__(road, position, heading, velocity, target_lane_index, target_velocity, route, enable_lane_change, timer)

        self.ngsim_traj = ngsim_traj
        self.traj = np.array(self.position)
        self.vehicle_ID = vehicle_ID
        self.sim_steps = 0 
        self.overtaken = False
        self.appear = True if self.position[0] != 0 else False
        self.velocity_history = []
        self.heading_history = []
        self.crash_history = []
        self.overtaken_history = []

        # Vehicle length [m]
        self.LENGTH = v_length
        # Vehicle width [m]
        self.WIDTH = v_width 

Question 2:

In file humandriving.py class NGSIMVehicle method act():

def act(self):
        """
        Execute an action when NGSIM vehicle is overriden.

        :param action: the action
        """
        if not self.overtaken:
            return

        if self.crashed:
            return

        action = {}
        front_vehicle, rear_vehicle = self.road.neighbour_vehicles(self)

        # Lateral: MOBIL
        self.follow_road()
        if self.enable_lane_change:
            self.change_lane_policy()
        action['steering'] = self.steering_control(self.target_lane_index)

        # Longitudinal: IDM
        action['acceleration'] = self.acceleration(ego_vehicle=self, front_vehicle=front_vehicle, rear_vehicle=rear_vehicle)
        action['acceleration'] = np.clip(action['acceleration'], -self.ACC_MAX, self.ACC_MAX)
        self.check_collision
        self.action = action

Does the code self.check_collision right? Since it is a method which needs to be passes parameter.

Question 3

Another problem is that if I only use the dataset (the maximum length of vehicle trajectories in this dataset are 4s (40 frames)) to train, are the trajectories too short? Because I want to use INTERACTION dataset to train.

MCZhi commented 2 years ago

Sorry for the very late reply. For Question 1, yes, the class parameter "self.overtaken" is used to indicate whether the vehicle is affected by the ego vehicle, and thus should not be following the recorded trajectory. For Question 2, that might be a mistake, and I have deleted that line. For Question 3, I don't think the trajectories are too short, because 4 seconds is long enough.