klampt.vis package

Commonly used submodules

glinterface Defines the GLPluginInterface class, which is a unified base class for plugins to the klampt.vis module.
editors Functions for visual editing.
gldraw OpenGL drawing functions for geometric primitives.
ipython Defines a Jupyter Notebook interface to Klampt.
glcommon Defines GLWidgetPlugin, GLMultiViewportProgram, and CachedGLObject, which are used by the core visualization module.
glrobotprogram Defines GLWorldPlugin and GLSimulationPlugin, which may be useful as base classes for your own plugins.

Internally used submodules

camera This module defines a basic set of 3D cameras that can be controlled by a GUI.
glinit
glprogram This module defines convenient classes for building 3D GUI programs.
glutbackend
qtbackend

Module contents

Klamp’t visualization routines. See vistemplate.py in Klampt-examples for an example of how to run this module.

OVERVIEW

The visualization module lets you draw most Klamp’t objects in a 3D world using a simple interface. It also lets you customize the GUI using Qt widgets, OpenGL drawing, and keyboard/mouse intercept routines.

Main features include:

  • Simple interface to modify the visualization
  • Simple interface to animate and render trajectories
  • Simple interface to edit certain Klamp’t objects (configurations, points, transforms)
  • Simple interface to drawing text and text labels, and drawing plots
  • Multi-window, multi-viewport support
  • Unified interface to PyQt and GLUT (with loss of resource editing functionality under GLUT)
  • Automatic camera setup

The resource editing functionality in the klampt.io.resource module (based on klampt.vis.editors) use this module as well.

There are two primary modes of running the visualization: multi-threaded and single-threaded.

  • Multi-threaded mode pops up a window using show(), and the caller can then continue to interact with the vis module. IMPORTANT: multi-threaded mode is only supported on some systems (Linux, Windows using Qt). Due to weird OpenGL and Qt behavior in multi-threaded programs, if you are using multithreaded mode, you should only interact with OpenGL and the visualization using the methods in this module.
  • Single-threaded mode blocks the calling thread using loop(). To interact with the scene, the caller will provide callbacks that can modify the visualization world, pop up windows etc. Single-threaded mode is the most compatible, and is the only mode that works with GLUT and Mac OS.

There are also some convenience functions that will work in both modes, such as run(), spin(), and dialog().

The biggest drawback of single-threaded operation is that you can only start blocking dialogs at the outer- most level, not inside loop(). So if you have a GUI that’s running in real-time, in a multi-threaded visualization your code can pop up a dialog (like an editor) and the continue running with the returned value. There are some workarounds in single-thread mode (providing a callback to the dialog function) but these are not nearly as convenient.

It is possible to start in single-threaded mode and convert to multi-threaded, but the converse is not possible.

To set up and modify the visualization scene, there are three primary ways to do so:

  • Default scene manager. You can use the scene manager to add items to the visualization world and then customize them using the vis.X routines in this module (like add, setColor, animate, etc). See Python/demos/vistemplate.py for more information. These just mirror the methods in VisualizationPlugin, which is how the default scene manager is implemented.
  • Custom GLPluginInterface. The user creates a subclass of GLPluginInterface and performs all the necessary OpenGL drawing / interaction inside its hooks. In this case, you will call vis.setPlugin(plugin) to override the default visualization behavior before creating your window. See Python/demos/visplugin.py for more information.
  • Hybrid visualization. A GLPluginInterface subclass is created to add functionality on top of default the visualization world. To augment the default scene manager, call vis.pushPlugin(plugin). Another option for hybrid visualization is to subclass the vis.VisualizationPlugin class, and selectively augment / override the default functionality.

