grasping with Translation3D

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

grasping with Translation3D

karim
Hello,

I am using a 4 DOF robot, and the only library I managed to use for the IK fast is the Translation3D. So, everything is working fine, until I reached the point that I want to load the grasp library, and that's when it shows and error, telling me that "IK solver is not correct". After reading a bit about the grasp library, it turned out, that I have to run either the TranslationDirection5D library or the Transform 6D.

Is there anyway I can use the Grasp library with my 4 DOF robot?

ps. I tried to change the description of the robot to add some fake joints, but this is a bit hectic. So, I would like to find another way of getting the grasp library to work with the 4 DOF robot.

Thank you

My simple code to try the grasping:
from openravepy import *
from numpy import *
import time, numpy

# Load Environment and Robot ----------------------------
env    = Environment()
env.SetViewer('qtcoin')
env.Load('/home/karim/code/arm_rave/env/test_env.env.xml')
env.Load('/home/karim/code/arm_rave/env/pdArm.robot.xml')
robot  = env.GetRobots()[0]
target = env.ReadKinBodyXMLFile('/home/karim/code/arm_rave/env/fake_brick.xml')
env.AddKinBody(target)
manip  = robot.GetActiveManipulator()

# IK Model-----------------------------------------------
iktype = IkParameterization.Type.Translation3D
#freeindices = robot.GetActiveManipulator().GetArmIndices()[3:]
ikmodel = databases.inversekinematics.InverseKinematicsModel(robot,iktype=iktype)#,freeindices=freeindices)

if not ikmodel.load():
        ikmodel.autogenerate()#freejoints=[3])


basemanip = interfaces.BaseManipulation(robot) # create the interface for basic manipulation programs

taskprob = interfaces.TaskManipulation(robot) # create the interface for task manipulation programs

#Grasp Model -------------------------------------------
gmodel = databases.grasping.GraspingModel(robot,target)
if not gmodel.load():
    gmodel.autogenerate()

# "Everything goes fine until here"

validgrasps,validindices = gmodel.computeValidGrasps(returnnum=1)
validgrasp=validgrasps[0] # choose first grasp
gmodel.showgrasp(validgrasp) # show the grasp
gmodel.moveToPreshape(validgrasp) # move to the preshape of the first grasp
Tgrasp = gmodel.getGlobalGraspTransform(validgrasp,collisionfree=True) # get the grasp transform
basemanip = openravepy.interfaces.BaseManipulation(robot)
basemanip.MoveToHandPosition(matrices=[Tgrasp]) # move the robot to the grasp



The error that I get is:
>>> validgrasps,validindices = gmodel.computeValidGrasps(returnnum=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack

when I try to run gmodel alone:
>>> gmodel.computeValidGrasps(returnnum=1)
ValueError('manipulator iktype not correct',)
Loading...