Sensors

Sensor

class gym_collision_avoidance.envs.sensors.Sensor.Sensor

Each Agent has a list of these, which compute a measurement about the environment/other Agents

sense(agents, agent_index, top_down_map)

Dummy method to be re-implemented by each Sensor subclass

set_args(args)

Update several class attributes (in dict format) of the Sensor object

Parameters:args (dict) – {‘arg_name1’: new_value1, …} sets self.arg_name1 = new_value1, etc.

OtherAgentsStatesSensor

class gym_collision_avoidance.envs.sensors.OtherAgentsStatesSensor.OtherAgentsStatesSensor(max_num_other_agents_observed=3, agent_sorting_method='closest_first')

A dense matrix of relative states of other agents (e.g., their positions, vel, radii)

Parameters:
  • max_num_other_agents_observed – (int) only can observe up to this many agents (the closest ones)
  • agent_sorting_method – (str) definition of closeness in words (one of [‘closest_last’, ‘closest_first’, ‘time_to_impact’])
get_clipped_sorted_inds(sorting_criteria)

Determine the closest N agents using the desired sorting criteria

Parameters:sorting_criteria (str) – how to sort the list of agents (one of [‘closest_last’, ‘closest_first’, ‘time_to_impact’]). See journal paper.
Returns:
indices of the “closest” max_num_other_agents_observed
agents sorted by “closeness” (“close” defined by sorting criteria),
Return type:clipped_sorted_inds (list)
sense(agents, agent_index, top_down_map=None)

Go through each agent in the environment, and compute its relative position, vel, etc. and put into an array

This is a denser measurement of other agents’ states vs. a LaserScan or OccupancyGrid

Parameters:
  • agents (list) – all Agent in the environment
  • agent_index (int) – index of this agent (the one with this sensor) in agents
  • top_down_map (2D np array) – binary image with 0 if that pixel is free space, 1 if occupied (not used!)
Returns:

(max_num_other_agents_observed x 7) the 7 states about each other agent, [p_parallel_ego_frame, p_orthog_ego_frame, v_parallel_ego_frame, v_orthog_ego_frame, other_agent.radius, combined_radius, dist_2_other]

Return type:

other_agents_states (np array)

LaserScanSensor

class gym_collision_avoidance.envs.sensors.LaserScanSensor.LaserScanSensor

2D LaserScan based on map of the environment (containing static objects and other agents)

Currently the laserscan parameters are mostly hard-coded…

Parameters:
  • num_beams – (int) how many beams/rays should be in the laserscan
  • num_to_store – (int) how many past laserscans to stack into one measurement
  • range_resolution – (float) radians between each beam
  • max_range – (float) largest value per beam (meters)
  • min_range – (float) smallest value per beam (meters)
  • min_angle – (float) relative to agent’s current heading, angle of the first beam (radians)
  • max_angle – (float) relative to agent’s current heading, angle of the last beam (radians)
  • angles – (np array) linearly spaced array of angles, ranging from min_angle to max_angle, containing num_beams
  • ranges – (np array) linearly spaced array of ranges, ranging from min_range to max_range, spaced by range_resolution
sense(agents, agent_index, top_down_map)

Use top_down_map to ray-trace for obstacles, with sensor located at agents[agent_index] center.

Parameters:
  • agents (list) – all Agent in the environment
  • agent_index (int) – index of this agent (the one with this sensor) in agents
  • top_down_map (2D np array) – binary image with 0 if that pixel is free space, 1 if occupied
Returns:

(num_to_store x num_beams) stacked history of laserscans, where each entry is a range in meters of the nearest obstacle at that angle

Return type:

measurement_history (np array)

OccupancyGridSensor

class gym_collision_avoidance.envs.sensors.OccupancyGridSensor.OccupancyGridSensor

OccupancyGrid based on map of the environment (containing static objects and other agents)

Currently the grid parameters are mostly hard-coded…

Parameters:
  • x_width – (float or int) meters of x dimension in returned gridmap (-x_width/2, +x_width/2) from agent’s center
  • x_width – (float or int) meters of y dimension in returned gridmap (-y_width/2, +y_width/2) from agent’s center
resize(og_map)

Currently just copies the gridmap… not sure why this exists.

sense(agents, agent_index, top_down_map)

Use the full top_down_map to compute a smaller occupancy grid centered around agents[agent_index]’s center.

Parameters:
  • agents (list) – all Agent in the environment
  • agent_index (int) – index of this agent (the one with this sensor) in agents
  • top_down_map (2D np array) – binary image with 0 if that pixel is free space, 1 if occupied
Returns:

(self.y_width/top_down_map.grid_cell_size x self.x_width/top_down_map.grid_cell_size)

binary 2d array where 0 is free space, 1 is occupied, centered around agent

Return type:

resized_og_map (np array)