INSTRUCTIONS

  • To add things to the default visualization: Call the VisualizationPlugin aliases (add, animate, setColor, etc)

  • To show the visualization and quit when the user closes the window:

    vis.run()
    
  • To show the visualization and return when the user closes the window:

    vis.dialog()
    ... do stuff afterwards ...
    vis.kill()
    
  • To show the visualization and run a script alongside it until the user closes the window (multithreaded mode):

    vis.show()
    while vis.shown():
        vis.lock()
        ... do stuff ...
        [to exit the loop call vis.show(False)]
        vis.unlock()
        time.sleep(dt)
    ... do stuff afterwards ...
    vis.kill()
    
  • To show the visualization and run python commands until the user closes the window (single-threaded mode):

    def callback():
        ... do stuff ...
        [to exit the loop manually call vis.show(False)]
    vis.loop(setup=vis.show,callback=callback)
    vis.kill()
    
  • To run a window with a custom plugin (GLPluginInterface) and terminate on closure:

    vis.run(plugin)
    
  • To show a dialog or parallel window:

    vis.setPlugin(plugin)
    ... then call
    vis.dialog()
    ... or
    vis.show()
    ... do stuff afterwards ...
    vis.kill()
    
  • To add a GLPluginInterface that just customizes a few things on top of the default visualization:

    vis.pushPlugin(plugin)
    vis.dialog()
    vis.popPlugin()
    
  • To run plugins side-by-side in the same window:

    vis.setPlugin(plugin1)
    vis.addPlugin(plugin2)  #this creates a new split-screen
    vis.dialog()
    ... or
    vis.show()
    ... do stuff afterwards ...
    vis.kill()
    
  • To run a custom Qt window or dialog containing a visualization window:

    vis.setPlugin([desired plugin or None for visualization])
    def makeMyUI(qtglwidget):
        return MyQtMainWindow(qtglwidget)
    vis.customUI(makeMyUI)
    vis.dialog()
    ... or
    vis.show()
    ... do stuff afterwards ...
    vis.kill()
    
  • To launch a second window after the first is closed: just call whatever you want again. Note: if show was previously called with a plugin and you wish to revert to the default visualization, you should call setPlugin(None) first to restore the default.

  • To create a separate window with a given plugin:

    w1 = vis.createWindow("Window 1")  #w1=0
    show()
    w2 = vis.createWindow("Window 2")  #w2=1
    vis.setPlugin(plugin)
    vis.dialog()
    #to restore commands to the original window
    vis.setWindow(w1)
    while vis.shown():
        ...
    vis.kill()
    

Note: in multithreaded mode, when changing the data shown by the window (e.g., modifying the configurations of robots in a WorldModel) you must call vis.lock() before accessing the data and then call vis.unlock() afterwards.

MAIN INTERFACE

  • def createWindow(title): creates a new visualization window and returns an integer identifier.

  • def setWindow(id): sets the active window for all subsequent calls. ID 0 is the default visualization window.

  • def getWindow(): gets the active window ID.

  • def setWindowTitle(title): sets the title of the visualization window.

  • def getWindowTitle(): returns the title of the visualization window

  • def setPlugin(plugin=None): sets the current plugin (a GLPluginInterface instance). This plugin will now capture input from the visualization and can override any of the default behavior of the visualizer. Set plugin=None if you want to return to the default visualization.

  • def addPlugin(plugin): adds a second OpenGL viewport governed by the given plugin (a GLPluginInterface instance).

  • def run([plugin]): pops up a dialog and then kills the program afterwards.

  • def kill(): kills all previously launched visualizations and terminates the visualization thread. Afterwards, you may not be able to start new windows. Call this to cleanly quit.

  • def multithreaded(): returns true if multithreading is available.

  • def loop(setup=None,callback=None,cleanup=None): Runs the visualization thread inline with the main thread. The setup() function is called at the start, the callback() function is run every time the event thread is idle, and the cleanup() function is called on termination.

    NOTE FOR MAC USERS: having the GUI in a separate thread is not supported on Mac, so the loop function must be used rather than show/spin.

    NOTE FOR GLUT USERS: this may only be run once.

  • def dialog(): pops up a dialog box (does not return to calling thread until closed).

  • def dialogInLoop(callback): for use inside loop(). Pops up a dialog box window, and returns immediately to calling thread. The callback function has signature callback(okPressed), where okPressed is True if the user pressed the OK button, and False if Cancel or the close box was clicked.

  • def show(hidden=False): shows/hides a visualization window. If not called from the visualization loop, a new visualization thread is run in parallel with the calling script.

  • def spin(duration): shows the visualization window for the desired amount of time before returning, or until the user closes the window.

  • def shown(): returns true if the window is shown.

  • def lock(): locks the visualization world for editing. The visualization will be paused until unlock() is called.

  • def unlock(): unlocks the visualization world. Must only be called once after every lock().

  • def customUI(make_func): launches a user-defined UI window by calling make_func(gl_backend) in the visualization thread. This can be used to build custom editors and windows that are compatible with other visualization functionality. Here gl_backend is an instance of _GLBackend instantiated for the current plugin, and make_func returns a QDialog for dialog() constructed windows, or QMainWindow (or similar Qt object) for show() constructed windows.

  • def getViewport(): Returns the currently active viewport.

