gennav.utils package

Submodules

gennav.utils.common module

class gennav.utils.common.Node(**data)

Bases: object

Node class used in trees and graph representations.

Parameters:data (dict) – Arbitrary keyword arguments (**kwargs).
classmethod from_coordinates(coordinates)

Create Node from coordinates.

Parameters:coordinates (gennav.utils.geometry.Point) – Point representing coordinates.
Returns:state with the required conversion to Node.
Return type:gennav.utils.common.Node
classmethod from_orientation(orientation_rpy)

Create Node from orientation (type of arg: OrientationRPY).

Parameters:orientation_rpy (gennav.utils.geometry.OrientationRPY) – OrientationRPY representing the roll, pitch and yaw.
Returns:state with the required conversion to Node.
Return type:gennav.utils.common.Node
class gennav.utils.common.RobotState(position=utils.geometry.Point(0, 0, 0), orientation=utils.geometry.OrientaionRPY(0, 0, 0), velocity=gennav.utils.common.Velocity(linear=utils.common.Vector3D(0, 0, 0), angular=utils.common.Vector3D(0, 0, 0)))

Bases: object

Class for representing the robot state

Parameters:
  • position – class utils.geometry.Point (default = utils.geometry.Point)
  • orientation – class utils.geometry.OrientationRPY (default = utils.geometry.OrientationRPY)
  • velocity – class utils.common.Velocity (default = utils.common.Velocity)
class gennav.utils.common.Trajectory(path, timestamps=None)

Bases: object

Representation of robot trajectory as a series of robot states.

Parameters:
  • path (list of gennav.utils.RobotState) – series of robot states
  • timestamps (list of datetime.datetime, optional) – timstamps for each state
class gennav.utils.common.Velocity(linear=utils.geometry.Vector3D(0, 0, 0), angular=utils.geometry.Vector3D(0, 0, 0))

Bases: object

Class for representing Velocity

Parameters:
  • linear – class utils.geometry.Vector3D (default = utils.geometry.Vector3D)
  • angular – class utils.geometry.Vector3D (default = utils.geometry.Vector3D)

gennav.utils.custom_exceptions module

exception gennav.utils.custom_exceptions.InvalidGoalState(goal, message='Goal state is invalid.')

Bases: Exception

Exception raised when ending/goal state is invalid.

Parameters:end (gennav.utils.RobotState) – Goal state
exception gennav.utils.custom_exceptions.InvalidStartState(start, message='Start state is invalid.')

Bases: Exception

Exception raised when starting state is invalid.

Parameters:start (gennav.utils.RobotState) – Start state
exception gennav.utils.custom_exceptions.PathNotFound(path, message='Path could not be found.')

Bases: Exception

Exception raised when path is not found.

Parameters:path (gennav.utils.Trajectory) – Path found by planner.
exception gennav.utils.custom_exceptions.SamplingFailed(sample, message='Sampler failed to return valid state.')

Bases: Exception

Exception raised when the Sampler fails to return a valid state.

Parameters:sample (gennav.utils.RobotState) – state returned by the sampler

gennav.utils.geometry module

Various common geometric constructs.

class gennav.utils.geometry.OrientationRPY(roll=0, pitch=0, yaw=0)

Bases: object

Class for representing Orientation in terms if Roll, Pitch, Yaw :param roll: rotation about x-axis (default = 0) :param pitch: rotation about y-axis (default = 0) :param yaw: rotation about z-axis (default = 0)

class gennav.utils.geometry.PathComplete(states)

Bases: object

Class that can be used to represent path which contains RobotStates as waypoints :param states = class utils.geometry.RobotState[]: :type states = class utils.geometry.RobotState[]: a list of utils.geometry.RobotState

Note

For representing path using only Points, use utils.geometry.PointPath

class gennav.utils.geometry.Point(x=0, y=0, z=0)

Bases: object

A Basic Point class :param x: x-coordinate of the point (default = 0) :param y: y-coordinate of the point (default = 0) :param z: z-coordinate of the point (default = 0)

class gennav.utils.geometry.PointPath(points)

Bases: object

A class for storing Path :param points = class utils.geometry.Point[]: :type points = class utils.geometry.Point[]: a list of utils.geometry.Point

Note

This class does not take into consideration the orientation at each point For such a class use utils.geometry.Path

class gennav.utils.geometry.Quaternion(x=0, y=0, z=0, w=1)

Bases: object

Class for Quaternions Args :

x : x-component of quaternion (default = 0) y : y-component of quaternion (default = 0) z : z-component of quaternion (default = 0) w : w-component of quaternion (default = 1)
class gennav.utils.geometry.Vector3D(x=0, y=0, z=0)

Bases: object

Class for representing a 3 Dimensional Vector :param x: x-component (default = 0) :param y: y-component (default = 0) :param z: z-component (default = 0)

Note

This class contains additional methods wrt to the utils.geometry.Point Class

directionCosines()

Returns the direction cosines of the vector, i.e cos(alpha), cos(beta), cos(gamma)

magnitude()

Returns the magnitude of the vector

unit()

Returns the unit vector of the vector as a Vector3D object :returns: Unit vector of the given vector :rtype: unitVector (utils.geometry.Vector3D)

gennav.utils.geometry.compute_angle(p1, p2)

Compute angle between two points. :param p1: One of the two points :type p1: gennav.utils.geometry.Point :param p2: One of the two points :type p2: gennav.utils.geometry.Point

