sensors package¶
Overview¶
Sensors act as an interface between the environment and the vehicles intelligence modules. This module acts as a simulation of real world sensors, by taking in in formation from the vehicle and the maps module about the environment around the vehicle. The currently implemented sensors include BasicVisual, GPS and Speed. BasicVisual provides information about the objects present in the field of view of the vehicle This can be thought of as LIDAR or RADAR readings, or simply as the surroundings as seen by a driver through the windshield or the rear view mirrors. GPS provides the coordinates of the vehicle and Speed provides the speedometer reading of the vehicle. These sensor readings are used by the vehicles internal modules to localize the vehicle and to take a decision based on the inferences. To understand the effect of sensor failures/malfunctions, these sensors can be configured to provide noisy readings to the vehicle.
sensors.sensor module¶
-
class
core.lib.sensors.sensor.
BasicVisual
¶ Simulates the capability of a human visual system.
-
static
get_intersection_traffic
(car, tg)¶ Used to ‘peep and look’ at turnings. Essentially used only in right of way rules to see if there is a car coming into the intersection from another road. Refer to the implementation docs for details on how this function works, and what the dict keys mean.
Note
Currently this seems to be used at all time instants so often returns dict with keys from [1,8] or [0,7] which is probably when it is called when on turn roads. Don’t panic!!
Parameters: - car (object) – vehicle object
- tg (object) – Traffic Graph object
Returns: with keys as [1,3,5,7] and values as list of vehicle objects
Return type: dict
-
static
get_traffic_signal_state
(car)¶ Shows the traffic signals that are visible to a human driver.
Currently included in BasicVisual as driver can ‘see’ the traffic signal. Later should be included in communication module.
Parameters: car (object) – vehicle object Returns: [color, time remaining] , if there is no signal, returns [None, None] Return type: list
-
static
get_visible_cars
(car, tg)¶ Shows cars that are visible to a human driver. Similar to what a driver can see (directly or via the mirrors, side or rear).
Note
Instead of passing a car, pass only the attributes as a message or via a bus in the future.
Parameters: - car (object) – Vehicle object
- tg (object) – Traffic Graph object
Returns: with keys as [‘front’, ‘back’, ‘left’, ‘right’] and values as a list of vehicle objects
Return type: dict
-
static
-
class
core.lib.sensors.sensor.
GPS
¶ Simulates a GPS device.
-
static
get_position
(x, y)¶ Shows the GPS coordinates of vehicle.
Parameters: - x (float) – x coordinate of vehicle
- y (float) – y coordinate of vehicle
Returns: [x, y] of the vehicle
Return type: list
-
static
-
class
core.lib.sensors.sensor.
LaneCenterSensor
¶ Simulates a sensor that gives offset from the lane center.
Note
Implementation might have to change for curved roads/roadstring ds in the future.
-
static
get_lane_center_dtheta
(car)¶ Takes in the car object and returns the difference between the heading of the road/lane and the heading of the vehicle.
Parameters: car (object) – vehicle object Returns: angle in radians Return type: float
-
static
get_lane_center_dy
(car)¶ Takes in car object and returns the displacement from the lane center.
Note
Calculates distance from left edge of road and subtracts lane number * lane width.
Parameters: car (object) – vehicle object Returns: distance from center of lane Return type: float
-
static
offset_direction
(car)¶ Deprecated. When lane center was calculated using distance from center of road, this method was used to check if the car is to the left of the road center or to the right.
Note
Not using this currently.
Parameters: car (object) – car Returns: 0 or 1 or -1 Return type: int
-
static
-
class
core.lib.sensors.sensor.
PositionBasedVelocityEstimator
¶ Estimates the vehicle speed based on its position.
Note
Not implemented currently. returning the speed directly. Will be implemented a fusion of speed sensor and position based velocity estimator.
-
class
core.lib.sensors.sensor.
VehicleSpeedSensor
(car=None)¶ Simulates a speed sensor.
Note
Will be implemented with noisy version of speed and sensor fusion using GPS data.
-
car
¶ object – Vehicle object
-
read_speed
()¶ Shows the speed of vehicle.
Returns: speed Return type: float
-
-
core.lib.sensors.sensor.
get_adj_polygon_from_point
(x, y, theta, width, distance, direction, lane_width)¶ Returns a polygon with lane_width away from (x, y) along theta angle in given direction with sizes distance x width.
Parameters: - x (float) – x coordinate
- y (float) – y coordinate
- theta (float) – angle in radians
- width (float) – width of the bounding box
- distance (float) – length of the bounding box
- direction (str) – ‘left’ or ‘right’
- lane_width (float) – to check lane_width distance away = finding in the adjacent lane
Returns: shapely Polygon object
Return type: object
-
core.lib.sensors.sensor.
get_car_bounding_box
(car)¶ Returns the bounding box (not axis aligned; generic one) of the vehicle.
Parameters: car (object) – vehicle object Returns: shapely Polygon object Return type: object
-
core.lib.sensors.sensor.
get_car_bounding_box_adj
(car, lane_width, direction)¶ Returns a bounding box of the area in the adjacent lane of the vehicle determined by the input args.
Parameters: - car (object) – vehicle object
- lane_width (float) –
- direction (str) – ‘left’ or ‘right’
Returns: shapely Polygon object
Return type: object
-
core.lib.sensors.sensor.
get_car_bounding_box_back
(car)¶ Returns the bounding box (not axis aligned; generic one) of the area in the back vehicle (determined by safe dist).
Parameters: car (object) – vehicle object Returns: shapely Polygon object Return type: object
-
core.lib.sensors.sensor.
get_car_bounding_box_front
(car)¶ Returns the bounding box (not axis aligned; generic one) of the area in the front vehicle (determined by safe dist).
Parameters: car (object) – vehicle object Returns: shapely Polygon object Return type: object
-
core.lib.sensors.sensor.
get_polygon_from_point
(x, y, theta, width, front_distance, back_distance)¶ Returns a polygon around a point in a given heading angle with given dimensions. Front_distance and back_distance are determined by the heading angle to figure out which one is front or back.
Parameters: - x (float) – x coordinate
- y (float) – y coordinate
- theta (float) – heading angle in radians
- width (float) – width of the bounding box
- front_distance (float) – distance from the point to the end of the front of the box (ahead of the point)
- back_distance (float) – distance from the point to the end of the back of the box (behind the point)
Returns: shapely Polygon object
Return type: object
sensors.sensor_factory module¶
-
class
core.lib.sensors.sensor_factory.
SensorFactory
¶ Factory class to build sensors of various type.
-
static
build_sensor
(type)¶ Parameters: type (str) – should be a valid sensor type among the following implemented Returns: returns an instantiation of the mentioned sensor Return type: object Note
Currently only includes the following sensors.
- ‘gps’
- ‘lane_center’
- ‘speed’
- ‘basic_visual’
-
static