The following VisualizationPlugin methods are also added to the klampt.vis namespace and operate on the default plugin. If you are calling these methods from an external loop (as opposed to inside a plugin) be sure to lock/unlock the visualization before/after calling these methods.

  • def add(name,item,keepAppearance=False): adds an item to the visualization. name is a unique identifier. If an item with the same name already exists, it will no longer be shown. If keepAppearance=True, then the prior item’s appearance will be kept, if a prior item exists.
  • def clear(): clears the visualization world.
  • def listItems(): prints out all names of visualization objects
  • def listItems(name): prints out all names of visualization objects under the given name
  • def dirty(item_name=’all’): marks the given item as dirty and recreates the OpenGL display lists. You may need to call this if you modify an item’s geometry, for example.
  • def remove(name): removes an item from the visualization.
  • def setItemConfig(name,vector): sets the configuration of a named item.
  • def getItemConfig(name): returns the configuration of a named item.
  • def hide(name,hidden=True): hides/unhides an item. The item is not removed, it just becomes invisible.
  • def edit(name,doedit=True): turns on/off visual editing of some item. Only points, transforms, coordinate.Point’s, coordinate.Transform’s, coordinate.Frame’s, robots, and objects are currently accepted.
  • def hideLabel(name,hidden=True): hides/unhides an item’s text label.
  • def setAppearance(name,appearance): changes the Appearance of an item.
  • def revertAppearance(name): restores the Appearance of an item
  • def setAttribute(name,attribute,value): sets an attribute of the appearance of an item.
  • def setColor(name,r,g,b,a=1.0): changes the color of an item.
  • def setDrawFunc(name,func): sets a custom OpenGL drawing function for an item.
  • def animate(name,animation,speed=1.0,endBehavior=’loop’): Sends an animation to the object. May be a Trajectory or a list of configurations. Works with points, so3 elements, se3 elements, rigid objects, or robots.
  • def pauseAnimation(paused=True): Turns on/off animation.
  • def stepAnimation(amount): Moves forward the animation time by the given amount in seconds
  • def animationTime(newtime=None): Gets/sets the current animation time
  • def addText(name,text,position=None): adds text to the visualizer.
  • def clearText(): clears all previously added text.
  • def addPlot(name): creates a new empty plot.
  • def addPlotItem(name,itemname): adds a visualization item to a plot.
  • def logPlot(name,itemname,value): logs a custom visualization item to a plot
  • def logPlotEvent(name,eventname,color=None): logs an event on the plot.
  • def hidePlotItem(name,itemname,hidden=True): hides an item in the plot.
  • def setPlotDuration(name,time): sets the plot duration.
  • def setPlotRange(name,vmin,vmax): sets the y range of a plot.
  • def setPlotPosition(name,x,y): sets the upper left position of the plot on the screen.
  • def setPlotSize(name,w,h): sets the width and height of the plot.
  • def savePlot(name,fn): saves a plot to a CSV (extension .csv) or Trajectory (extension .traj) file.
  • def autoFitCamera(scale=1.0): Automatically fits the camera to all objects in the visualization. A scale > 1 magnifies the camera zoom.

