GithubHelp home page GithubHelp logo

pjlab-adg / limsim Goto Github PK

View Code? Open in Web Editor NEW
368.0 10.0 29.0 24.72 MB

LimSim & LimSim++: Integrated traffic and autonomous driving simulators with (M)LLM support

Home Page: https://pjlab-adg.github.io/LimSim/

License: GNU General Public License v3.0

Python 99.89% Shell 0.10% Batchfile 0.01%

limsim's Introduction

logo-full.svg

Custom badge Custom badge Custom badge Custom badge

🚀News:

  • 2024/03/05 LimSim++ is now released!
  • 2023/07/26 Add the docs about co-sim with CARLA.
  • 2023/07/13 The code is now released!

LimSim

LimSim is a Long-term Interactive Multi-scenario traffic Simulator, which aims to provide a continuous simulation capability under the complex urban road network.

Quick Start

After configuring the runtime environment, download the LimSim source code to your local machine:

git clone https://github.com/PJLab-ADG/LimSim.git

Finally, you need to install the required Python extensions:

cd LimSim
pip install -r requirements.txt

Now, the local installation and deployment of LimSim are complete.

1. Real-time Sim

Real-time simulation following the Ego vehicle is the fundamental feature of LimSim. To experience it, run the following command:

python ModelExample.py

2. Simulation replay

In the root directory, running the following command will invoke LimSim's replay feature:

python ReplayExample.py

For more information of our code, please see our Online Documentation.

If you have any problem when installing and deployment, feel free to open an issue here!

🎁 Main Features

  • Long-term: Traffic flow can be generated over long periods under the guidance of demand and route planning.

  • Diversity: The built-in behavioral models take heterogeneous driving styles of vehicles into account.

  • Interactivity: Vehicles in the scenario area are controlled address sophisticated interactions among vehicles.

  • Multi-scenario: The universal road components supports a variety of road structures in the real world.

🖥️ GUI

LimSim has a cross-platform user-friendly GUI, which includes not only a beautiful simulation interface, but also information on road network and ego-vehicle status.

limsim_gui.png

🛣️ Multi-scenarios support

LimSim supports road scenarios not limited to freeways, signalized intersections, roundabouts and overpasses.

scenarios.gif

📊 Scenario Evaluation

After running a long-term simulation with all kinds of scenarios contained in it, LimSim generates a log report and extract the key scenarios via the evaluation results.

evaluation.gif

💡Co-sim with SUMO & CARLA

LimSim supports co-simulation with CARLA and SUMO, guaranteeing that all three softwares show identical vehicle status. Please see the docs for more information.

cosim.gif

➕Additional Maps

LimSim supports the freewayB and Expressway_A maps from the CitySim datasets. However, we have not included these two road network files in this library due to copyright.

To run these two maps, you need to:

  1. Go to CitySim Repo and submit the data access form.
  2. Get access to the dataset and download the .net.xml files in both the freewayB and Expressway_A data folders.
  3. Copy the road network files (.net.xml) to the relevant networkFiles/CitySim folder and ensure that your file paths are as follows:
    networkFiles/CitySim/freewayB/freewayB.net.xml
    networkFiles/CitySim/Expressway_A/Expressway_A.net.xml
    

Acknowledgments

We would like to thank the authors and developers of the following projects, this project is built upon these great projects.

Contact

If you have any suggestions or collaboration about this repo, feel free to create a issue/PR or send email to us ([email protected]).

Citation

If you use LimSim in your research , please use the following BibTeX entry.

@misc{wen2023limsim,
      title={LimSim: A Long-term Interactive Multi-scenario Traffic Simulator}, 
      author={Licheng Wen and Daocheng Fu and Song Mao and Pinlong Cai and Min Dou and Yikang Li and Yu Qiao},
      year={2023},
      eprint={2307.06648},
      archivePrefix={arXiv},
      primaryClass={eess.SY}
}

License

LimSim is released under the GNU GPL v3.0 license.

limsim's People

Contributors

fdarco avatar zijinoier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

limsim's Issues

ModuleNotFoundError: No module named 'carla'

