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:
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:
- collider
used for the click_world helper.
- Type:
Args: world (WorldModel): the world to draw
- 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 (int) – the screen coordinates of a point being clicked
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:
GLWorldPlugin
A program that runs a simulation given a world.
- sim
the simulator that this plugin will be using
- Type:
- 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