Grasper plugin - how to stop it from moving hand?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Grasper plugin - how to stop it from moving hand?

Krzysztof Trzciński
Hi,
I have a simple script:

from openravepy import *
from numpy import *

env = Environment() # create openrave environment
RaveLoadPlugin('libgrasper');

hand = env.ReadRobotXMLFile("robots/barretthand.robot.xml")
env.AddRobot( hand )

graspTarget = env.ReadKinBodyXMLFile("data/mug1.kinbody.xml")
env.AddKinBody(graspTarget)

env.SetViewer('qtcoin') # attach viewer (optional)

graspProb = RaveCreateProblem(env, 'Grasper')
env.LoadProblem(graspProb,args='BarrettHand')

raw_input('place object...')
graspProb.SendCommand('Grasp target mug');
raw_input('end...')

Description of grasper plug-in says it is "Used to simulate a hand grasping an object by closing its fingers until
collision with all links.", which it does, but it also moves the hand around which I do not want.
How can I call the grasper plug-in to only close fingers without moving anything else?
And is there a possibility to specify arbitrary speeds for each joint?

I tried looking at documentation and source code, but I couldn't find even a simple example of use of this plug-in
anywhere. Is there some place I missed?

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
hi Krzysztof,

The TaskManipulation interface wraps this closing and releasing
functionality of the grasping plugin, so it is highly recommended over
calling 'grasp' directly.

#move hand below cup
T=eye(4)
T[2,3] = -0.176
hand.SetTransform(T)
# close fingers
taskmanip=interfaces.TaskManipulation(hand)
taskmanip.CloseFingers()

rosen,

2010/10/12 Krzysztof Trzciński <[hidden email]>:

> Hi,
> I have a simple script:
>
> from openravepy import *
> from numpy import *
>
> env = Environment() # create openrave environment
> RaveLoadPlugin('libgrasper');
>
> hand = env.ReadRobotXMLFile("robots/barretthand.robot.xml")
> env.AddRobot( hand )
>
> graspTarget = env.ReadKinBodyXMLFile("data/mug1.kinbody.xml")
> env.AddKinBody(graspTarget)
>
> env.SetViewer('qtcoin') # attach viewer (optional)
>
> graspProb = RaveCreateProblem(env, 'Grasper')
> env.LoadProblem(graspProb,args='BarrettHand')
>
> raw_input('place object...')
> graspProb.SendCommand('Grasp target mug');
> raw_input('end...')
>
> Description of grasper plug-in says it is "Used to simulate a hand grasping an object by closing its fingers until
> collision with all links.", which it does, but it also moves the hand around which I do not want.
> How can I call the grasper plug-in to only close fingers without moving anything else?
> And is there a possibility to specify arbitrary speeds for each joint?
>
> I tried looking at documentation and source code, but I couldn't find even a simple example of use of this plug-in
> anywhere. Is there some place I missed?
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
> Spend less time writing and  rewriting code and more time creating great
> experiences on the web. Be a part of the beta today.
> http://p.sf.net/sfu/beautyoftheweb
> _______________________________________________
> Openrave-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openrave-users
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
Hi Krzysztof,

To get contacts for each of the links, you can use the
Environment.CheckCollision function like this:

report=CollisionReport()
env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
# notify checker to return contacts
for link in robot.GetLinks():
    incollision=env.CheckCollision(link,report)
    print 'num contacts are: ',len(report.contacts)

report.contacts[0].pos, report.contacts[0].norm,
report.contacts[0].depth are the values for the first contact point

As for the "EvaluateConstraints" command, check out the code for the
constraintplanning example:

openrave.py --example constraintplanning

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:

> On 12.10.2010 16:26, Rosen Diankov wrote:
>> Hi Krzysztof,
>>
>> This was one of the problems fixed in r1771. If it isn't too much
>> trouble, can you test it?
>>
>> rosen,
>
> After "svn update" and recompiling it works as it should.
>
> After calling TaskManipulation.CloseFingers() is there an easy way to get contact points+normals?
> Also what is the use of EvaluateConstraints() and what is the meaning of freedoms and configs arguments?
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
hi Krysztof,