Utility function:

  • def autoFitViewport(viewport,objects): Automatically fits the viewport’s camera to see all the given objects.

NAMING CONVENTION

The world, if one exists, should be given the name ‘world’. Configurations and paths are drawn with reference to the first robot in the world.

All items that refer to a name (except add) can either be given a top level item name (a string) or a sub-item (a sequence of strings, given a path from the root to the leaf). For example, if you’ve added a RobotWorld under the name ‘world’ containing a robot called ‘myRobot’, then setColor((‘world’,’myRobot’),0,1,0) will turn the robot green. If ‘link5’ is the robot’s 5th link, then setColor((‘world’,’myRobot’,’link5’),0,0,1) will turn the 5th link blue.

class klampt.vis.visualization.MyQThread(func, *args)[source]

Bases: PyQt5.QtCore.QThread

run()[source]
class klampt.vis.visualization.VisAppearance(item, name=None)[source]
clearDisplayLists()[source]
destroy()[source]
draw(world=None)[source]

Draws the specified item in the specified world. If name is given and text_hidden != False, then the name of the item is shown.

drawText(text, point)[source]

Draws the given text at the given point

getBounds()[source]

Returns a bounding box (bmin,bmax) or None if it can’t be found

getSubItem(path)[source]
make_editor(world=None)[source]
markChanged()[source]
remove_editor()[source]
setItem(item)[source]
swapDrawConfig()[source]

Given self.drawConfig!=None, swaps out the item’s curren configuration with self.drawConfig. Used for animations

updateAnimation(t)[source]

Updates the configuration, if it’s being animated

updateTime(t)[source]

Updates in real time

update_editor(item_to_editor=False)[source]
class klampt.vis.visualization.VisPlot[source]
addEvent(name, t, color=None)[source]
autoRange()[source]
beginSave(fn)[source]
discard(tmin)[source]
dumpAll()[source]
dumpCurrent()[source]
endSave()[source]
render(window, x, y, w, h, duration, vmin=None, vmax=None)[source]
update(t, duration, compressThreshold)[source]
class klampt.vis.visualization.VisPlotItem(itemname, linkitem)[source]
customUpdate(item, t, v)[source]
discard(tstart)[source]
update(t)[source]
updateTrace(i, t, v)[source]
class klampt.vis.visualization.VisualizationPlugin[source]

Bases: klampt.vis.glcommon.GLWidgetPlugin

add(name, item, keepAppearance=False)[source]

Adds a named item to the visualization world. If the item already exists, the appearance information will be reinitialized if keepAppearance=False (default) or be kept if keepAppearance=True.

addLabel(text, point, color)[source]
addPlotItem(plotname, itemname)[source]
addText(name, text, pos=None)[source]
animate(name, animation, speed=1.0, endBehavior='loop')[source]
animationTime(newtime=None)[source]
autoFitCamera(scale=1.0)[source]
clear()[source]

Clears the visualization world

clearText()[source]

Clears all text in the visualization.

closefunc()[source]
dirty(item_name='all')[source]

Marks an item or everything as dirty, forcing a deep redraw.

display()[source]
display_screen()[source]
edit(name, doedit=True)[source]
eventfunc(type, args='')[source]
getItem(item_name)[source]

Returns an VisAppearance according to the given name or path

getItemConfig(name)[source]
hide(name, hidden=True)[source]
hideLabel(name, hidden=True)[source]
hidePlotItem(plotname, itemname, hidden=True)[source]
idle()[source]
initialize()[source]
keyboardfunc(c, x, y)[source]
keyboardupfunc(c, x, y)[source]
listItems(root=None, indent=0)[source]

Prints out all items in the visualization world.

