Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Sensors mutate in observe #1997

Open
Gamenot opened this issue Apr 27, 2023 · 0 comments
Open

[Bug Report] Sensors mutate in observe #1997

Gamenot opened this issue Apr 27, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Gamenot
Copy link
Collaborator

Gamenot commented Apr 27, 2023

High Level Description

Sensors change their state in sensors.observe(...). This mutability complicates management of sensors.

Note the following that sensors observe:

return (
dict(
drivable_area_grid_map=get_camera_sensor_result(
vehicle_sensors, "drivable_area_grid_map_sensor", renderer
),
occupancy_grid_map=get_camera_sensor_result(
vehicle_sensors, "ogm_sensor", renderer
),
top_down_rgb=get_camera_sensor_result(
vehicle_sensors, "rgb_sensor", renderer
),
lidar_point_cloud=lidar,
),
updated_sensors,
)

updated_sensors = {
sensor_name: sensor
for sensor_name, sensor in vehicle_sensors.items()
if sensor.mutable and sensor.serializable
}
return (
Observation(
dt=sim_frame.last_dt,
step_count=sim_frame.step_count,
steps_completed=sensor_state.steps_completed,
elapsed_sim_time=sim_frame.elapsed_sim_time,
events=events,
ego_vehicle_state=ego_vehicle,
under_this_agent_control=agent_controls,
neighborhood_vehicle_states=neighborhood_vehicle_states,
waypoint_paths=waypoint_paths,
distance_travelled=distance_travelled,
road_waypoints=road_waypoints,
via_data=via_data,
signals=signals,
),
done,
updated_sensors,
)

Then pushes up to the SensorResolver interface:

return observations, dones, updated_sensors

Then propagates up to sensor manager observe:

observations, dones, updated_sensors = self._sensor_resolver.observe(
sim_frame,
sim_local_constants,
agent_ids,
renderer_ref,
physics_ref,
)
for actor_id, sensors in updated_sensors.items():
for sensor_name, sensor in sensors.items():
self._sensors[
SensorManager._actor_and_sensor_name_to_sensor_id(
sensor_name, actor_id
)
] = sensor
return observations, dones

Version

smarts==1.0.11

Steps to reproduce the bug

No response

System info

No response

Error logs and screenshots

No response

Impact (If known)

This complicates reusing sensors for multiple interested clients (e.g. multiple agents.)
This also means that individual sensors have to sync back to the main process when dealing with the parallel processing of sensors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant