motional / nuplan-devkit

The devkit of the nuPlan dataset.
https://www.nuplan.org
Other
700 stars 136 forks source link

Bug when running nuplan_planner_tutorial.ipynb #217

Open QuanyiLi opened 1 year ago

QuanyiLi commented 1 year ago

Describe the bug

Hi, I am running the basic tutorial: nuplan_planner_tutorial.ipynb. When running to the cell where main_simulation(cfg, planner) is called, I got some errors as follows.

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
Rendering histograms: 0it [00:00, ?it/s]

I checked the error. It seems that when creating StateVector2D the argument x is in list type instead of float type. It causes the error when using a list to initialize np.array.

Setup

Ubuntu20.04, 64g ram

Steps To Reproduce

Just follow the documentation and install nuplan, and then run this .ipynb

Stack Trace

Traceback (most recent call last):
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/runner/executor.py", line 27, in run_simulation
    return sim_runner.run()  # type: ignore
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/runner/simulations_runner.py", line 134, in run
    trajectories = self.planner.compute_trajectory(planner_inputs)
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/planner/abstract_planner.py", line 124, in compute_trajectory
    raise e
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/planner/abstract_planner.py", line 121, in compute_trajectory
    trajectory = self.compute_planner_trajectory(current_input)
  File "/home/shady/data/nuplan-devkit/my_test/_test_script.py", line 95, in compute_planner_trajectory
    state = self.motion_model.propagate_state(state, state.dynamic_car_state, self.sampling_time)
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/controller/motion_model/kinematic_bicycle.py", line 98, in propagate_state
    propagating_state = self._update_commands(state, ideal_dynamic_state, sampling_time)
  File "/home/shady/data/nuplan-devkit/nuplan/planning/simulation/controller/motion_model/kinematic_bicycle.py", line 82, in _update_commands
    rear_axle_acceleration_2d=StateVector2D(updated_accel, 0),
  File "/home/shady/data/nuplan-devkit/nuplan/common/actor_state/state_representation.py", line 292, in __init__
    self.array = np.array([self.x, self.y], dtype=np.float64)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.
Rendering histograms: 0it [00:00, ?it/s]

Screenshots

Screenshot from 2023-01-19 20-51-01

Additional context

N/A

kevinstoesser commented 1 year ago

I solved the issue by integrating #214. Maybe this helps you.

QuanyiLi commented 1 year ago

@K3vwho Thank you!

QuanyiLi commented 1 year ago

BTW, I found when using +simulation=closed_loop_reactive_agents for run_simulatioin.py, there are similar shape related bugs in idm_agent_manager, which causes the shapely.Polygon construction error.

For reproducing it, run:

python run_simulation.py \
+simulation=closed_loop_nonreactive_agents   \    
scenario_filter.limit_total_scenarios=1        \
planner=simple_planner \
worker=sequential 
kevinstoesser commented 1 year ago

Yes, I also have the same issue when using idm_planner or +simulation=closed_loop_reactive_agents. I didn't solve the issue yet. If you found any solution, would be nice if you can share it.

PS: I think you meant +simulation=closed_loop_reactive_agents in your reproduction example.

kevinstoesser commented 1 year ago

I found that the construction error is caused by shapely==2.0.0, if you use an earlier version e.g. 1.8.4, it's solved. But the a new error occurs in the strtree_occupancy_map.py. I didn't manage to solve the key error yet, do you have any suggestions?

patk-motional commented 1 year ago

Hi all,

We have addressed this issue in the next release. The issue comes from the update to shapely >=2.0 and some interfaces have changed. Thank you for your patience

HITXCI commented 1 year ago

Hi! I got the same problem when i was running "nuplan_planner_tutorial.ipynb". I have changed the shapely to 1.8.4, but didn't work. ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. Rendering histograms: 0it [00:00, ?it/s] do you have any suggestions? Thanks

kevinstoesser commented 1 year ago

@HITXCI just change the branch to nuplan-devkit-v1.1 and install everything accordingly.

HITXCI commented 1 year ago

@K3vwho Thanks for your suggenstion! But it's still not working.