logPlot(plotname, itemname, value)[source]
logPlotEvent(plotname, eventname, color)[source]
motionfunc(x, y, dx, dy)[source]
mousefunc(button, state, x, y)[source]
pauseAnimation(paused=True)[source]
remove(name)[source]
reshapefunc(w, h)[source]
revertAppearance(name)[source]
savePlot(plotname, fn)[source]
setAppearance(name, appearance)[source]
setAttribute(name, attr, value)[source]
setColor(name, r, g, b, a=1.0)[source]
setDrawFunc(name, func)[source]
setItemConfig(name, value)[source]
stepAnimation(amount)[source]
widgetchangefunc(edit)[source]

Called by GLWidgetPlugin on any widget change

class klampt.vis.visualization.WindowInfo(name, frontend, vis, glwindow=None)[source]

Mode can be hidden, shown, or dialog

klampt.vis.visualization.aabb_create(*ptlist)[source]
klampt.vis.visualization.aabb_empty(bb)[source]
klampt.vis.visualization.aabb_expand(bb, bb2)[source]
klampt.vis.visualization.add(name, item, keepAppearance=False)[source]

Adds an item to the visualization. name is a unique identifier. If an item with the same name already exists, it will no longer be shown. If keepAppearance=True, then the prior item’s appearance will be kept, if a prior item exists.

klampt.vis.visualization.addPlot(name)[source]

Creates a new empty plot..

klampt.vis.visualization.addPlotItem(name, itemname)[source]
klampt.vis.visualization.addPlugin(plugin)[source]

Adds a second OpenGL viewport in the same window, governed by the given plugin

Parameters:plugin (GLPluginInterface) – the plugin used for the second viewport.
klampt.vis.visualization.addText(name, text, pos=None)[source]

Adds text to the visualizer. You must give an identifier to all pieces of text, which will be used to access the text as any other vis object.

Parameters:
  • name (str) – the text’s unique identifier.
  • text (str) – the string to be drawn
  • pos (list, optional) – the position of the string. If pos=None, this is added to the on-screen “console” display. If pos has length 2, it is the (x,y) position of the upper left corner of the text on the screen. Negative units anchor the text to the right or bottom of the window. If pos has length 3, the text is drawn in the world coordinates.

To customize the text appearance, you can set the color, ‘size’ attribute, and ‘position’ attribute of the text using the identifier given in ‘name’.

klampt.vis.visualization.animate(name, animation, speed=1.0, endBehavior='loop')[source]

Sends an animation to the named object. Works with points, so3 elements, se3 elements, rigid objects, or robots, and may work with other objects as well.

Parameters:
  • animation – may be a Trajectory or a list of configurations.
  • speed (float, optional) – a modulator on the animation speed. If the animation is a list of milestones, it is by default run at 1 milestone per second.
  • endBehavior (str, optional) – either ‘loop’ (animation repeats forever) or ‘halt’ (plays once).
klampt.vis.visualization.animationTime(newtime=None)[source]

Gets/sets the current animation time

If newtime == None (default), this gets the animation time.

If newtime != None, this sets a new animation time.

klampt.vis.visualization.autoFitCamera(scale=1)[source]

Automatically fits the camera to all items in the visualization.

Parameters:scale (float, optional) – a scale > 1 magnifies the camera zoom.
klampt.vis.visualization.autoFitViewport(viewport, objects)[source]
klampt.vis.visualization.clear()[source]

Clears the visualization world.

klampt.vis.visualization.clearText()[source]

Clears all text in the visualization.

klampt.vis.visualization.createWindow(title)[source]

Creates a new window (and sets it active).

Returns:an identifier of the window (for use with setWindow()).
Return type:int
klampt.vis.visualization.customUI(func)[source]

Tells the next created window/dialog to use a custom UI function. func is a 1-argument function that takes a QtWindow or GLUTWindow as its argument.

klampt.vis.visualization.dialog()[source]

A blocking call to start a single dialog window with the current plugin. It is closed by pressing OK or closing the window.

klampt.vis.visualization.dirty(item_name='all')[source]

