ucla-mobility / OpenCDA

A generalized framework for prototyping full-stack cooperative driving automation applications under CARLA+SUMO.
Other
988 stars 197 forks source link

lag in v2x_manager #220

Open wbw20000 opened 8 months ago

wbw20000 commented 8 months ago

HI i am new to reading OpenCDA code. I may found the logic of v2x_manager add lag have improvement space !!

So i want to verfiy it with you .

The v2x_manager logic to add lag depends on the ego car pos list longer or shorter than self.lag . But in real world the comuncaiton lag mainly depends on the distance between two CAVs.Or the lag come from other issues like network congestion and so on .

the code in core/common/v2x_manager.py

** def get_ego_pos(self): """ Add noise and lag to the current ego position and send to other CAVs. This is for simulate noise and lagging during communication.

    Returns
    -------
    processed_ego_pos : carla.Transform
        The ego position after adding noise and lagging.
    """
    if not self.ego_pos:
        return None

    # add lag
    ego_pos = self.ego_pos[0] if len(self.ego_pos) < self.lag else \
        self.ego_pos[np.random.randint(-1 - int(abs(self.lag)), 0)]**