Open sah-huawei opened 2 years ago
Note that computing the lane_relative_heading
for every vehicle is potentially costly in terms of step time (because it requires computing the lane vector at each vehicle's offset), so it should be cached so as to not do it more than once per vehicle per step. (If using the LocalTrafficProvider
, this is already computed each step anyway, but we can make the cache more accessible.)
As this seems to be the trend for inputs in many of the ML papers we're seeing these days (so-called "vector representations" of the spatial scene from an egocentric perspective), I propose we add the following to our standard Observations:
To the
VehicleObservation
andEgoVehicleObservation
classes, I propose we add:lane_relative_heading
- which is the result of applyingmin_angles_difference_signed()
to the vehicle's and lane's local headings. (i.e., it's the difference between the vehicle's current heading and the way it's supposed to be going at this point in the lane, if it were centered in the lane.)Then, in the
Observation
class, I propose we change the type forneighborhood_vehicle_states
to beOptional[Dict[str, Tuple[VehicleObservation, RelativeObservation]]]
. TheDict
here would be keyed onvehicle_id
. The new typeRelativeObservation
could look like:Note that
relative_bearing
is redundant and may not be needed (as it can be computed frombearing
andheading
) but this seems to be the most useful info here, so we might as well compute it. (... especially if we also consider keeping track of, and reporting, the rate-of-change of therelative_bearing
over a time window, which is something very useful to avoiding collisions!)We may also consider adding other fields to
RelativeObservation
includingrelative_speed
relative_acceleration
(or vectorized versions of these) and evenestimated_time_to_contact
(although computing this one requires making several assumptions that might be hard to justify/explain).If we want flexibility (for example, if the overhead is too high), the
NeighborhoodVehicles
class inagent_interface.py
could be augmented to add a boolean flaginclude_relative_info
which, whenTrue
, would include theRelativeObservation
objects in the output of the sensor.