OpenRAVE Documentation

tutorial_plotting Module

Example plotting calls.

../../_images/tutorial_plotting.jpg

Running the Example:

openrave.py --example tutorial_plotting

Command-line

Usage: openrave.py [options]

tutorial_plotting

Options:
  -h, --help            show this help message and exit

  OpenRAVE Environment Options:
    --loadplugin=_LOADPLUGINS
                        List all plugins and the interfaces they provide.
    --collision=_COLLISION
                        Default collision checker to use
    --physics=_PHYSICS  physics engine to use (default=none)
    --viewer=_VIEWER    viewer to use (default=qtcoin)
    --server=_SERVER    server to use (default=None).
    --serverport=_SERVERPORT
                        port to load server on (default=4765).
    --module=_MODULES   module to load, can specify multiple modules. Two
                        arguments are required: "name" "args".
    -l _LEVEL, --level=_LEVEL, --log_level=_LEVEL
                        Debug level, one of
                        (fatal,error,warn,info,debug,verbose,verifyplans)
    --testmode          if set, will run the program in a finite amount of
                        time and spend computation time validating results.
                        Used for testing

Main Python Code

def main(env,options):
    "Main example code."
    spinner = None
    try:
        handles = []
        handles.append(env.plot3(points=array(((-1.5,-0.5,0),(-1.5,0.5,0))),
                                   pointsize=15.0,
                                   colors=array(((0,1,0),(0,0,0)))))
        handles.append(env.plot3(points=array((-1.5,-1,0)),
                                   pointsize=25.0,
                                   colors=array(((0,0,1,0.2)))))
        handles.append(env.drawlinestrip(points=array(((-1.25,-0.5,0),(-1.25,0.5,0),(-1.5,1,0))),
                                           linewidth=3.0,
                                           colors=array(((0,1,0),(0,0,1),(1,0,0)))))
        handles.append(env.plot3(points=array(((-0.5,-0.5,0),(-0.5,0.5,0))),
                                   pointsize=0.05,
                                   colors=array(((0,1,0),(1,1,0))),
                                   drawstyle=1))
        handles.append(env.drawtrimesh(points=array(((0,0,0),(0.5,0,0),(0,0.5,0))),
                                         indices=None,
                                         colors=array(((0,1,0),(0,0,1),(1,0,0)))))
        handles.append(env.drawtrimesh(points=array(((0,0,0.5),(0.5,0,0.5),(-0.5,0.5,0.5),(1,0.5,0.5))),
                                         indices=array(((0,1,2),(2,1,3)),int64),
                                         colors=array((1,0,0,0.5))))
        handles.append(env.plot3(points=array(((0.5,0,1.0),(-0.5,0,1.0))),
                                   pointsize=45.0,
                                   colors=array(((0,0,0,0.1),(0,0,0,0.8)))))
        # draw a random texture with alpha channel
        X,Y = meshgrid(arange(0,1,0.005),arange(0,1,0.01))
        Ic = zeros((X.shape[0],X.shape[1],4))
        Ic[:,:,1] = 0.5*sin(20*Y)+0.5
        Ic[:,:,2] = 1
        Ic[:,:,3] = 0.5*sin(20*Y)+0.5
        handles.append(env.drawplane(transform=matrixFromAxisAngle(array((1,0,0)),pi/4),extents=[1.0,0.5],texture=Ic))
        # spin one of the plots in another thread
        spinner = PlotSpinner(handles[-1])
        spinner.start()
        Tcamera = eye(4)
        Tcamera[0:3,3] = [-0.37, 0.26, 3.3]
        env.GetViewer().SetCamera(Tcamera)
        raw_input('Enter any key to quit. ')
        handles = None
    finally:
        if spinner is not None:
            spinner.ok = False

Class Definitions

class openravepy.examples.tutorial_plotting.PlotSpinner(handle)[source]

Bases: threading.Thread

run()[source]
openravepy.examples.tutorial_plotting.main(env, options)[source]

Main example code.

openravepy.examples.tutorial_plotting.run(*args, **kwargs)[source]

Command-line execution of the example.

Parameters:args – arguments for script to parse, if not specified will use sys.argv

Questions/Feedback

Having problems with OpenRAVE?