velo_grasp_planning_task.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 #include <dbase_grasp_planner/velo_grasp_planning_task.h>
00036 
00037 #include "robot.h"
00038 #include "EGPlanner/searchState.h"
00039 #include "EGPlanner/loopPlanner.h"
00040 #include "debug.h"
00041 
00042 namespace dbase_grasp_planner {
00043 
00044 VeloGraspPlanningTask::VeloGraspPlanningTask(graspit_dbase_tasks::DBTaskDispatcher *disp, 
00045                                            db_planner::DatabaseManager *mgr, 
00046                                            db_planner::TaskRecord rec) : GraspPlanningTask(disp, mgr, rec) {}
00047 
00048 void VeloGraspPlanningTask::start()
00049 {
00050   GraspPlanningTask::start();
00051   if (mStatus == RUNNING) {
00052     static_cast<LoopPlanner*>(mPlanner)->setSaveThreshold(6.0);
00053   }
00054 }
00055 
00056 bool VeloGraspPlanningTask::setPreGrasp(const GraspPlanningState *graspState)
00057 {
00058   //go back 10cm 
00059   double RETREAT_BY = -100;
00060 
00061   //place the mHand in position
00062   graspState->execute();  
00063 
00064   //go to Velo open pose
00065   std::vector<double> dof(mHand->getNumDOF(),0.0);
00066   dof[0] = dof[2] =  20.0 * M_PI / 180.0;
00067   dof[1] = dof[3] = -20.0 * M_PI / 180.0;
00068   std::vector<double> stepSize(mHand->getNumDOF(), M_PI/36.0);
00069   mHand->moveDOFToContacts(&dof[0], &stepSize[0], true, false);
00070 
00071   //check if move has succeeded
00072   for (int d=0; d<mHand->getNumDOF(); d++) {
00073     if ( fabs( dof[d] - mHand->getDOF(d)->getVal() ) > 1.0e-5) {
00074       DBGP("  Velo trying to open to " << dof[d] << "; only made it to " << mHand->getDOF(d)->getVal());
00075       DBGA("  open Velo fails");
00076       return false;
00077     }
00078   }
00079 
00080   //retreat along approach direction
00081   if (mHand->approachToContact(RETREAT_BY, false)) {
00082     //we have hit something
00083     DBGA("  retreat fails");
00084     return false;
00085   }
00086 
00087   return true;
00088 }
00089 
00090 }
00091 
00092 


dbase_grasp_planner
Author(s): Matei Ciocarlie
autogenerated on Mon Jan 6 2014 11:20:17