OpenCDA icon indicating copy to clipboard operation
OpenCDA copied to clipboard

Running the latest commit code with sample args occurs error

Open payprays opened this issue 1 year ago • 7 comments

Environment

  • OS: Ubuntu 22.04
  • Python: 3.7.12 (Anaconda environment)
  • matplotlib: 3.4.2
  • OpenCDA version: 0.1.3
  • CARLA version: 0.9.12

Problem Description

When running the platoon joining scenario with co-simulation, I'm getting a dimension mismatch error in the evaluation manager when trying to plot data:

ValueError: x and y must have same first dimension, but have shapes (1124,) and (1126,)

The error occurs in the plot_3d method of the EvaluationManager class when trying to plot accelerometer data. The time series (x-axis) has 1124 data points while the accelerometer data (y-axis) has 1126 points.

Steps to Reproduce

  1. Clone the repository
  2. Run the platoon joining scenario:
    python opencda.py -t platoon_joining_2lanefree_cosim  --apply_ml --record -v 0.9.12
    

Error Log

The error occurs during the evaluation phase after the simulation completes successfully:

***********Planning Evaluation Module***********
Planned distance: 1343.6927490234375
Real distance: 1341.3471999624744
...
ValueError: x and y must have same first dimension, but have shapes (1124,) and (1126,)

Additionally, I notice the warning:

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

here is the complete console:

est@4090-pc ~/V/O/OpenCDA (main)>  cd /home/test/V2X/OpenCDA/OpenCDA ; /usr/bin/env /home/test/anaconda3/envs/opencda
/bin/python /home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/adapter/../../debu
gpy/launcher 59233 -- /home/test/V2X/OpenCDA/OpenCDA/opencda.py -t platoon_joining_2lanefree_cosim -v carla_version --
apply_ml --record -v 0.9.12 
OpenCDA Version: 0.1.3
Using cache found in /home/test/.cache/torch/hub/ultralytics_yolov5_master
YOLOv5 🚀 v6.2-0-gd3ea0df Python-3.7.12 torch-1.8.0 CUDA:0 (NVIDIA GeForce RTX 4090, 24109MiB)

Fusing layers... 
YOLOv5m summary: 290 layers, 21172173 parameters, 0 gradients, 48.9 GFLOPs
Adding AutoShape... 
load opendrive map '2lane_freeway_simplified.xodr'.
Starting new sumo server...
Remember to press the play button to start the simulation
 Retrying in 1 seconds
/home/test/V2X/OpenCDA/OpenCDA/opencda/co_simulation/sumo_integration/sumo_simulation.py:297: FutureWarning: This search incorrectly ignores the root element, and will be fixed in a future version.  If you rely on the current behaviour, change it to './/net-file'
  tag = tree.find('//net-file')
Creating platoons/
Using cache found in /home/test/.cache/torch/hub/ultralytics_yolov5_master
YOLOv5 🚀 v6.2-0-gd3ea0df Python-3.7.12 torch-1.8.0 CUDA:0 (NVIDIA GeForce RTX 4090, 24109MiB)