I'm getting contacts with the initial collision method:

num contacts are:  0
num contacts are:  0
num contacts are:  0
num contacts are:  1
num contacts are:  0
num contacts are:  0
num contacts are:  1
num contacts are:  0
num contacts are:  2


Also

report=CollisionReport()
incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
print report.contacts

gives 2 contacts

Are you sure you are calling:
env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)

Once the fingers have closed, can you click on the hand (in edit mode)
in the GUI and confirm it is orange (meaning in collision)?

I'm not sure why you would ever want to ignore collisions between some
links and not others..... ignoring a link just makes the grasp
impossible to achieve in the real world. If you want to get collision
contacts between only the finger tips, then do the above
env.CheckCollision(link...) call

The protocol between the planner and the caller is a stringstream. If
you want the planner to return the contacts it computes for all links,
then it would be necessary to serialize the contact points. This can
certainly be done, here's the ticket for it:

https://sourceforge.net/apps/trac/openrave/ticket/77

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:

> On 12.10.2010 17:10, Rosen Diankov wrote:
>> report=CollisionReport()
>> env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
>> # notify checker to return contacts
>> for link in robot.GetLinks():
>>     incollision=env.CheckCollision(link,report)
>>     print 'num contacts are: ',len(report.contacts)
>
> I tried this and I have tried:
>
> report=CollisionReport()
> incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
> print report.contacts
>
> I also tried changing between ODE and Bullet collision checkers. In every case I got from your code:
>
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
> num contacts are:  0
>
> and from mine:
>
> []
>
> So the grasp has closed, but I do not get any contacts.
>
> Second flaw with this solution is that I want to reduce the number of collision checks so there should be a way to get
> those from the CloseFingers() method as it has to compute them.
>
> And one more thing. Is there a way to tell CloseFingers() to check collisions only for given set of links? (in my
> particular case I would like to check only if the tips of fingers collide with anything).
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
Hi Krzysztof,

If you don't want other objects considered, you should call
KinBody.Enable(False) on them.

The Grasper plugin supports the 'targetbody' parameter that allows the
user to fail a grasp if the hand contacts anything but that target
object.

The reason for the TaskManipulation interface's CloseFingers and
ReleaseFingers functions is to make it easy for users to call the
Grasper Planner. Otherwise, they would have to fill a
PlannerParameters structure each time, which can be a pain.

If you think there is a way to speed up the grasper planner and still
produce the same behavior, then please check out the
plugins/grasper/grasperplanner.h file and send your comments. Even if
you are only interested in the finger tips, collision has to be
checked with the entire robot hand.

If you consider all other contacts as incorrect, then the grasper
plugin has a special 'avoidlinks' parameter. You should put all
non-tip link names in this parameter. If any of these links are
contacted, the grasp returns immediate failure.  (this is not exposed
in CloseFingers at the moment, but we can add it if you wish)

Please send your final script that still returns 0 for contacts, if it
works for me, then something might be wrong with your installation...
or you have local changes somewhere?

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:

