OpenRAVE Documentation

testphysics_diffdrive Module

Shows how to enable differential drive with physics.

../../_images/testphysics_diffdrive.jpg

Running the Example:

openrave.py --example testphysics_diffdrive

Command-line

Usage: openrave.py [options]

test physics diff drive controller

Options:
  -h, --help            show this help message and exit
  --scene=SCENE         Scene file to load
                        (default=data/diffdrive_sample.env.xml)

  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."
    env.Load(options.scene)
    if options._physics is None:
        # no physics engine set, so set one
        physics = RaveCreatePhysicsEngine(env,'ode')
        env.SetPhysicsEngine(physics)

    with env:
        env.GetPhysicsEngine().SetGravity(array((0,0,-9.8)))
        robot = env.GetRobots()[0]
        robot.SetController(RaveCreateController(env,'odevelocity'),range(robot.GetDOF()),0)
        env.StopSimulation()
        env.StartSimulation(timestep=0.001)

    starttime = time.time()
    while True:
        velocities = 4*(random.rand(robot.GetDOF())-0.5)
        print 'velocities: ',velocities
        robot.GetController().SendCommand('setvelocity '+' '.join(str(f) for f in velocities))
        time.sleep(2)

Class Definitions

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

Main example code.

openravepy.examples.testphysics_diffdrive.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?