Planning Scene Visualisers

Each simulator engines would needs a corresponding visualiser for the framework to know what to display. The simulator and visualiser are decoupled, for the purpose of benchmarking. During benchmark, one would want to disable the visualisation because the drawing (or the preparation) of visual elements would slow down the planning process. Even if the slowdown is consistent across different types of planners, it always best to have the ability to obtain quick results.

Each planner can register a visualisation function for a specific type of simulator. You can disable the visualisation of the planning problem, regardless of simulator type, with the following.

python main.py <PLANNER> <MAP> start <q_1>,...,<q_n> goal <p_1>,...,<p_n> --no-display

For example:

python main.py rrt maps/intel_lab.png start 25,25 goal 225,225 --no-display

Important

Notice that in the example above, the argument start and goal are directly provided in the prompt. This is because with the –no-display flag there won’t be any GUI for user to select the start/goal pair. Therefore, it is necessary for user to directly supply the starting and target configurations.

The following sections showcase the different classes of sbp_env.visualiser.

2D Image Space Visualiser

class sbp_env.visualiser.PygameEnvVisualiser(**kwargs)[source]

Bases: BaseEnvVisualiser

Environment Visualiser with the Pygame engine.py

draw_circle(pos, colour, radius, layer)[source]

Draw a circle (e.g. to represent a node)

Parameters
  • pos – the origin position of the circle

  • colour – the color of the circle

  • radius – the radius of the circle

  • layer – the layer to draw the circle

draw_path(node1, node2, colour=(26, 128, 178), line_modifier=1, layer=None)[source]

Draw a path that represents an edge

Parameters
  • node1 – the starting node of the edge

  • node2 – the ending node of the edge

  • colour (optional) – the color of the edge

    Default: (26, 128, 178)

  • line_modifier (optional) – modify the weight of the edge to be drawn

    Default: 1

  • layer (optional) – the layer to draw th edge

    Default: None

draw_stick_robot(node, colour1=[255, 160, 16, 128], colour2=[20, 200, 200, 128], line_modifier=2.5, layer=None)[source]

Draw a 4D stick robotic arm

Parameters
  • node – the origin of the robot arm

  • colour1 (optional) – the colour of the first link

    Default: [255, 160, 16, 128]

  • colour2 (optional) – the colour of the second link

    Default: [20, 200, 200, 128]

  • line_modifier (optional) – modify the weight of the link to be drawn

    Default: 2.5

  • layer (optional) – the layer to draw the arm

    Default: None

set_start_goal_points(start=None, goal=None, **kwargs)[source]

A function that query user for start/goal and set them accordingly.

Parameters
  • start (Optional[ndarray], optional) – the start configuration of the motion planning problem

    Default: None

  • goal (Optional[ndarray], optional) – the goal configuration of the motion planning problem

    Default: None

update_screen(update_all=False)[source]

Refresh the screen

Parameters

update_all (optional) –

Force update the screen (as oppose to limit drawing to speed up)

Default: False

visualiser_init(no_display=False)[source]

Delayed initialisation method for environment visualiser.

Parameters

no_display (bool, optional) –

Controls whether turn on the visualisation or not, defaults to False. This option is deprecated, and instead, the environment should derived directly from the base visualisation to turn off visualisation.

Default: False

class sbp_env.visualiser.PygamePlannerVisualiser(planner_instance, planner_data_pack, **kwargs)[source]

Bases: BasePlannerVisualiser

Planner Visualiser with the Pygame engine.py

Parameters
  • planner_instance (Planner) – an instance of a planner

  • planner_data_pack (PlannerDataPack) – a planner data pack that stores the implemented paint function or init function.

draw_solution_path()[source]

Method to draw solution path for planner visualiser.

init(**kwargs)[source]

The delayed initialisation method for planner visualiser.

paint()[source]

Paint method for planner visualiser.

terminates_hook()[source]

Terminates hook for planner visualiser that is executed at the end of loop.

class sbp_env.visualiser.PygameSamplerVisualiser(sampler_instance, sampler_data_pack=None, **kwargs)[source]

Bases: BaseSamplerVisualiser

Visualisation of the sampler with Pygame engine.py

