huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
956 stars 190 forks source link

[Bug Report] Noisy warning "WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor..."appears in random simulation #1996

Closed qianyi-sun closed 1 year ago

qianyi-sun commented 1 year ago

High Level Description

When running simulation with Argoverse scenarios, during the simulation in some of the scenarios, there's noisy warning appears such as the following, example scenario and corresponding data is attached. scenario_pack.zip

Version

up to date with master branch

Steps to reproduce the bug

Unzip the attached file, modify the scenario path in the scenario.py and start the simulation by scl run command

System info

No response

Error logs and screenshots

04:12:07 (.venv) root@Patrick-WS driving-smarts-2.competition-scenarios ±|master|→ scl run --envision ~/SMARTS/examples/control/chase_via_points.py /root/driving-smarts-2.competition-scenarios/t3/training/ff239c9d-e4ff-4acc-bad5-bd55648c212e_agents_1/
tcgetpgrp failed: Not a tty
/root/SMARTS/.venv/lib/python3.8/site-packages/gymnasium/spaces/box.py:129: UserWarning: WARN: Box bound precision lowered by casting to float32
  gym.logger.warn(f"Box bound precision lowered by casting to {self.dtype}")
/root/SMARTS/smarts/env/hiway_env.py:123: DeprecationWarning: agent_specs has been deprecated in favor of agent_interfaces.  Please update your code.
  warnings.warn(
Using configuration from: /root/SMARTS/smarts/engine.ini
╭────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────╮
│            Episode │     Sim T / Wall T │        Total Steps │        Steps / Sec │       Scenario Map │    Scenario Routes │     Mission (Hash) │             Scores │
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `trip_meter_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `driven_path_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `accelerometer_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `lane_position_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `waypoints_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `via_sensor-history-vehicle-47242`
│               0/10 │               8.01 │                109 │              80.13 │ ff239c9d-e4ff-4acc │                    │ -80595750520755437 │   162.74 - Agent_0 │
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `trip_meter_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `driven_path_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `accelerometer_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `lane_position_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `waypoints_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `via_sensor-history-vehicle-47242`
│               1/10 │               8.56 │                109 │              85.61 │ ff239c9d-e4ff-4acc │                    │ -80595750520755437 │   162.74 - Agent_0 │
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `trip_meter_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `driven_path_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `accelerometer_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `lane_position_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `waypoints_sensor-history-vehicle-47242`
WARNING:smarts.core.sensor_manager:Duplicate sensor attempted to add to actor `history-vehicle-47242`: `via_sensor-history-vehicle-47242`
│               2/10 │               9.01 │                109 │              90.08 │ ff239c9d-e4ff-4acc │                    │ -80595750520755437 │   162.74 - Agent_0 │

Impact (If known)

it doesnt block anything, just a bit messy in the terminal

Gamenot commented 1 year ago

What I know about this is that it occurs when there are already sensors on a vehicle and the sensor and there is an attempt to add the same sensor again.

I suppose this could be fixed by allowing multiple sensors of the same type on a vehicle and then indexing the sensor by the interface & sensor.class. I believe solving this requires addressing #1997.

qianyi-sun commented 1 year ago

We note that there is a conflict caused by using VehicleIndex.start_agent_observation followed by VehicleIndex.switch_control_to_agent

The first sensor additions are done here:

  ~/SMARTS/examples/control/chase_via_points.py(99)<module>()
-> main(
  ~/SMARTS/examples/control/chase_via_points.py(73)main()
-> observations = env.reset()
  ~/SMARTS/examples/rl/platoon/.venv/lib/python3.8/site-packages/gym/wrappers/order_enforcing.py(16)reset()
-> return self.env.reset(**kwargs)
  ~/SMARTS/smarts/env/hiway_env.py(311)reset()
-> observations = self._smarts.reset(scenario)
  ~/SMARTS/smarts/core/smarts.py(447)reset()
-> return self._reset(scenario, start_time)
  ~/SMARTS/smarts/core/smarts.py(510)_reset()
-> observations_for_ego, _, _, _ = self.step({})
  ~/SMARTS/smarts/core/smarts.py(257)step()
-> return self._step(agent_actions, time_delta_since_last_step)
  ~/SMARTS/smarts/core/smarts.py(325)_step()
-> actor_capture_manager.step(self)
  ~/SMARTS/smarts/core/id_actor_capture_manager.py(91)step()
-> vehicle: Optional[Vehicle] = self._take_existing_vehicle(
  ~/SMARTS/smarts/core/actor_capture_manager.py(113)_take_existing_vehicle()
-> vehicle = sim.switch_control_to_agent(
  ~/SMARTS/smarts/core/smarts.py(653)switch_control_to_agent()
-> self.vehicle_index.start_agent_observation(
  ~/SMARTS/smarts/core/utils/cache.py(136)wrapper()
-> return func(self, *args, **kwargs)
  ~/SMARTS/smarts/core/vehicle_index.py(375)start_agent_observation()
-> Vehicle.attach_sensors_to_vehicle(
  ~/SMARTS/smarts/core/vehicle.py(466)attach_sensors_to_vehicle()
-> sensor_manager.add_sensor_for_actor(vehicle.id, sensor_name, sensor)
> ~/SMARTS/smarts/core/sensor_manager.py(257)add_sensor_for_actor()

The second set of sensor additions are done here:

  ~/SMARTS/examples/control/chase_via_points.py(99)<module>()
-> main(
  ~/SMARTS/examples/control/chase_via_points.py(73)main()
-> observations = env.reset()
  ~/SMARTS/examples/rl/platoon/.venv/lib/python3.8/site-packages/gym/wrappers/order_enforcing.py(16)reset()
-> return self.env.reset(**kwargs)
  ~/SMARTS/smarts/env/hiway_env.py(311)reset()
-> observations = self._smarts.reset(scenario)
  ~/SMARTS/smarts/core/smarts.py(447)reset()
-> return self._reset(scenario, start_time)
  ~/SMARTS/smarts/core/smarts.py(510)_reset()
-> observations_for_ego, _, _, _ = self.step({})
  ~/SMARTS/smarts/core/smarts.py(257)step()
-> return self._step(agent_actions, time_delta_since_last_step)
  ~/SMARTS/smarts/core/smarts.py(325)_step()
-> actor_capture_manager.step(self)
  ~/SMARTS/smarts/core/id_actor_capture_manager.py(91)step()
-> vehicle: Optional[Vehicle] = self._take_existing_vehicle(
  ~/SMARTS/smarts/core/actor_capture_manager.py(113)_take_existing_vehicle()
-> vehicle = sim.switch_control_to_agent(
  ~/SMARTS/smarts/core/smarts.py(656)switch_control_to_agent()
-> vehicle = self.vehicle_index.switch_control_to_agent(
  ~/SMARTS/smarts/core/utils/cache.py(136)wrapper()
-> return func(self, *args, **kwargs)
  ~/SMARTS/smarts/core/vehicle_index.py(441)switch_control_to_agent()
-> return self._switch_control_to_agent_recreate(
  ~/SMARTS/smarts/core/vehicle_index.py(629)_switch_control_to_agent_recreate()
-> self._enfranchise_agent(
  ~/SMARTS/smarts/core/utils/cache.py(136)wrapper()
-> return func(self, *args, **kwargs)
  ~/SMARTS/smarts/core/vehicle_index.py(704)_enfranchise_agent()
-> Vehicle.attach_sensors_to_vehicle(
> ~/SMARTS/smarts/core/vehicle.py(466)attach_sensors_to_vehicle()
-> sensor_manager.add_sensor_for_actor(vehicle.id, sensor_name, sensor)
  ~/SMARTS/smarts/core/sensor_manager.py(257)add_sensor_for_actor()