Simulate grasping of objects and computing force closure metrics.
Running the Generator
openrave.py --database grasping
_databases_grasping_usage:
Dynamically generate/load the grasping set for a robot manipulator and target object:
robot.SetActiveManipulator(...)
gmodel = openravepy.databases.grasping.GraspingModel(robot,target)
if not gmodel.load():
gmodel.autogenerate()
To compute at most 10 valid grasps in the current environment do:
validgrasps,validindices = gmodel.computeValidGrasps(returnnum=10)
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
It is also possible to return an iterator to the valid grasps via:
for validgrasps,validindices in gmodel.validGraspIterator():
gmodel.showgrasp(validgrasp) # show the grasp
OpenRAVE can simulate grasps for any type of robotic hand, evaluate the quality of the grasps, and use those grasps in a more complex grasp planning framework. This tutorial is meant to introduce you to the grasper plugin and the scripts provided to manage the testing and simulation. At the end, you should be able to create grasp tables and use them effectively in OpenRAVE.
A grasp is simulated by giving the end-effector an initial pose and initial joint angles (preshape). Then the end effector moves along a direction (usually along the normal of the palm) until it hits the target object. Once hit, the ‘fingers’ of the end-effector slowly close around the object until they cannot close further. The contacts between the end-effector and target object are extracted, and force closure is calculated. The Grasper - grasper is responsible for this simulation, the scripts just pass in the correct parameters to it.
Grasp set creation first tries to uniformly sample the surface of the object to determine where to the approach directions should be. Sampling the actual geometric surface of the object can lead to unwanted results due to possible concavities like the handle of a cup. A simpler approach is to take the bounding box of the object and sample its surface uniformly (see GraspingModel.computeBoxApproachRays).
Once the surface of the box is sampled, the intersection of the object and a ray originating from each point going inward is taken. The normal of the object’s surface from each of these intersection points is taken to be the approaching direction of the end-effector. The red lines in the above image indicate the rays along which the end-effector will approach the cup.
Once the initial pose, preshape, and approach direction are chosen, the grasper planner is called, which queries the contact points of the grasp and analyzes them for force closure.
Render the final configuration of the end-effector closing down on the target object along with the friction cones at each contact point (red transparent cones).
Calling GraspingModel.generate generates tables for a ketchup bottle.
Here’s a short list of features of the grasper planner and problem interfaces:
Usage: openrave.py --database grasping [options] Grasp set generation example for any robot/body pair. Options: -h, --help show this help message and exit --plannername=PLANNERNAME The grasper planner to use for this model (default=none) --target=TARGET The filename of the target body whose grasp set to be generated (default=data/mug1.kinbody.xml) --boxdelta=BOXDELTA Step size of of box surface sampling --spheredelta=SPHEREDELTA Delta angle between directions on the sphere --normalanglerange=NORMALANGLERANGE The range of angles around the surface normal to approach from (default=0.0) --directiondelta=DIRECTIONDELTA The average distance of approach directions for each surface point in radians (default=0.4) --translationstepmult=TRANSLATIONSTEPMULT The multiplier for translational step sizes vs rotational step sizes --finestep=FINESTEP The second stage step size for the joints --standoff=STANDOFFS Add a standoff distance --roll=ROLLS Add a roll angle --preshape=PRESHAPES Add a preshape for the manipulator gripper joints --manipulatordirection=MANIPULATORDIRECTIONS Add a direction for the gripper to face at when approaching (in the manipulator coordinate system) --avoidlink=AVOIDLINKS Add a link name to avoid at all costs (like sensor links) --friction=FRICTION Friction between robot and target object (default=0.3) --graspingnoise=GRASPINGNOISE Random undeterministic noise to add to the target object, represents the max possible displacement of any point on the object. Noise is added after global direction and start have been determined (default=0) --graspindex=GRASPINDEX If set, then will only show this grasp index 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 OpenRAVE Database Generator General Options: --show Graphically shows the built model --getfilename If set, will return the final database filename where all data is stored --gethas If set, will exit with 0 if datafile is generated and up to date, otherwise will return a 1. This will require loading the model and checking versions, so might be a little slow. --robot=ROBOT OpenRAVE robot to load (default=robots/barrettsegway.robot.xml) --numthreads=NUMTHREADS number of threads to compute the database with (default=1) --manipname=MANIPNAME The name of the manipulator on the robot to use
ベースクラス: openravepy.databases.DatabaseGenerator
Holds all functions/data related to a grasp between a robot hand and a target
When ‘entered’ will hide all the non-gripper links in order to facilitate visiblity of the gripper
Returns the set of grasps that satisfy conditions like collision-free and reachable.
パラメタ: |
|
---|
Generates all the worker items, processes them, and stores the results. For an argument list, take a look at generatepcg()
Generates a grasp set by searching space and evaluating contact points.
All grasp parameters have to be in the bodies’s coordinate system (ie: approachrays). @param checkgraspfn: If set, then will be used to validate the grasp. If its evaluation returns false, then grasp will not be added to set. Called by checkgraspfn(contacts,finalconfig,grasp,info)
returns the final grasp transform before fingers start closing. If collisionfree is set to True, then will return a grasp that is guaranteed to be not in collision with the target object when at its preshape. This is achieved by by moving the hand back along igraspdir.
uses a planner to safely move the hand to the preshape and returns the trajectory
squeeze the fingers to test whether the completed grasp only collides with the target, throws an exception if it fails. Otherwise returns the Grasp parameters. Uses the grasp transformation directly.
sets the preshape on the robot, assumes environment is locked
Returns an iterator for valid grasps that satisfy certain conditions.
パラメタ: | returnfinal – if True will return the contacts and finalconfig of the simulation grasp |
---|
See computeValidGrasps() for description of parameters.
OPENRAVE_API CollisionCheckerBasePtr RaveCreateCollisionChecker(EnvironmentBasePtr penv, const std::string & name)
OPENRAVE_API ModuleBasePtr RaveCreateModule(EnvironmentBasePtr penv, const std::string & name)
OPENRAVE_API TrajectoryBasePtr RaveCreateTrajectory(EnvironmentBasePtr penv, const std::string & name = “” )
Return an empty trajectory instance.
OPENRAVE_API void RaveDestroy()
Destroys the entire OpenRAVE state and all loaded environments.
This functions should be always called before program shutdown in order to assure all resources are relased appropriately.
OPENRAVE_API std::string RaveFindDatabaseFile(const std::string & filename, bool bRead = true )
Searches for a filename in the database and returns a full path/URL to it.
- Parameters
- filename -
- the relative filename in the database
- bRead -
- if true will only return a file if it exists. If false, will return the filename of the first valid database directory.
- Return
- a non-empty string if a file could be found.
RaveVector < T > quatRotateDirection(const RaveVector < T > & sourcedir, const RaveVector < T > & targetdir)
Return the minimal quaternion that orients sourcedir to targetdir.
- Parameters
- sourcedir -
- direction of the original vector, 3 values
- targetdir -
- new direction, 3 values
RaveTransformMatrix < T > matrixFromQuat(const RaveVector < T > & quat)
Converts a quaternion to a 3x3 matrix.
- Parameters
- quat -
- quaternion, (s,vx,vy,vz)