tutorial_iktranslation Module
Shows how to use translational inverse kinematics for an arm with few joints.
Running the Example:
openrave.py --example tutorial_iktranslation
Description
There are two different types of translation 3D IKs:
- Translation3D - Align the origin of the manipulation coordinate system with the desired world position
- TranslationLocalGlobal6D - Align a dynamically chosen position with respect ot the manipulation coordinate system with the desired world position. To see this in action, execute the example with:
openrave.py --example tutorial_iktranslation --withlocal
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/katanatable.env.xml)
--manipname=MANIPNAME
name of manipulator to use (default=arm)
--withlocal If set, will use the TranslationLocalGlobal6D type to
further specify the target point in the manipulator
coordinate system
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
iktype = IkParameterization.Type.Translation3D if not options.withlocal else IkParameterization.Type.TranslationLocalGlobal6D
ikmodel = databases.inversekinematics.InverseKinematicsModel(robot, iktype=iktype,freeindices=robot.GetActiveManipulator().GetArmIndices()[3:])
if not ikmodel.load():
ikmodel.autogenerate()
with env:
robot2 = env.ReadRobotXMLFile(robot.GetXMLFilename())
env.Add(robot2)
T = robot.GetTransform()
T[0,3] -= 1
robot2.SetTransform(T)
robot2.Enable(False)
robot2.SetActiveManipulator(robot.GetActiveManipulator().GetName())
for link in robot2.GetLinks():
for geom in link.GetGeometries():
geom.SetTransparency(0.2)
while True:
with env:
while True:
target=ikmodel.manip.GetTransform()[0:3,3]+(random.rand(3)-0.5)
if options.withlocal:
localtarget = 0.5*(random.rand(3)-0.5)
ikparam = IkParameterization([localtarget,target],IkParameterization.Type.TranslationLocalGlobal6D)
else:
localtarget = zeros(3)
ikparam = IkParameterization(target,IkParameterization.Type.Translation3D)
solutions = ikmodel.manip.FindIKSolutions(ikparam,IkFilterOptions.CheckEnvCollisions)
if solutions is not None and len(solutions) > 0: # if found, then break
break
h=env.plot3(array([target]),10.0)
T2 = robot2.GetActiveManipulator().GetTransform()
h2=env.plot3(dot(T2[0:3,0:3],localtarget)+T2[0:3,3],15.0,[0,1,0])
for i in random.permutation(len(solutions))[0:min(80,len(solutions))]:
with env:
robot.SetDOFValues(solutions[i],ikmodel.manip.GetArmIndices())
T = ikmodel.manip.GetTransform()
env.UpdatePublishedBodies()
time.sleep(0.05)
h=None
h2=None
Class Definitions
-
openravepy.examples.tutorial_iktranslation.main(env, options)[ソース]
Main example code.
-
openravepy.examples.tutorial_iktranslation.run(*args, **kwargs)[ソース]
Command-line execution of the example.
パラメタ: | args – arguments for script to parse, if not specified will use sys.argv |