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:
- 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
- class discopygal.solvers.PathCollection(paths=None, metric=<class 'discopygal.solvers.metrics.Metric_Euclidean'>)
Bases:
object
Collection of the paths of all the robots in the scene. This is the objects that is returned by a solver.
- 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 pointdata (
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:
- 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:
- 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:
- 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 typestart ((
Point_2
,FT
)) – The start location and angle of the robot, as a tuple of CGAL point and angleend ((
Point_2
,FT
)) – The end location and angle of the robot, as a tuple of CGAL point and angledata (
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:
- add_obstacle(obstacle)
Add a obstacle to the scene
- Parameters:
obstacle (
Obstacle
) – obstacle 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:
- static from_file(scene_path)
Load scene from json file
- Parameters:
scene_path (
str
) – Path to scene json file- Returns:
A scene object build from the given file
- Return type:
- remove_obstacle(obstacle)
Remove a obstacle from the scene
- Parameters:
obstacle (
Obstacle
) – obstacle 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:
gui (
discopygal.gui.gui.GUI
) – the given guiscene (
Scene
) – the given scene to draw
- 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 drawcolor_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 drawcolor_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