Marks the given item as dirty and recreates the OpenGL display lists. You may need to call this if you modify an item’s geometry, for example. If things start disappearing from your world when you create a new window, you may need to call this too.

klampt.vis.visualization.drawRobotTrajectory(traj, robot, ees, width=2, color=[1, 0.5, 0, 1])[source]

Draws trajectories for the robot’s end effectors. Note: no additional discretization is performed, only the end effector points at the trajectory’s milestones are shown. If you want more accurate trajectories, first call traj.discretize(eps).

klampt.vis.visualization.drawTrajectory(traj, width, color)[source]

Draws a trajectory of points or transforms

klampt.vis.visualization.edit(name, doedit=True)[source]

Turns on/off visual editing of some item.

Only items of type point, transform, coordinate.Point, coordinate.Transform, coordinate.Frame, config, robot, and rigid object are currently accepted.

klampt.vis.visualization.getItemConfig(name)[source]

Returns a configuration of an item from the visualization. Useful for interacting with edited objects.

Returns:
a list of floats describing the item’s current configuration. Returns
None if name doesnt refer to an object.
Return type:list
klampt.vis.visualization.getViewport()[source]

Returns the GLViewport of the current window (see klampt.vis.glprogram.GLViewport)

klampt.vis.visualization.getWindow()[source]

Retrieves ID of currently active window or -1 if no window is active

klampt.vis.visualization.getWindowTitle()[source]
klampt.vis.visualization.hide(name, hidden=True)[source]

Hides an item in the visualization.

Note: the opposite of hide() is not show(), it’s hide(False).

klampt.vis.visualization.hideLabel(name, hidden=True)[source]

Hides or shows the label of an item in the visualization

klampt.vis.visualization.hidePlotItem(name, itemname, hidden=True)[source]

Hides an item in the plot. To hide a particular channel of a given item pass a pair (itemname,channelindex).

Examples

To hide configurations 0-5 of ‘robot’, call::
hidePlotItem(‘plot’,(‘robot’,0)) … hidePlotItem(‘plot’,(‘robot’,5))
klampt.vis.visualization.kill()[source]

This should be called at the end of the calling program to cleanly terminate the visualization thread

klampt.vis.visualization.listItems(name=None, indent=0)[source]
klampt.vis.visualization.lock()[source]

Begins a locked section. Needs to be called any time you modify a visualization item outside of the visualization thread. unlock() must be called to let the visualization thread proceed.

klampt.vis.visualization.logPlot(name, itemname, value)[source]

Logs a custom visualization item to a plot

klampt.vis.visualization.logPlotEvent(name, eventname, color=None)[source]

Logs an event on the plot.

klampt.vis.visualization.loop(setup=None, callback=None, cleanup=None)[source]

Runs the visualization thread inline with the main thread. The setup() function is called at the start, the callback() function is run every time the event thread is idle, and the cleanup() function is called on termination.

NOTE FOR MAC USERS: a multithreaded GUI is not supported on Mac, so the loop() function must be used rather than “show and wait”.

NOTE FOR GLUT USERS: this may only be run once.

klampt.vis.visualization.multithreaded()[source]

Returns true if the current GUI system allows multithreading. Useful for apps that will work cross-platform with Macs and systems with only GLUT.

klampt.vis.visualization.objectToVisType(item, world)[source]

Returns the default type for the given item in the current world

klampt.vis.visualization.pauseAnimation(paused=True)[source]
klampt.vis.visualization.popPlugin()[source]

Reverses a prior pushPlugin() call

klampt.vis.visualization.pushPlugin(plugin)[source]

Adds a new plugin on top of the old one.

Parameters:plugin (GLPluginInterface) – a plugin that will optionally intercept GUI callbacks. Unhandled callbacks will be forwarded to the next plugin on the stack.
klampt.vis.visualization.remove(name)[source]

Removes an item from the visualization

klampt.vis.visualization.revertAppearance(name)[source]
klampt.vis.visualization.run(plugin=None)[source]

A blocking call to start a single window and then kill the visualization once the user closes the window.

