OpenRAVE Documentation

tutorial_iklookat Module

Shows how to use lookat inverse kinematics to maintain line of sight with a moving object.

../../_images/tutorial_iklookat.jpg

Running the Example:

openrave.py --example tutorial_iklookat

Command-line

Usage: openrave.py [options]

Shows how to use different IK solutions for arms with few joints.

Options:
  -h, --help            show this help message and exit
  --scene=SCENE         Scene file to load (default=data/pr2test1.env.xml)
  --manipname=MANIPNAME
                        name of manipulator to use (default=head_torso)

  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)
    robot = env.GetRobots()[0]
    robot.SetActiveManipulator(options.manipname)

    # generate the ik solver
    ikmodel = databases.inversekinematics.InverseKinematicsModel(robot, iktype=IkParameterization.Type.Lookat3D)
    if not ikmodel.load():
        ikmodel.autogenerate()

    while True:
        with env:
            # move the robot in a random collision-free position and call the IK
            while True:
                target=ikmodel.manip.GetTransform()[0:3,3]+(random.rand(3)-0.5)
                solutions = ikmodel.manip.FindIKSolutions(IkParameterization(target,IkParameterization.Type.Lookat3D),IkFilterOptions.CheckEnvCollisions)
                if len(solutions) > 0:
                    break
        h=env.plot3(array([target]),20.0)
        for i in random.permutation(len(solutions))[0:min(100,len(solutions))]:
            with env:
                robot.SetDOFValues(solutions[i],ikmodel.manip.GetArmIndices())
                T = ikmodel.manip.GetTransform()
                globaldir = numpy.dot(T[0:3,0:3],ikmodel.manip.GetDirection())
                dist = linalg.norm(T[0:3,3]-target)+0.4
                hray = env.drawlinelist(array([T[0:3,3], T[0:3,3]+dist*globaldir]),5,colors=[0.1,0.1,1])
                env.UpdatePublishedBodies()
            time.sleep(0.1)

Class Definitions

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

Main example code.

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