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

Running Error about cannot next_lanes #21

Closed CornfileChase closed 3 months ago

CornfileChase commented 3 months ago

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!

CornfileChase commented 3 months ago

RoundaboutA.zip The attachment are the net file and rou file

Fdarco commented 3 months ago

Thanks for using LimSim & LimSim++, according to your description, it should be that the vehicle exiting the intersection did not turn to the proper lane in time. For example, if the vehicle needs to turn left, it needs to turn to the leftmost lane, but due to a wrong decision, the vehicle may not turn to the leftmost lane at the end of the road. Since get_available_lanes() gets the available lanes based on the vehicle's route information, the function won't work when this happens. To fix this, you can have the vehicle switch to the available lanes as soon as possible before it reaches the end of the road. Additionally, you can change the value of the Vehicle.lookForward property in simModel.common.carFactory.py to increase the value of this property, which will allow the vehicle to look farther and make decisions earlier.

CornfileChase commented 3 months ago

Thanks for your reply, it does work