gennav.envs package¶
Submodules¶
gennav.envs.base module¶
-
class
gennav.envs.base.Environment¶ Bases:
objectBase class for an envrionment.
An environment object should encapsulate all data processing related to a specific environment representation and should provide the ability to check for collision using this API
-
get_status(state)¶ Get whether a given state is valid within the environment.
This method needs to be implemented in the specific env implementation.
Parameters: state (gennav.utils.RobotState) – State to be checked Returns: True if state is valid otherwise False Return type: bool
-
get_traj_status(traj)¶ Get whether a given trajectory is valid within the environment.
This method needs to be implemented in the specific env implementation.
Parameters: state (gennav.utils.Trajectory) – Trajectory to be checked Returns: True if state is valid otherwise False Return type: bool
-
minimum_distance(state, *args, **kwargs)¶ Gives a list of minimum distance of each obstacle from the robot state.
This method needs to be implemented in the specific env implementation.
Parameters: - state (gennav.utils.RobotState) – The current state of the robot.
- *args – Variable length argument list.
- **kwargs – Variable length keyword arguments.
-
nearest_obstacle_distance(state, *args, **kwargs)¶ Get the distance to nearest obstacle.
This method needs to be implemented in the specific env implementation
Parameters: - state (gennav.utils.RobotState) – The current state of the robot.
- *args – Variable length argument list.
- **kwargs – Variable length keyword arguments.
-
update(*args, **kwargs)¶ Update the environment.
This method needs to be implemented in the specific env implementation.
Parameters: - *args – Variable length argument list.
- **kwargs – Arbitrary keyword arguments.
-
gennav.envs.binaryOccupancyGrid2D_env module¶
-
class
gennav.envs.binaryOccupancyGrid2D_env.BinaryOccupancyGrid2DEnv(X=10, Y=10, *args, **kwargs)¶ Bases:
gennav.envs.base.EnvironmentBase class for a Binary Occupancy Grid 2D envrionment.
Parameters: - X (unsigned int) – The number of grid cells in the x-direction
- Y (unsigned int) – the number of grid cells in the y-direction
-
check_line_segment(state1, state2)¶ Checks whether a line segment is collision free in the environent
Computes a line segment from the start point to the end point and parametrically checks if the grid cells they occupy are occupied.
Parameters: - state1 (gennav.utils.common.RobotState) – One end point
- state2 (gennav.utils.common.RobotState) – The other end point
-
compute_transforms()¶ Computes transforms between frames
Uses robot pose to compute transform between the world frame and the bot frame
-
fillOccupancy()¶ Function that fill the occupnacy grid on every update Assumptions:
- RobotPose is considered (0, 0, 0) to accomodate the laser scan, which produces ranges wrt to the bot
- The RobotPose in the occupancy grid is (X * scale_factor/2, Y * scale_factor /2, 0)
- The attribute robotPose is the real pose of the robot wrt to the world Frame,
- thus it helps us to calculate the transform for trajectory and pose validity queries
-
get_status(state)¶ Get whether a given state is valid within the environment.
Method for checking the validity of a given RobotPose in the environment.
Parameters: state (gennav.utils.RobotState) – State to be checked Returns: True if state is valid otherwise False Return type: bool
-
get_traj_status(traj)¶ Get whether a given trajectory is valid within the environment.
Method for checking the validity of a trajectory in the given environment.
Parameters: state (gennav.utils.Trajectory) – Trajectory to be checked Returns: True if state is valid otherwise False Return type: bool
-
transform(frame1, frame2, rsf1)¶ Transform robotPose from one pose to the other
Parameters: - frame1 (string) – from the frame (world, bot, map)
- frame2 (string) – to the frame (world, bot, map)
- rsf1 (gennav.utils.common.RobotState) – RobotState in frame1
Returns: RobotState in frame2
Return type:
-
update(scan, robotPose)¶ Function to update the environment :param scan: List of ang_min, ang_max, ranges :type scan: list :param robotPose: Current RobotPose :type robotPose: gennav.utils.RobotPose
-
visualise_grid()¶ Helper function to visualise grid
gennav.envs.common module¶
-
gennav.envs.common.visualize_path(traj, env)¶ Draw the path along with environment obstacles.
Parameters: - traj (gennav.utils.Trajectory) – list of points in the path as tuples.
- env (gennav.envs.Environment) – list of obtacles.
gennav.envs.polygon_env module¶
Polygon Environment Class
-
class
gennav.envs.polygon_env.PolygonEnv(buffer_dist=0.0, *args, **kwargs)¶ Bases:
gennav.envs.base.EnvironmentPolygonEnvironment Class .. attribute:: obstacles
type: list of Coordinates -
buffer_dist¶ distance passed to shapely.buffer()
Type: float
-
collision(points, obstacles)¶ A helper function that checks for Collision between the given obstacles and a set of points using shapely
Parameters: - points (list of coordinates (x, y)) –
- obstacles (list of list of cooridnates(x,y)) –
Returns: True if collision is detected
Return type: bool
-
get_status(state)¶ Get whether a given state is valid within the given environment
Checks whether the position given is not within any obstacle
Parameters: state (gennav.utils.RobotState) – State to be checked for Returns: True if the state is valid, False otherwise Return type: bool
-
get_traj_status(traj)¶ Get whether a given trajectory is valid within the given environment
Checks whether the given trajectory intersects with any obstacles or not
Parameters: traj (gennav.utils.common.Trajectory) – Trajectory to be checked for Returns: True if the trajctory is valid, False otherwise Return type: bool
-
minimum_distances(state, sort=False)¶ Function to get the minimum distance of each obstacle form the robot state
Uses shapely Point’s distance method to obtain the minimum distances
Parameters: - state (gennav.utils.RobotState) – present state of the robot
- sort (bool default = False) – returns the distances in ascending form when set true
- Returns :
- min_dist (list) : list containing minimum distances(float) of each obstacle from the robot state
-
nearest_obstacle_distance(state, return_object=True)¶ Function to get the nearest obstacle to the robot state
Uses shapely Point’s distance method to obtain the distance
Parameters: - state (gennav.utils.RobotState) – present state of the robot
- return_object (bool default=True) – returns nearest obstacle also
Returns: distance to the nearest obstacle obj (shapely.Polygon) : nearest obstacle
Return type: dist (float)
-
update(obstacles)¶ Function call to update environment variables
Updates the obstacles in the environment
Parameters: obstacles – list of list of points (x, y) that make an obstacle Example of argument: [ [(1, 1), (2, 1), (2, 2), (1, 2)], [(3, 4), (3.3, 4), (3.3, 4.2), (3, 4.2)] ] The above list contains a list of points that constitute an obstacle. There can be arbitrary number of obstacles, which each obstacle having an arbitrary number of points
-
gennav.envs.scan_env module¶
-
class
gennav.envs.scan_env.ScanEnv(scan_=None, bot_size=0.4, ang_range=[0, 6.283185307179586], viz=False, *args, **kwargs)¶ Bases:
gennav.envs.base.Environment-
get_status(state)¶ Get whether a given state is valid within the environment.
Checks whether position of given state is clear of all points in the scan by a certain threshold given as the robot size.
Parameters: state (gennav.utils.RoboState) – State to be checked Returns: True if state is valid otherwise False Return type: bool
-
get_traj_status(traj)¶ Get whether a given trajectory is valid within the environment.
Checks if the path is clear of all obstacles by a certain threshold given as the robot size.
Parameters: state (gennav.utils.Trajectory) – Trajectory to be checked Returns: True if state is valid otherwise False Return type: bool
-
scan¶
-
update(data)¶ Update the environment.
Updates internal representation with new scan data.
Parameters: data – The updated scan data.
-