Returns:The computed angle in radians
Return type:float
gennav.utils.geometry.compute_distance(p1, p2)

Compute distance between two points. :param p1: One of the two points :type p1: gennav.utils.geometry.Point :param p2: One of the two points :type p2: gennav.utils.geometry.Point

Returns:The computed distance
Return type:float
gennav.utils.geometry.transform(obj, position, orientation)

Tranform geometric object (shape, line, point etc) w.r.t given position and orientation in cartesian system of coordinates. :param obj: object to be transformed. :type obj: shapely.geometry :param point: base location. :type point: gennav.utils.geometry.Point :param orientation: base roll pitch and yaw. :type orientation: gennav.utils.geometry.OrientationRPY

Returns:Transformed robot state.
Return type:gennav.utils.RoboState
gennav.utils.geometry.transform_state(state, point, orientation)

Tranform a robot state w.r.t given position and orientation in cartesian system of coordinates. :param state: state to be transformed. :type state: gennav.utils.RoboState :param point: base location. :type point: gennav.utils.geometry.Point :param orientation: base roll pitch and yaw. :type orientation: gennav.utils.geometry.OrientationRPY

Returns:Transformed robot state.
Return type:gennav.utils.RoboState
gennav.utils.geometry.transform_traj(traj, point, orientation)

Tranform a trajectory w.r.t given position and orientation in cartesian system of coordinates. :param traj: state to be transformed. :type traj: gennav.utils.Trajectory :param point: base location. :type point: gennav.utils.geometry.Point :param orientation: base roll pitch and yaw. :type orientation: gennav.utils.geometry.OrientationRPY

Returns:Transformed robot state.
Return type:gennav.utils.RoboState

gennav.utils.graph module

class gennav.utils.graph.Graph

Bases: object

Graph class used for graph based algorithms.

add_edge(node1, node2)

Adds edge connecting two nodes to the graph.

Parameters:
  • node1 (gennav.utils.RobotState) – one end of the edge.
  • node2 (gennav.utils.RobotState) – other end of the edge.
add_node(node)

Adds nodes to the graph.

Parameters:node (gennav.utils.RobotState) – to be added to the set of nodes.
calc_dist(node1, node2)

Calculates distance between two nodes.

Parameters:
  • node1 (gennav.utils.RobotState) – one end of the edge.
  • node2 (gennav.utils.RobotState) – other end of the edge.
Returns:

distance between two nodes.

Return type:

dist (float)

del_edge(node1, node2)

Deletes edge connecting two nodes to the graph.

Parameters:
  • node1 (gennav.utils.RobotState) – one end of the edge.
  • node2 (gennav.utils.RobotState) – other end of the edge.

gennav.utils.path_processing module

gennav.utils.path_processing.los_optimizer(traj, env)

Line of Sight Path Optimizer.

For each point in the path, it checks if there is a direct connection to procceeding points which does not pass through any obstacles. By joining such points, number of uneccessary points in the path are reduced.

Parameters:
  • traj (gennav.utils.Trajectory) – trajectory to optimize.
  • env – (gennav.envs.Environment): environment to optimize path in.
Returns:

Trajectory with otimized path.

If path is found to be intersecting with any obstacle and there is no lookahead optimization which avoids this, then only the path uptill the intersection is returned.

Return type:

gennav.utils.Trajectory

gennav.utils.samplers module

class gennav.utils.samplers.Sampler

Bases: object

Base classs for samplers.

class gennav.utils.samplers.UniformCircularSampler(radius, centre=utils.geometry.Point(0, 0, 0), goal=None, goal_sample_p=0)

Bases: gennav.utils.samplers.Sampler

Uniformly sample point in given circular area while sampling goal point with
a specified probability.
Parameters:
  • radius (float) – Radius of sample area
  • centre (gennav.utils.geometry.Point) – Centre of circle to sample from. Defaults to origin
  • goal (gennav.utils.RobotState) – Goal state. Defaults to None
  • goal_sample_p (float) – Probability of sampling goal. Defaults to 0
Raises:

ValueError – If goal is not specified when goal_sample_p > 0

class gennav.utils.samplers.UniformRectSampler(min_x, max_x, min_y, max_y, goal=None, goal_sample_p=0)

Bases: gennav.utils.samplers.Sampler

Uniformly sample point in given rectangular area while sampling goal point with
a specified probability.
Parameters:
  • min_x (float) – Minimum x coordinate of sample area
  • max_x (float) – Maximum x coordinate of sample area
  • min_y (float) – Minimum y coordinate of sample area
  • max_y (float) – Maximum y coordinate of sample area
  • goal (gennav.utils.RobotState) – Goal state. Defaults to None
  • goal_sample_p (float) – Probability of sampling goal. Defaults to 0
Raises:

ValueError – If goal is not specified when goal_sample_p > 0

gennav.utils.visualisation module

gennav.utils.visualisation.visualize_graph(graph, env)

Draw the graph along with environment obstacles.

Parameters:
  • graph (gennav.utils.graph Graph) – object of Graph class which stores the graph as a dict.
  • env (gennav.envs.Environment) – list of obtacles.
gennav.utils.visualisation.visualize_node(node_list, env)

Plot all the nodes and the obstacles in the environment

Parameters:
  • node_list (list) – list containing all the nodes of the type (gennav.utils.common Node)
  • env (gennav.envs.Environment) – Environment object

Module contents