> On 12.10.2010 18:05, Rosen Diankov wrote:
>> hi Krysztof,
>>
>> I'm getting contacts with the initial collision method:
>>
>> num contacts are:  0
>> num contacts are:  0
>> num contacts are:  0
>> num contacts are:  1
>> num contacts are:  0
>> num contacts are:  0
>> num contacts are:  1
>> num contacts are:  0
>> num contacts are:  2
>>
>>
>> Also
>>
>> report=CollisionReport()
>> incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
>> print report.contacts
>>
>> gives 2 contacts
>>
>> Are you sure you are calling:
>> env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
>>
> Yes, I am calling it after changing the collision checking plug-in, but before calling CheckCollision().
>
>
>> Once the fingers have closed, can you click on the hand (in edit mode)
>> in the GUI and confirm it is orange (meaning in collision)?
>>
> Both the grasped object and hand are marked as colliding. So it appears I am doing something wrong, but I can't find
> anything.
>
>> I'm not sure why you would ever want to ignore collisions between some
>> links and not others..... ignoring a link just makes the grasp
>> impossible to achieve in the real world.
> For speed. I assume that closing fingers is done in a simple way of incrementing the joint values and checking which
> links collide. So this means that each iteration we call collision checking for all links while I am interested only in
> tips of the fingers.
> This reduces few times the amount of time spent on checking collisions.
> It would be also nice to be able to pass to CloseFingers() the target, so collision checking would take into account
> only given links and the specified object.
>
> If that would be possible then after closing fingers I could check if all other links collide with anything. In my
> application they shouldn't, so any grasp that collided other than specified link should be considered incorrect.
>
>> If you want to get collision
>> contacts between only the finger tips, then do the above
>> env.CheckCollision(link...) call
>>
>> The protocol between the planner and the caller is a stringstream. If
>> you want the planner to return the contacts it computes for all links,
>> then it would be necessary to serialize the contact points. This can
>> certainly be done, here's the ticket for it:
>>
>> https://sourceforge.net/apps/trac/openrave/ticket/77
>
> As far as I can see this can be done calling Grasper plug-in directly, so I don't understand why TaskManipulation was
> introduced.
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
In reply to this post by Rosen Diankov
You need to lock the environment before using OpenRAVE functions! ;0)

http://openrave.programmingvision.com/ordocs/en/openravepy-html/index.html#rst-locking-thread-safety-mechanisms

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:
> I found out what is happening I just don't know why.
> After the call to CloseFingers() it appears that is done asynchronously to my script.
> This leads to call to CheckCollision() being made before the closing of the fingers have finished.
> After I put the raw_input() between those two calls I got correct results. How can I force my script to wait until the
> closing has finished?
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Fwd: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
---------- Forwarded message ----------
From: Rosen Diankov <[hidden email]>
Date: 2010/10/13
Subject: Re: [OpenRAVE-users] Grasper plugin - how to stop it from moving hand?
To: Krzysztof Trzciński <[hidden email]>


the code would look like this:

taskmanip=interfaces.TaskManipulation(hand)
final,traj = taskmanip.CloseFingers()
hand.WaitForController()

with env:
   env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
   report=CollisionReport()
   incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
   print report.contacts


If you just want the final joint values, you can do:

final,traj = taskmanip.CloseFingers(execute=False,outputfinal=True)

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:

> On 12.10.2010 19:02, Rosen Diankov wrote:
>> You need to lock the environment before using OpenRAVE functions! ;0)
>>
>> http://openrave.programmingvision.com/ordocs/en/openravepy-html/index.html#rst-locking-thread-safety-mechanisms
>>
>> rosen,
>>
>> 2010/10/13 Krzysztof Trzciński <[hidden email]>:
>>> I found out what is happening I just don't know why.
>>> After the call to CloseFingers() it appears that is done asynchronously to my script.
>>> This leads to call to CheckCollision() being made before the closing of the fingers have finished.
>>> After I put the raw_input() between those two calls I got correct results. How can I force my script to wait until the
>>> closing has finished?
>>>
>>
>
> I don't see how should I use it to make it help the problem.
> After everything was set up I do:
>
> taskmanip=interfaces.TaskManipulation(hand)
> final,traj = taskmanip.CloseFingers()
>
> env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
>
> report=CollisionReport()
> incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
> print report.contacts
>
> And this leads to computing collisions before CloseFingers have finished.
> When I put raw_input() before the CheckCollision() I can wait for it to finish.
>
> How could I use locking work here? It appears that thread that gets started by CloseFingers() does not lock the
> environment, as changing this to:
>
> with env:
>        taskmanip=interfaces.TaskManipulation(hand)
>        final,traj = taskmanip.CloseFingers()
>
> env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
>
> with env:
>        report=CollisionReport()
>        incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
>        print report.contacts
>
> And this doesn't surprise me. So how should I write this to force the wait for CloseFingers() to end?
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users
Reply | Threaded
Open this post in threaded view
|

