Base Object Classes

class discopygal.solvers.Obstacle(data)

Bases: object

Abstract class that represents the notion of an obstacle in the scene. The obstacle has some geometry.

Parameters:

data (object) – Any metadata appended to the obstacle (could be None)

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.ObstacleDisc(location, radius, data=None)

Bases: Obstacle

Disc obstacle in the scene. Its geometry is given as a location and radius.

Parameters:
  • location (Point_2) – Disc obstacle location point, as a CGAL point

  • radius (FT) – Disc radius, as a CGAL field type

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.ObstaclePolygon(poly, data=None)

Bases: Obstacle

Polygon obstacle in the scene. Its geometry is given as a polygon.

Parameters:

poly (Polygon2) – Polygon obstacle geometry, as a CGAL polygon

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.Path(points)

Bases: object

Representation of the path a single robot does

Parameters:

points (list<PathPoint>) – points along the path

calculate_length(metric: Metric)

Return the total length of the path (sum of length between each two points)

Parameters:

metric (Metric) – The metric to use for calculating the distance between two points

Returns:

The length of the path

Return type:

FT

static path_from_points(points)

Create a Path object from points as Point_2 or Point_d (not as PathPoint) Converts each point to PathPoint (with default constructor)

Parameters:

points (list<Point_2 or Point_d>) – List of points

Returns:

Path object

Return type:

Path

class discopygal.solvers.PathCollection(paths=None)

Bases: object

Collection of the paths of all the robots in the scene. This is the objects that is returned by a solver.

Parameters:

paths (dict<Robot, Path>) – collection of paths

add_robot_path(robot, path)

Add a robot’s path to the collection

Parameters:
  • robot (Robot) – the robot we add

  • path (Path) – robot’s path

class discopygal.solvers.PathPoint(location, data=None)

Bases: object

A single point in the path (of some robot). Has a 2D location and additional data

Parameters:
  • location (Point_2) – location of point

  • data (dict) – attached data to point

class discopygal.solvers.Robot(start, end, data=None)

Bases: object

Abstact class that represents the notion of a robot in a scene. Reference point is always the origin of the given geometry.

Parameters:
  • start (Point_2) – The start location of the robot, as a CGAL point (unless stated otherwise)

  • end (Point_2) – The end location of the robot, as a CGAL point (unless stated otherwise)

  • data (object) – Any metadata appended to the robot (could be None)

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.RobotDisc(radius, start, end, data=None)

Bases: Robot

A disc robot. Its geometry is defined by its radius.

Parameters:
  • radius (FT) – The radius of the disc robot, as a CGAL field type

  • start (Point_2) – The start location of the robot, as a CGAL point

  • end (Point_2) – The end location of the robot, as a CGAL point

  • data (object) – Any metadata appended to the robot (could be None)

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.RobotPolygon(poly, start, end, data=None)

Bases: Robot

A polygonal robot. Its geometry is given as a CGAL 2D polygon.

Parameters:
  • poly (Polygon2) – The geometry of the robot, as a CGAL 2D Polygon

  • start (Point_2) – The start location of the robot, as a CGAL point

  • end (Point_2) – The end location of the robot, as a CGAL point

  • data (object) – Any metadata appended to the robot (could be None)

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.RobotRod(length, start, end, data=None)

Bases: Robot

A rod robot. Its geometry is defined by its length.

Parameters:
  • length (FT) – The length of the rod, as a CGAL field type

  • start ((Point_2, FT)) – The start location and angle of the robot, as a tuple of CGAL point and angle

  • end ((Point_2, FT)) – The end location and angle of the robot, as a tuple of CGAL point and angle

  • data (object) – Any metadata appended to the robot (could be None)

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.Scene(obstacles=None, robots=None, metadata=None)

Bases: object

The notion of “scene” in DiscoPygal, which is the setting where we conduct motion planning. A scene has robots that can move inside it, and obstacles. Also the scene can have any metadata, saved as a dictionary.

Parameters:
  • obstacles (list<Obstacle>) – list of obstacles

  • robots (list<Robot>) – list of robots

  • metadata (dict) – dict with metadata on the scene

add_obstacle(obstacle)

Add a obstacle to the scene

Parameters:

obstacle (Obstacle) – obstacle to add

add_robot(robot)

Add a robot to the scene

Parameters:

robot (Robot) – Robot to add

calc_max_robot_size()

Return the size of the largest robot in the scene For RobotDisc the is it’s diameter For RobotRod the size is it’s length

static from_dict(d)

Load json dict to object

Parameters:

d (dict) – dict representing json export

Returns:

A scene object build from the given dict

Return type:

Scene

remove_obstacle(obstacle)

Remove a obstacle from the scene

Parameters:

obstacle (Obstacle) – obstacle to remove

remove_robot(robot)

Remove a robot from the scene

Parameters:

robot (Robot) – Robot to remove

to_dict()

Convert current object to json dict

Returns:

dict representing json export

Return type:

dict

class discopygal.solvers.SceneDrawer(gui, scene)

Bases: object

Object for lookup tables and drawing scene objects

Parameters:
clear_scene()

Clear (only) the DiscoPygal scene objects from the GUI

deselect_entity(entity)
draw_obstacle(obstacle, color_select=False)

Draw a single obstacle to the scene You can affect its color by having the data of the obstacle as a dict, and having “color” value (with a string confining to gui.gui.color).

Parameters:
  • obstacle (Obstacle) – obstacle to draw

  • color_select (bool) – if true override color to select color

draw_robot(robot, color_select=False)

Draw a single robot to the scene You can affect its color by having the data of the robot as a dict, and having “color” value (with a string confining to gui.gui.color).

Parameters:
  • obstacle (Robot) – robot to draw

  • color_select (bool) – if true override color to select color

draw_scene()

Draw the scene to the selected GUI

select_entity(entity)
discopygal.solvers.load_object_from_dict(d)

Load a seriallized object from a dict In order for this to work, the dict should have a “__class__” property, which is equal to the exact python name of the class

Parameters:

d (dict) – dict describing an object

Returns:

the serialized object

Return type:

object