Fusing layers... 
YOLOv5m summary: 290 layers, 21172173 parameters, 0 gradients, 48.9 GFLOPs
Adding AutoShape... 
Creating single CAVs.
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.tt
/home/test/V2X/OpenCDA/OpenCDA/opencda/core/application/platooning/platoon_behavior_agent.py:303: RuntimeWarning: divide by zero encountered in double_scalars
  time_gap = distance / delta_v
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.a2
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.patrol
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.a2
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.jeep.wrangler_rubicon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
merging vehicle chooses cut-in joining
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
trying to get the vehicle
trying to get the vehicle
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
trying to get the vehicle
trying to get the vehicle
trying to get the vehicle
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close, step back!
too close to rear vehicle!
cuurent gap is 0.610000
too close to rear vehicle!
cuurent gap is 0.620000
too close to rear vehicle!
cuurent gap is 0.630000
too close to rear vehicle!
cuurent gap is 0.640000
too close to rear vehicle!
cuurent gap is 0.650000
too close to rear vehicle!
cuurent gap is 0.660000
too close to rear vehicle!
cuurent gap is 0.670000
too close to rear vehicle!
cuurent gap is 0.680000
too close to rear vehicle!
cuurent gap is 0.690000
too close to rear vehicle!
cuurent gap is 0.700000
too close to rear vehicle!
cuurent gap is 0.710000
too close to rear vehicle!
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.volkswagen.t2
cuurent gap is 0.720000
too close to rear vehicle!
cuurent gap is 0.730000
too close to rear vehicle!
cuurent gap is 0.740000
too close to rear vehicle!
cuurent gap is 0.750000
too close to rear vehicle!
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.chevrolet.impala
cuurent gap is 0.760000
too close to rear vehicle!
cuurent gap is 0.770000
too close to rear vehicle!
cuurent gap is 0.780000
too close to rear vehicle!
cuurent gap is 0.790000
too close to rear vehicle!
cuurent gap is 0.800000
too close to rear vehicle!
cuurent gap is 0.810000
too close to rear vehicle!
cuurent gap is 0.820000
too close to rear vehicle!
cuurent gap is 0.830000
too close to rear vehicle!
cuurent gap is 0.840000
too close to rear vehicle!
cuurent gap is 0.850000
too close to rear vehicle!
cuurent gap is 0.860000
too close to rear vehicle!
cuurent gap is 0.870000
too close to rear vehicle!
cuurent gap is 0.880000
too close to rear vehicle!
cuurent gap is 0.890000
too close to rear vehicle!
cuurent gap is 0.900000
too close, step back!
cuurent gap is 0.910000
too close, step back!
cuurent gap is 0.920000
too close, step back!
cuurent gap is 0.930000
too close, step back!
cuurent gap is 0.940000
too close, step back!
cuurent gap is 0.950000
too close, step back!
cuurent gap is 0.960000
too close, step back!
cuurent gap is 0.970000
too close, step back!
cuurent gap is 0.980000
too close, step back!
cuurent gap is 0.990000
too close, step back!
cuurent gap is 1.000000
too close, step back!
cuurent gap is 1.010000
too close, step back!
cuurent gap is 1.020000
too close, step back!
cuurent gap is 1.030000
too close, step back!
cuurent gap is 1.040000
too close, step back!
cuurent gap is 1.050000
too close, step back!
cuurent gap is 1.060000
too close, step back!
cuurent gap is 1.070000
too close, step back!
cuurent gap is 1.080000
too close, step back!
cuurent gap is 1.090000
too close, step back!
cuurent gap is 1.100000
too close, step back!
cuurent gap is 1.110000
too close, step back!
cuurent gap is 1.120000
too close, step back!
cuurent gap is 1.130000
too close, step back!
cuurent gap is 1.140000
too close, step back!
cuurent gap is 1.150000
too close, step back!
cuurent gap is 1.160000
too close, step back!
cuurent gap is 1.170000
too close, step back!
cuurent gap is 1.180000
too close, step back!
cuurent gap is 1.190000
too close to rear vehicle!
cuurent gap is 1.200000
too close to rear vehicle!
cuurent gap is 1.210000
too close to rear vehicle!
cuurent gap is 1.220000
too close to rear vehicle!
cuurent gap is 1.230000
too close to rear vehicle!
cuurent gap is 1.240000
too close to rear vehicle!
cuurent gap is 1.250000
too close to rear vehicle!
cuurent gap is 1.260000
too close to rear vehicle!
cuurent gap is 1.270000
too close to rear vehicle!
cuurent gap is 1.280000
too close to rear vehicle!
cuurent gap is 1.290000
too close to rear vehicle!
cuurent gap is 1.300000
too close to rear vehicle!
cuurent gap is 1.310000
too close to rear vehicle!
cuurent gap is 1.320000
too close to rear vehicle!
cuurent gap is 1.330000
too close to rear vehicle!
cuurent gap is 1.340000
too close to rear vehicle!
cuurent gap is 1.350000
too close to rear vehicle!
cuurent gap is 1.360000
too close to rear vehicle!
cuurent gap is 1.370000
too close to rear vehicle!
cuurent gap is 1.380000
too close to rear vehicle!
cuurent gap is 1.390000
too close to rear vehicle!
cuurent gap is 1.400000
too close to rear vehicle!
cuurent gap is 1.410000
too close to rear vehicle!
cuurent gap is 1.420000
too close to rear vehicle!
cuurent gap is 1.430000
too close to rear vehicle!
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.a2
cuurent gap is 1.440000
too close to rear vehicle!
cuurent gap is 1.450000
too close to rear vehicle!
cuurent gap is 1.460000
too close to rear vehicle!
cuurent gap is 1.470000
too close to rear vehicle!
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.patrol
cuurent gap is 1.480000
too close to rear vehicle!
cuurent gap is 1.490000
too close to rear vehicle!
cuurent gap is 1.500000
start merging !
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 84
cuurent gap is 1.500000
merging speed 84
cuurent gap is 1.500000
merging speed 84
cuurent gap is 1.500000
merging speed 84
cuurent gap is 1.500000
merging speed 85
cuurent gap is 1.500000
merging speed 85
cuurent gap is 1.500000
merging speed 84
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
cuurent gap is 1.500000
merging speed 83
merge finished
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.volkswagen.t2
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.tt
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.volkswagen.t2
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.micra
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.a2
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.micra
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.micra
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.bmw.grandtourer
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.jeep.wrangler_rubicon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.audi.tt
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.jeep.wrangler_rubicon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.nissan.micra
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.jeep.wrangler_rubicon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.seat.leon
sumo vtype DEFAULT_VEHTYPE not found in carla. The following blueprint will be used: vehicle.chevrolet.impala
Simulation is Over
***********Planning Evaluation Module***********
Planned distance: 1343.6927490234375
Real distance: 1341.3471999624744
Cav world ticks elapsed: 0
Cav World time in seconds: 0.0
Calculated success threshold (with 10km/h or 2.77m/s): 483.7290026652354
Success or not:  Yes
/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/evaluations/evaluate_manager.py:129: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  plt.show(block=False)
Traceback (most recent call last):
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/platoon_joining_2lanefree_cosim.py", line 76, in run_scenario
    platoon.run_step()
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/core/application/platooning/platooning_manager.py", line 230, in run_step
    self.leader_target_speed)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/core/common/vehicle_manager.py", line 215, in run_step
    target_speed, target_pos = self.agent.run_step(target_speed)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/core/application/platooning/platoon_behavior_agent.py", line 212, in run_step
    return super().run_step(target_speed, collision_detector_enabled)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/core/plan/behavior_agent.py", line 796, in run_step
    sys.exit(0)
