klampt.vis.glrobotprogram module

Defines GLWorldPlugin and GLSimulationPlugin, which may be useful as base classes for your own plugins.

class klampt.vis.glrobotprogram.GLWorldPlugin(world)[source]

Bases: klampt.vis.glinterface.GLPluginInterface

A program that draws a WorldModel. This is a pretty bare plugin class, and users will want to override the GLPluginInterface methods to provide any reasonable functionality.

world

a world instance provided on construction. All elements in the world must be instantiated already.

Type

WorldModel

collider

used for the click_world helper.

Type

WorldCollider

Args: world (WorldModel): the world to draw

display()[source]
click_world(x, y, want_points=False)[source]

Helper: returns a list of objects sorted in order of increasing distance. This will be useful for handling mouse_click events.

Parameters
  • x,y (int) – the screen coordinates of a point being clicked

  • want_points (bool, optional) – if true, the return list contains the point of contact.

Returns

If want_points=False, a list of world objects.

If want_points=True, a list of (world object, point) pairs

Return type

(list)

class klampt.vis.glrobotprogram.GLSimulationPlugin(world)[source]

Bases: klampt.vis.glrobotprogram.GLWorldPlugin

A program that runs a simulation given a world.

sim

the simulator that this plugin will be using

Type

SimpleSimulator

simulate

set this to True to start simulating.

Type

bool

dt

the timestep for each idle call.

Type

float

drawContacts

set this to True to draw contact points

Type

bool

drawSensors

set this to True to draw sensors

Type

bool

saveScreenshots

set this to True if frames should be saved to disk.

Type

bool

verbose

set to 1 if you wish to get printouts of the event loop

Type

int, optional

Subclasses should overload self.control_loop() and put whatever control loop you desire inside. Note: in this loop you should interact with self.sim.controller(0), not self.world.robot(0). self.world is simply a model and does not have a direct relation to the simulation.

Args: world (WorldModel): the world to simulate

initialize()[source]

Called by backend after the GL context is created but before the event loop starts.

display()[source]

Override this to do custom drawing

control_loop()[source]

Overload this to perform custom control handling.

sim_step(dt=None)[source]

Advance the simulation and update the GUI

idle()[source]
mousefunc(button, state, x, y)[source]
motionfunc(x, y, dx, dy)[source]