Parameters
  • sampler_instance (Sampler) – an instance of a sampler

  • sampler_data_pack (Optional[SamplerDataPack], optional) –

    a sampler data pack that stores the implemented paint function or init function.

    Default: None

init(**kwargs)[source]

Abstract method, delayed initialisation method for sampler visualiser.

paint()[source]

Abstract method, paint method for sampler visualiser.

terminates_hook()[source]

Abstract method, terminates hook for sampler visualiser that is executed at the end of loop.

4D Image Space Manipulator Visualiser

The 4D manipulator visualiser uses the same sbp_env.visualiser.PygameEnvVisualiser, sbp_env.visualiser.PygamePlannerVisualiser and sbp_env.visualiser.PygameSamplerVisualiser as the 2D Image Space Visualiser to visualise the planning scene. However, it performs the necessary kinematics transformations to translates configurations \(q \in C\) to worldspace \(x \in \mathcal{W}\) with the help of the collision checker sbp_env.collisionChecker.RobotArm4dCollisionChecker.

Warning

The settings of the robot arm’s joint length is configurable from the collision checker’s construction, but has not been exposed to the commandline interface yet. See collisionChecker.RobotArm4dCollisionChecker.__init__()

3D Object-based Visualiser

class sbp_env.visualiser.KlamptEnvVisualiser(**kwargs)[source]

Bases: BaseEnvVisualiser

Environment Visualiser with the Klampt engine.py

draw_node(pos, colour=(1, 0, 0, 1), size=15, label=None)[source]

Draw a node in the klampt visualiser

Parameters
  • pos – the position of the node

  • colour (optional) – the colour of the node

    Default: (1, 0, 0, 1)

  • size (optional) – the size of the node

    Default: 15

  • label (optional) – if given, add label to the node

    Default: None

draw_path(pos1, pos2, colour=None)[source]

Draw a path (line) in the klampt visualiser

Parameters
  • pos1 – the position of the start of line

  • pos2 – the position of the end of line

  • colour (optional) – the colour of the line

    Default: None

set_start_goal_points(start=None, goal=None, **kwargs)[source]

A function that query user for start/goal and set them accordingly.

Parameters
  • start (Optional[ndarray], optional) – the start configuration of the motion planning problem

    Default: None

  • goal (Optional[ndarray], optional) – the goal configuration of the motion planning problem

    Default: None

update_screen(update_all=False)[source]

Refresh the screen

Parameters

update_all (optional) –

Force update the screen (as oppose to limit drawing to speed up)

Default: False

visualiser_init(no_display=False)[source]

Delayed initialisation method for environment visualiser.

Parameters

no_display (optional) –

Controls whether turn on the visualisation or not, defaults to False. This option is deprecated, and instead, the environment should derived directly from the base visualisation to turn off visualisation.

Default: False

class sbp_env.visualiser.KlamptPlannerVisualiser(planner_instance, planner_data_pack, **kwargs)[source]

Bases: BasePlannerVisualiser

Planner Visualiser with the Klampt engine.py

Parameters
  • planner_instance (Planner) – an instance of a planner

  • planner_data_pack (PlannerDataPack) – a planner data pack that stores the implemented paint function or init function.

init(**kwargs)[source]

The delayed initialisation method for planner visualiser.

paint(**kwargs)[source]

Paint method for planner visualiser.

terminates_hook()[source]

Terminates hook for planner visualiser that is executed at the end of loop.

class sbp_env.visualiser.KlamptSamplerVisualiser(sampler_data_pack=None, **kwargs)[source]

Bases: BaseSamplerVisualiser

Visualisation of the sampler with Klampt engine.py

Parameters

sampler_data_pack (Optional[planner_registry.SamplerDataPack]) –

init(**kwargs)[source]

Abstract method, delayed initialisation method for sampler visualiser.

paint()[source]

Abstract method, paint method for sampler visualiser.

terminates_hook()[source]

Abstract method, terminates hook for sampler visualiser that is executed at the end of loop.

Black Box Engine Visualiser

class sbp_env.visualiser.BlackBoxEnvVisualiser(**kwargs)[source]

Bases: BaseEnvVisualiser

Environment Visualiser with the Pygame engine.py