Re: Grasper plugin - how to stop it from moving hand?

Rosen Diankov
Administrator
In reply to this post by Rosen Diankov
hi Krzysztof,

final,traj = taskmanip.CloseFingers(execute=False,outputfinal=True)

returns the final configuration without setting it.....

Currently the challenge with OpenRAVE is to increase reliability and
stability. OpenRAVE's design has evolved from these factors.

Although computational speed is very important, if it comes between
choosing simulation reliability or speed, openrave plugins choose
reliability. Although both ways can be exposed, the number of exposed
parameters will increase, which will just confuse the user. Because
robot planning involves many modules, a plugin should be designed to
make the most precise methods the easiest to use. After all,
computation is becoming cheaper. Even if doing things onboard the
robot, nowadays you can easily add a few Ghz/multi-core Intel Atom or
ARM processor to help.

If you think there is a way to reduce computation while still
maintaining the same functionality, then that would definitely be
awesome to use ;0)

For example, to speed up setting joint values and computing jacobians
in openrave, we've been thinking of generating robot-specific C++
libraries that use gcc's optimizer to do the computation. This would
be much faster than iterating through the entire list of joints and
accumulating data.

rosen,

2010/10/13 Krzysztof Trzciński <[hidden email]>:

> On 12.10.2010 19:00, Rosen Diankov wrote:
>> If you don't want other objects considered, you should call
>> KinBody.Enable(False) on them.
>
> That is also an option. It is just that in my problems I have to check collisions only with one object (but this might
> change).
> I was just hoping that there is a simple way to do this with TaskManipulation.
>
>> The Grasper plugin supports the 'targetbody' parameter that allows the
>> user to fail a grasp if the hand contacts anything but that target
>> object.
>
> That is also good to know.
>
>> The reason for the TaskManipulation interface's CloseFingers and
>> ReleaseFingers functions is to make it easy for users to call the
>> Grasper Planner. Otherwise, they would have to fill a
>> PlannerParameters structure each time, which can be a pain.
>>
>> If you think there is a way to speed up the grasper planner and still
>> produce the same behavior, then please check out the
>> plugins/grasper/grasperplanner.h file and send your comments. Even if
>> you are only interested in the finger tips, collision has to be
>> checked with the entire robot hand.
>>
>> If you consider all other contacts as incorrect, then the grasper
>> plugin has a special 'avoidlinks' parameter. You should put all
>> non-tip link names in this parameter. If any of these links are
>> contacted, the grasp returns immediate failure.  (this is not exposed
>> in CloseFingers at the moment, but we can add it if you wish)
>
> I don't think there is a way to achieve the same behavior with less collision checks.
> I was willing to give up precision of simulation knowing that it might produce wrong results in some cases.
>
> On 12.10.2010 20:10, Rosen Diankov wrote:
>> the code would look like this:
>>
>> taskmanip=interfaces.TaskManipulation(hand)
>> final,traj = taskmanip.CloseFingers()
>> hand.WaitForController()
>>
>> with env:
>>     env.GetCollisionChecker().SetCollisionOptions(CollisionOptions.Contacts)
>>     report=CollisionReport()
>>     incollision=env.CheckCollision(hand, body2=graspTarget,report=report)
>>     print report.contacts
>
> And this works like a charm (at least as long as I use PQP collision checker, as for the other two I get a bit too few
> contact points).
>
>> If you just want the final joint values, you can do:
>>
>> final,traj = taskmanip.CloseFingers(execute=False,outputfinal=True)
>
> I found about this. Also it makes me a bit curious.
> How can it return the "final" configuration before it is set?
> Does setting execute,outputfinal and outputtraj to False speed up the process?
> If it does do you know any estimates on how much does enabling does impact the processing time?
>

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openrave-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openrave-users