PJLab-ADG / LimSim

LimSim & LimSim++: Integrated traffic and autonomous driving simulators with (M)LLM support
https://pjlab-adg.github.io/LimSim/
GNU General Public License v3.0
344 stars 27 forks source link

The possibility of using neural network models to replace the PDP process. #26

Closed gcruiser closed 3 months ago

gcruiser commented 3 months ago

Thanks for the work! May I ask if limsim supports using neural network models trained through deep learning or reinforcement learning as multi vehicle decision models? My trained model takes environment observation as input and output continuous actions [acceleration, steering] in every step for the next step.

Fdarco commented 3 months ago

Hello, thank you for your interest in LimSim and LimSim++. As of now, LimSim supports controlling vehicle motion through Meta-actions (in LimSim++) and trajectory control.

Controlling via Meta-actions

from trafficManager.common.vehicle import Behaviour
# your_behavior: Behaviour = your_model.output()
trajectories = planner.plan(
    model.timeStep * 0.1, roadgraph, vehicles, your_behavior, other_plan=False
)
model.setTrajectories(trajectories)

Direct Trajectory Control

# your_trajectory = your_model.output()
model.setTrajectories(trajectories)

Unfortunately, we do not currently support controlling vehicles through continuous actions (such as acceleration and steering). Achieving this in the current version is challenging. Our next step will be to provide a CARLA ONLY version, which may support this functionality.

Of course, if you can implement this feature, feel free to submit a pull request. 🚗🔧

Fdarco commented 3 months ago

Alternatively, you can write a function that converts continuous actions into trajectories, allowing you to control vehicles in LimSim. This is a relatively straightforward solution. For example, consider the following simple function to achieve this:

import math

def update_state(x, y, v, acc, yaw, steering, dt):
    # Update speed
    v_new = v + acc * dt
    # Update direction
    yaw_new = yaw + steering * dt
    # Update position
    x_new = x + v_new * math.cos(yaw_new) * dt
    y_new = y + v_new * math.sin(yaw_new) * dt
    return x_new, y_new, v_new, yaw_new

Of course this is only a rough version of the implementation, you can design more realistic functions according to your own requirements.

gcruiser commented 3 months ago

Thanks!

Alternatively, you can write a function that converts continuous actions into trajectories, allowing you to control vehicles in LimSim. This is a relatively straightforward solution. For example, consider the following simple function to achieve this:

import math

def update_state(x, y, v, acc, yaw, steering, dt):
    # Update speed
    v_new = v + acc * dt
    # Update direction
    yaw_new = yaw + steering * dt
    # Update position
    x_new = x + v_new * math.cos(yaw_new) * dt
    y_new = y + v_new * math.sin(yaw_new) * dt
    return x_new, y_new, v_new, yaw_new

Of course this is only a rough version of the implementation, you can design more realistic functions according to your own requirements.