SystemExit: 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/test/anaconda3/envs/opencda/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/test/anaconda3/envs/opencda/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 322, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 136, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/home/test/.vscode/extensions/ms-python.debugpy-2024.2.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda.py", line 75, in <module>
    main()
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda.py", line 70, in main
    scenario_runner(opt, scene_dict)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/platoon_joining_2lanefree_cosim.py", line 87, in run_scenario
    eval_manager.evaluate()
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/evaluations/evaluate_manager.py", line 63, in evaluate
    self.planning_eval(log_file)
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/evaluations/evaluate_manager.py", line 201, in planning_eval
    list(map(lambda e: math.sqrt(e[1].x * e[1].x + e[1].y * e[1].y + e[1].z * e[1].z), imu_data))[self.skip_head:],
  File "/home/test/V2X/OpenCDA/OpenCDA/opencda/scenario_testing/evaluations/evaluate_manager.py", line 91, in plot_3d
    ax1.plot(timestamp, acc_x_axis, label='Accelerometer X axis')
  File "/home/test/anaconda3/envs/opencda/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1605, in plot
    lines = [*self._get_lines(*args, data=data, **kwargs)]
  File "/home/test/anaconda3/envs/opencda/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 315, in __call__
    yield from self._plot_args(this, kwargs)
  File "/home/test/anaconda3/envs/opencda/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 501, in _plot_args
    raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (1124,) and (1126,)
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 460 (sensor.other.gnss) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 461 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 462 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 463 (sensor.other.collision) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 480 (sensor.other.gnss) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 481 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 482 (sensor.camera.rgb) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 483 (sensor.lidar.ray_cast) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 484 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 485 (sensor.other.collision) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 475 (sensor.other.gnss) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 476 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 477 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 478 (sensor.other.collision) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 470 (sensor.other.gnss) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 471 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 472 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 473 (sensor.other.collision) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 465 (sensor.other.gnss) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 466 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 467 (sensor.other.imu) 
WARNING: sensor object went out of the scope but the sensor is still alive in the simulation: Actor 468 (sensor.other.collision) 

payprays avatar Mar 08 '25 13:03 payprays

About the warnning

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

I tried to add the code in the beginning of evaluate_manager.py with the same result.

import matplotlib
matplotlib.use('Qt5Agg')

I download it to file manually.

Image

payprays avatar Mar 08 '25 13:03 payprays

Hello bro, I have the same problem as yours, have you solved it?

WinouyFeng avatar May 22 '25 06:05 WinouyFeng

It may be caused by improper destroying of sensors.

see the pr link to solve it. https://github.com/ucla-mobility/OpenCDA/pull/238#issue-2937933808

payprays avatar May 22 '25 07:05 payprays

谢谢大佬,我看你是西电的,方便进一步请教一下吗,我试了你发的那个fix版本还是出现一样的问题,折磨了我好多天了,实在没办法解决,跪求指点,谢谢谢谢。

WinouyFeng avatar May 22 '25 17:05 WinouyFeng

我fork了这个,在我的fuzz分支下改了些东西,你可以看看我的仓库,大概一个月前写的了,有些东西没啥印象了。

payprays avatar May 23 '25 01:05 payprays

ailab和毛子那边有人用这个写了个V2X的平台,这个仓库对V2X的实现比较简单粗略,你可以看看他们的 https://github.com/CAVISE/CAVISE https://github.com/CollaborativePerception/V2Xverse

payprays avatar May 23 '25 01:05 payprays

好的好的,感谢感谢!

WinouyFeng avatar May 23 '25 01:05 WinouyFeng

Thank you for solving the problem I encountered when using OpenCDA simulation test.

Jeremath avatar Aug 05 '25 12:08 Jeremath