Parameters:plugin (GLPluginInterface, optional) – If given, the plugin used to handle all rendering and user input. If plugin == None, the default visualization is used.

Note

Works in both multi-threaded and single-threaded mode.

klampt.vis.visualization.savePlot(name, fn)[source]

Saves a plot to a CSV (extension .csv) or Trajectory (extension .traj) file.

klampt.vis.visualization.setAppearance(name, appearance)[source]

Changes the Appearance of an item, for an item that uses the Appearance item to draw (config, geometry, robots, rigid bodies).

klampt.vis.visualization.setAttribute(name, attr, value)[source]

Sets an attribute of the appearance of an item.

Parameters:
  • name (str) – the name of the item
  • attr (str) – the name of the attribute (see below)
  • value – the value (see below)

Accepted attributes are:

  • ‘color’: the item’s color (r,g,b) or (r,g,b,a)
  • ‘size’: the size of the plot or text
  • ‘length’: the length of axes in RigidTransform
  • ‘width’: the width of axes and trajectory curves
  • ‘duration’: the duration of a plot
  • ‘endeffectors’: for a robot Trajectory, the list of end effectors to plot (default the last link).
  • ‘maxConfigs’: for a Configs resource, the maximum number of drawn configurations (default 10)
  • ‘fancy’: for RigidTransform objects, whether the axes are drawn with boxes or lines (default False)
  • ‘type’: for ambiguous items, like a 3-item list when the robot has 3 links, specifies the type to be
    used. For example, ‘Config’ draws the item as a robot configuration, while ‘Vector3’ or ‘Point’ draws it as a point.
klampt.vis.visualization.setColor(name, r, g, b, a=1.0)[source]
klampt.vis.visualization.setDrawFunc(name, func)[source]

Sets a custom OpenGL drawing function for an item.

Parameters:
  • name (str) – the name of the item
  • func (function or None) – a one-argument function draw(data) that takes the item data as input. Set func to None to revert to default drawing.
klampt.vis.visualization.setItemConfig(name, value)[source]

Sets a configuration of an item from the visualization.

Parameters:
  • name (str) – the item to set the configuration of.
  • value (list of floats) – the item’s configuration. The number of items depends on the object’s type. See the config module for more information.
klampt.vis.visualization.setPlotDuration(name, time)[source]

Sets the plot duration.

klampt.vis.visualization.setPlotPosition(name, x, y)[source]

Sets the upper left position of the plot on the screen.

klampt.vis.visualization.setPlotRange(name, vmin, vmax)[source]

Sets the y range of a plot to [vmin,vmax].

klampt.vis.visualization.setPlotSize(name, w, h)[source]

sets the width and height of the plot, in pixels.

klampt.vis.visualization.setPlugin(plugin)[source]

Lets the user capture input via a glinterface.GLPluginInterface class. Set plugin to None to disable plugins and return to the standard visualization

Parameters:plugin (GLPluginInterface) – a plugin that will hereafter capture input from the visualization and can override any of the default behavior of the visualizer. Can be set to None if you want to return to the default visualization.
klampt.vis.visualization.setViewport(viewport)[source]

Sets the current window to use a given GLViewport (see klampt.vis.glprogram.GLViewport)

klampt.vis.visualization.setWindow(id)[source]

Sets currently active window.

Note

ID 0 is the default visualization window.

klampt.vis.visualization.setWindowTitle(title)[source]
klampt.vis.visualization.show(display=True)[source]

Shows or hides the current window.

NOTE FOR MAC USERS: due to a lack of support of multithreading on Mac, this will not work outside of the setup / callback / cleanup functions given in a call to loop().

klampt.vis.visualization.shown()[source]

Returns true if a visualization window is currently shown.

klampt.vis.visualization.spin(duration)[source]

Spin-shows a window for a certain duration or until the window is closed.

klampt.vis.visualization.stepAnimation(amount)[source]
klampt.vis.visualization.unlock()[source]

Ends a locked section acquired by lock().