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

Ensure ego observation road, lane, lane index fields are filled. #1574

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Truncated all waypoint paths returned by `FormatObs` wrapper to be of the same length. Previously, variable waypoint-path lengths caused inhomogenous shape error in numpy array.
- Fixed a bug where traffic providers would leak across instances due to the ~~(awful design decision of python)~~ reference types defaults in arguments sharing across instances.
- Fixed minor bugs causing some Waymo maps not to load properly.
- Fixed issue where the ego vehicle observation was returning `None` for the nearby `lane_id`, `lane_index`, and `road_id`. These now default to constants `off_lane`, `-1`, and `off_road` respectively.

## [0.6.1]
### Added
Expand Down
10 changes: 7 additions & 3 deletions smarts/core/sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

logger = logging.getLogger(__name__)

EGO_LANE_ID_CONSTANT = "off_lane"
EGO_ROAD_ID_CONSTANT = "off_road"
EGO_LANE_INDEX_CONSTANT = -1


class VehicleObservation(NamedTuple):
"""Perceived vehicle information."""
Expand Down Expand Up @@ -326,9 +330,9 @@ def observe(sim, agent_id, sensor_state, vehicle) -> Tuple[Observation, bool]:
if vehicle.subscribed_to_lane_position_sensor:
ego_lane_pos = vehicle.lane_position_sensor(closest_lane, vehicle)
else:
ego_lane_id = None
ego_lane_index = None
ego_road_id = None
ego_lane_id = EGO_LANE_ID_CONSTANT
ego_lane_index = EGO_LANE_INDEX_CONSTANT
ego_road_id = EGO_ROAD_ID_CONSTANT
ego_vehicle_state = vehicle.state

acceleration_params = {
Expand Down