Traceback (most recent call last): File "ExampleVLMAgentCloseLoop.py", line 225, in <module> model.start() File "/home/v2t/LimSim/simModel/Model.py", line 177, in start from sumo_integration.run_synchronization import getSynchronization File "/home/v2t/LimSim/sumo_integration/run_synchronization.py", line 39, in <module> import carla # pylint: disable=import-error ModuleNotFoundError: No module named 'carla'

When I run ExampleVLMAgentCloseLoop.py,What can I do if I get the above error?

how to use co-simulation with carla?

Limsim is a creative software for traffic simulation.But I can't find the content for co-simulation with carla and create my own scenario.
Also ,the sumo network file and the route file seems don't seem to match well.
Looking forward to further improvement of the software and its user doc.

Can not open Traffic Simulator

We try your Quick Start and build the environment with python=3.9.18 and sumolib = 1.16 . But the Traffic Simulator shows nothing with no error.
1695026347840

关于能否鼠标点击车道输出车道坐标的问题

image
image
大佬您好,现在我想添加一个自定义功能:在点击车道时得到该车道的edge_id,就像sumo里面那样。这样方便我设置起点和终点坐标来规划路径。拜读您们的代码后还是对车道展示的逻辑不太清楚,能否请大佬给出一点思路吗?

About ‘EGO_PLANNER’ and ‘USE_DECISION_MAKER’

Hello,

I am confused about how LimSim generates trajectories if maintaining ‘USE_DECISION_MAKER’ as 'False'? Since the planning module needs to know decision results from the decision-making module in advance so that it can generate trajectories successfully. Could you explain it in more details? Thanks!

Another thing, the following error will happen when ‘EGO_PLANNER’ and ‘USE_DECISION_MAKER’ are changed from 'False' into 'True':

Traceback (most recent call last):
File "/home/caros/limsim/LimSim/ModelExample.py", line 83, in
run_model(net_file, rou_file, ego_veh_id="61", carla_cosim=False)
File "/home/caros/limsim/LimSim/ModelExample.py", line 70, in run_model
trajectories = planner.plan(
File "/home/caros/limsim/LimSim/trafficManager/traffic_manager.py", line 161, in plan
ego_path = self.ego_planner.plan(vehicles[ego_id], observation,
File "/home/caros/limsim/LimSim/trafficManager/planner/ego_vehicle_planner.py", line 49, in plan
current_state = State(x=other_track[0].x,
IndexError: list index out of range

Expressway_A and freewayB

您好,我遇到了一个问题,其中 networkFiles/CitySim/freewayB/freewayB.rou.xml 与 freewayB 不匹配。城市模拟中的 net.xml。也许 CitySim 已经更新了?有些边缘不存在,你能把你原来的边缘发给我吗?
Uploading 1701588937536.jpg…
Uploading image.png…

How to control ego vehicles

Hello, I hope to use my own control algorithm to control the steering wheel angle and throttle of the EGO vehicle. How should I take over the control of the EGO vehicle? Can you tell me where to start modifying the Traci control of ego vehicles? The surrounding vehicles still use their original trajectory control.

Some questions about carFactory.py

Hello, I would like to know the purpose of the code on line 246 in carFactory.py? Can it be deleted or how should it be changed? Because I found that the maximum acceleration of vehicles leaving the AOI area has been changed, which can cause congestion due to the low speed of vehicles leaving the AOI area.
if accel >= 0:
traci.vehicle.setAccel(self.id, accel)
traci.vehicle.setDecel(self.id, self.maxDecel)
else:
traci.vehicle.setAccel(self.id, self.maxAccel)
traci.vehicle.setDecel(self.id, -accel)
else:
traci.vehicle.setLaneChangeMode(self.id, 0)
traci.vehicle.setSpeedMode(self.id, 0)
traci.vehicle.moveToXY(self.id, '', -1, x, y,
angle=angle, keepRoute=2)
traci.vehicle.setSpeed(self.id, speed)
if accel >= 0:
traci.vehicle.setAccel(self.id, accel)
traci.vehicle.setDecel(self.id, self.maxDecel)
else:
traci.vehicle.setAccel(self.id, self.maxAccel)
traci.vehicle.setDecel(self.id, -accel)

image

Some question about frenet optimal plan

Hello, if the USE.DECISION-MAKER in the config file is False, the generated trajectory will not change lanes? Because I found that if the vehicle behavior is not changed, it is always KL, so the trajectory for keeping the lane will be generated by "def lanekeeping_trajectory_generator"

Running Error about cannot next_lanes

When I try to run the simulator in a new map, sometimes I will encounter the error as followings:

Traceback (most recent call last):
File "D:\Files and Data\Research\Work\Doing\TestPlatform\Codes\ModelExample.py", line 96, in
run_model(net_file, rou_file, ego_veh_id="HV_100", carla_cosim=False)
File "D:\Files and Data\Research\Work\Doing\TestPlatform\Codes\ModelExample.py", line 83, in run_model
trajectories = planner.plan(
File "D:\Files and Data\Research\Work\Doing\TestPlatform\Codes\trafficManager\traffic_manager.py", line 136, in plan
vehicle.update_behaviour(roadgraph, KEY_INPUT)
File "D:\Files and Data\Research\Work\Doing\TestPlatform\Codes\trafficManager\common\vehicle.py", line 249, in update_behaviour
self.lane_id = next_lane.id
AttributeError: 'NoneType' object has no attribute 'id'
Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown
Quitting (on error)

This seems to be caused by the 'None' returned by function 'get_available_next_lanes' in the class 'RoadGraph' (utils->roadgraph line 197) because the variable 'next_lane_i' isn't included in 'available_lanes' when the ego vehicle passes some specific lanes. Further I check the 'available lanes' of vehicle, which is the same as current lane id of ego vehicle, but I think available lanes may include the next lane id?
I don't know how to make it work correctly? I hope to get your help, thanks a lot!

Collect data

Can the software collect visual image data for reinforcement learning?

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

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.

How to perform a reset operation

Hello, I would like to enable the simulation to return to its original position and iterate repeatedly after the ego vehicle reaches its destination or meets certain conditions. How should I modify the code?

error

Traceback (most recent call last):
File "C:\doctor\LimSim-LimSim_plus\ExampleLLMAgentCloseLoop.py", line 288, in
model = Model(
File "C:\doctor\LimSim-LimSim_plus\simModel\Model.py", line 80, in init
self.dbBridge.createTable()
File "C:\doctor\LimSim-LimSim_plus\simModel\DBBridge.py", line 12, in createTable
conn = sqlite3.connect(self.database)
sqlite3.OperationalError: unable to open database file

I ran under win, reported this error, may I ask how to solve? Thanks for your reply!

EGO car and the surrounding cars

Hello, I would like to know if both the EGO car and surrounding cars are controlled by the LLM model? Also, can we implement our own model to control the EGO car and the LLM model to control the surrounding traffic flow, just like Limsim?

some errors happened when using co-simulation with CARLA 0.9.13

I can normally use LimSim, but when I co-simulate with CARLA, something wrong happens.
Here are my environment and log.
Thanks.
----environment----
Windows 10
python 3.9
SUMO 1.18.0
CARLA 0.9.13
----environment----

----run_synchronization.py Log----
INFO: Connection to sumo server. Host: 127.0.0.1 Port: 8813
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds
File "run_synchronization.py", line 319, in
synchronization_loop(arguments)
File "run_synchronization.py", line 246, in synchronization_loop
synchronization.tick()
File "run_synchronization.py", line 106, in tick
self.sumo.tick()
File "D:\Pycharm\PytorchProjects\CARLA\Sumo\sumo_integration\sumo_simulation.py", line 505, in tick
traci.simulationStep()
connection.check().simulationStep(step)
File "D:\SUMO\tools\traci\connection.py", line 368, in simulationStep
result = self._sendCmd(tc.CMD_SIMSTEP, None, None, "D", step)
File "D:\SUMO\tools\traci\connection.py", line 231, in _sendCmd
return self._sendExact()
File "D:\SUMO\tools\traci\connection.py", line 137, in _sendExact
raise FatalTraCIError("Connection closed by SUMO.")
traci.exceptions.FatalTraCIError: Connection closed by SUMO.
(pytorch) PS D:\Pycharm\PytorchProjects\CARLA\Sumo> python run_synchronization.py examples/Town05.sumocfg --sumo-host 127.0.0.1 --sumo-port 8813
INFO: Connection to sumo server. Host: 127.0.0.1 Port: 8813
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds
Could not connect to TraCI server at 127.0.0.1:8813 [WinError 10061] 由于目标计算机积极拒绝,无法连接。
Retrying in 1 seconds

INFO: Found the required file in cache! Carla/Maps/TM/Town05.bin
INFO: Cleaning synchronization
Traceback (most recent call last):
File "run_synchronization.py", line 319, in
synchronization_loop(arguments)
File "run_synchronization.py", line 246, in synchronization_loop
synchronization.tick()
File "run_synchronization.py", line 106, in tick
self.sumo.tick()
File "D:\Pycharm\PytorchProjects\CARLA\Sumo\sumo_integration\sumo_simulation.py", line 505, in tick
traci.simulationStep()
File "D:\SUMO\tools\traci\main.py", line 198, in simulationStep
connection.check().simulationStep(step)
File "D:\SUMO\tools\traci\connection.py", line 368, in simulationStep
result = self._sendCmd(tc.CMD_SIMSTEP, None, None, "D", step)
File "D:\SUMO\tools\traci\connection.py", line 231, in _sendCmd
return self._sendExact()
File "D:\SUMO\tools\traci\connection.py", line 137, in _sendExact
raise FatalTraCIError("Connection closed by SUMO.")
traci.exceptions.FatalTraCIError: Connection closed by SUMO.

----ModelExample.py Log----
Model initialized at 18:39:47.106.
Network building finished at 18:39:49.246.
Network information commited at 18:39:49.272.
Error: Answered with error to command 0x03: Order '1' is already taken.
Traceback (most recent call last):
File "D:\Pycharm\PytorchProjects\LimSim-master\ModelExample.py", line 83, in
run_model(net_file, rou_file, ego_veh_id="4", carla_cosim=True)
File "D:\Pycharm\PytorchProjects\LimSim-master\ModelExample.py", line 62, in run_model
model.start()
File "D:\Pycharm\PytorchProjects\LimSim-master\simModel\egoTracking\model.py", line 302, in start
traci.setOrder(1)
File "D:\SUMO\tools\traci\main.py", line 255, in setOrder
return connection.check().setOrder(order)
File "D:\SUMO\tools\traci\connection.py", line 389, in setOrder
self._sendCmd(tc.CMD_SETORDER, None, None, "I", order)
File "D:\SUMO\tools\traci\connection.py", line 231, in _sendCmd
return self._sendExact()
File "D:\SUMO\tools\traci\connection.py", line 144, in _sendExact
raise TraCIException(err, prefix[1], _RESULTS[prefix[2]])
traci.exceptions.TraCIException: Order '1' is already taken.

having multiple Ego vehicles inside a single Simulation

Hi, I was wondering if it is possible to have multiple Ego vehicles to switch between/ run multiple Clients inside a single Simulation. I Co-sim with SUMO and CARLA and was hoping to have multiple vehicles with different decision-making and spectate them either simultaneous or switch between them. If this is not natively supported by LimSim do you have an idea how I can achieve that?

About accelerate or decelerate in `ModelExample.py`

It seems that the code doesn't address accelerate or decelerate?
I have read the source code, and all the functions concerning trajectories do not take accelerate or decelerate into control.
Is this temporary and will be updated in the future?

Or am I wrong? Is there something I haven't noticed?

can not connect to 127.0.0.1:2000

Hi there,

I meet a strange problem that, I used a docker pulled from carla as the server, and I tried the SUMO demo "python3 run_synchronization.py examples/Town04.sumocfg --sumo-gui"
which works fine, however, I tried your "ExampleModel.py" , RuntimeError: time-out of 2000ms while waiting for the simulator, make sure the simulator is ready and connected to 127.0.0.1:2000, I read the code, I found the host and port are the same, I am so confused, did I make something wrong ? I really appreciate that you can help me out here. Thank you so much

Best,

openai.error.RateLimitError

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

When I use GPT-3.5, I get the error message as shown above. What is the reason for this and how can I resolve it?

Vehicles in the AOI area always accelerate and decelerate repeatedly

Hello, I have recently encountered a problem.I don't know if it's the problem I set, but I set the road speed limit for sumo and the vehicle speed in config.yaml to 30m/s. However, every time the vehicle speed in the AOI area reaches 13m/s, it slows down. What is the reason for this? How to solve this problem.
image
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.