7 this->
mimicNLRelMap = parserMoveIt->getMimicNLFatherOfJointMap();
21 if (mapOfLoosePinches.size() != 0 ){
26 if (mapOfPinches.size() == 0 ) {
27 std::cout <<
"[FINDACTIONS::" << __func__ <<
"]: I found no collisions between tips. Are you sure your hand" 28 <<
" has some fingertips that can collide? If yes, check your urdf/srdf, or be sure to" 29 <<
" have set the mesh or some collision geometry for the links, or" 30 <<
" set a bigger value in N_EXP_COLLISION" << std::endl;
37 for (
auto& it : mapOfPinches) {
40 std::set < std::string > keys ;
41 keys.insert (it.first.first) ;
42 keys.insert (it.first.second) ;
43 mapForWorker.insert (std::make_pair ( keys, pointer ) );
46 yamlWorker.
createYamlFile(mapForWorker,
"pinchTight", path2saveYaml);
49 if (mapOfLoosePinches.size() == 0 ) {
50 std::cout <<
"[FINDACTIONS::" << __func__ <<
"]: I found no loose pinches. This mean that some error happened or that" <<
51 " all the tips pairs collide with each other for at least one hand configuration." << std::endl;
58 for (
auto& it : mapOfLoosePinches) {
61 std::set < std::string > keys ;
62 keys.insert (it.first.first) ;
63 keys.insert (it.first.second) ;
64 mapForWorker.insert (std::make_pair ( keys, pointer ) );
67 yamlWorker.
createYamlFile(mapForWorker,
"pinchLoose", path2saveYaml);
70 return std::make_pair(mapOfPinches, mapOfLoosePinches);
74 std::string path2saveYaml) {
77 std::map <std::string, ActionTrig> trigMap;
80 case ROSEE::ActionPrimitive::Type::Trig : {
84 case ROSEE::ActionPrimitive::Type::TipFlex : {
88 case ROSEE::ActionPrimitive::Type::FingFlex : {
93 std::cout <<
"[ERROR FINDACTIONS::" << __func__ <<
"]: Passing as argument a action type which is not a type of trig. " << std::endl
94 <<
"I am returing an empty map" << std::endl;
99 if (trigMap.size() == 0 ) {
105 for (
auto & mapEl : trigMap) {
108 for (
auto joint : mapEl.second.getJointPos() ) {
109 jointsInvolvedCount.insert (std::make_pair(joint.first, 0));
110 for (
auto dof : joint.second) {
112 jointsInvolvedCount.at(joint.first) = 1;
117 mapEl.second.setJointsInvolvedCount (jointsInvolvedCount);
122 for (
auto& it : trigMap) {
125 std::set < std::string > keys ;
126 keys.insert (it.first) ;
127 mapForWorker.insert (std::make_pair ( keys, pointer ) );
131 yamlWorker.
createYamlFile(mapForWorker, trigMap.begin()->second.getName(), path2saveYaml);
139 std::map <std::string, ROSEE::ActionSingleJointMultipleTips> mapOfSingleJointMultipleTips;
142 std::cout <<
"[ERROR FINDACTIONS::" << __func__ <<
"] please pass a positive number " <<
143 " as number of fingers. You passed " << nFinger <<
" ! " << std::endl;
144 return mapOfSingleJointMultipleTips;
148 std::cout <<
"[ERROR FINDACTIONS::" << __func__ <<
"] with 1 finger, you are looking for a ActionTrig, " 149 <<
"and not a ActionSingleJointMultipleTips. Returning an empty map" << std::endl;
150 return mapOfSingleJointMultipleTips;
154 std::cout <<
"[ERROR FINDACTIONS::" << __func__ <<
"] I can not find an action which moves " << nFinger <<
155 " fingers if the hand has only " <<
parserMoveIt->getNFingers() <<
" fingers. Returning an empty map" << std::endl;
156 return mapOfSingleJointMultipleTips;
159 std::string actionName =
"singleJointMultipleTips_" + std::to_string(nFinger);
161 for (
auto mapEl :
parserMoveIt->getFingertipsOfJointMap() ) {
163 if (mapEl.second.size() != nFinger ) {
167 std::vector<double> furtherPos =
parserMoveIt->getBiggerBoundFromZero(mapEl.first);
168 std::vector<double> nearerPos =
parserMoveIt->getSmallerBoundFromZero(mapEl.first);
174 jpFar.insert ( std::make_pair ( it->getName(), jPos ));
178 jpFar.at ( mapEl.first ) = furtherPos;
179 jpNear.at ( mapEl.first ) = nearerPos;
181 std::vector<std::string> fingersInvolved;
182 for (
auto tip : mapEl.second){
183 fingersInvolved.push_back(
parserMoveIt->getFingerOfFingertip (tip) );
188 mapOfSingleJointMultipleTips.insert (std::make_pair(mapEl.first, action));
192 if (mapOfSingleJointMultipleTips.size() == 0 ) {
193 std::cout <<
"[FINDACTIONS::" << __func__ <<
"] no singleJointMultipleTips with " << nFinger <<
" found" << std::endl;
194 return mapOfSingleJointMultipleTips;
199 for (
auto& it : mapOfSingleJointMultipleTips) {
202 std::set<std::string>
set;
203 set.insert (it.first);
204 mapForWorker.insert (std::make_pair (
set, pointer ) );
208 yamlWorker.
createYamlFile(mapForWorker, actionName, path2saveYaml);
210 return mapOfSingleJointMultipleTips;
219 std::cerr <<
"[ERROR " << __func__ <<
"] for this find pass at least 3 as number " <<
220 " of fingertips for the pinch" << std::endl;
221 return multiplePinchMap;
227 if (multiplePinchMap.size() == 0 ) {
228 return multiplePinchMap;
232 for (
auto& it : multiplePinchMap) {
235 mapForWorker.insert (std::make_pair ( it.first, pointer ) );
239 yamlWorker.
createYamlFile(mapForWorker, multiplePinchMap.begin()->second.getName(), path2saveYaml);
241 return multiplePinchMap;
253 planning_scene::PlanningScene planning_scene (
parserMoveIt->getRobotModel() );
254 collision_detection::CollisionRequest collision_request;
255 collision_detection::CollisionResult collision_result;
262 collision_request.contacts =
true;
263 collision_request.max_contacts = 1000;
269 collision_detection::AllowedCollisionMatrix acm;
270 acm.setEntry(
parserMoveIt->getRobotModel()->getLinkModelNames(),
271 parserMoveIt->getRobotModel()->getLinkModelNames(),
true);
275 robot_state::RobotState kinematic_state(
parserMoveIt->getRobotModel());
279 std::stringstream logCollision;
280 collision_result.clear();
284 planning_scene.checkSelfCollision(collision_request, collision_result, kinematic_state, acm);
286 if (collision_result.collision) {
289 for (
auto cont : collision_result.contacts){
295 logCollision <<
"[FINDACTIONS::" << __func__ <<
"] Collision between " << cont.first.first <<
" and " <<
296 cont.first.second << std::endl;
298 for (
auto contInfo : cont.second){
299 logCollision <<
"\tWith a depth of contact: " << contInfo.depth;
311 auto itFind = mapOfPinches.find ( fingerPair );
312 if ( itFind == mapOfPinches.end() ) {
314 mapOfPinches.insert ( std::make_pair (fingerPair, pinch) );
315 logCollision <<
", NEW INSERTION";
318 if (itFind->second.insertActionState( jointPos, cont.second.at(0)) ) {
319 logCollision <<
", NEW INSERTION";
322 logCollision << std::endl;
323 logCollision << jointPos;
336 robot_state::RobotState kinematic_state(
parserMoveIt->getRobotModel());
343 for (
auto &mapEl : *mapOfLoosePinches) {
352 Eigen::Affine3d tip1Trasf = kinematic_state.getGlobalLinkTransform(tips.first);
353 Eigen::Affine3d tip2Trasf = kinematic_state.getGlobalLinkTransform(tips.second);
354 double distance = (tip1Trasf.translation() - tip2Trasf.translation() ) .norm() ;
356 mapEl.second.insertActionState( jointPosLoose, distance ) ;
357 mapEl.second.setJointsInvolvedCount ( jointsInvolvedCount );
365 robot_model::RobotModelPtr kinematic_model_noBound) {
367 for (
auto mapEl : *mapOfLoosePinches ) {
372 auto joints =
parserMoveIt->getJointsOfFingertipMap().at (tips.first);
373 for ( std::string joint : joints ) {
374 auto jointModel = kinematic_model_noBound ->getJointModel(joint);
376 auto type = jointModel->getType() ;
377 if (type == moveit::core::JointModel::REVOLUTE ) {
379 auto bound = jointModel->getVariableBounds().at(0);
380 bound.max_position_ = EIGEN_PI;
381 bound.min_position_ = -EIGEN_PI;
383 jointModel->setVariableBounds ( jointModel->getVariableNames().at(0), bound );
385 }
else if ( type == moveit::core::JointModel::PRISMATIC ) {
387 std::cout <<
"[WARNING FINDACTIONS::" << __func__ <<
"] I am doubling the bounds for your prismatic joint " 388 <<
"but I am not sure it is enough to make the tips colliding to find the loose pinches " <<
390 auto bound = jointModel->getVariableBounds().at(0);
391 bound.max_position_ *= 2;
392 bound.min_position_ *= 2;
394 jointModel->setVariableBounds ( jointModel->getVariableNames().at(0), bound );
398 std::cout <<
"[FINDACTIONS::" << __func__ <<
"] Why are you using a type " 399 << kinematic_model_noBound ->getJointModel(joint)->getType()
400 <<
" joint? Code not ready to temporarily delete the multiple dof bounds" 401 <<
" in the job done to find the loose pinches " << std::endl << std::endl;
408 auto joints2 =
parserMoveIt->getJointsOfFingertipMap().at (tips.second);
409 for (
auto joint : joints2 ) {
411 auto jointModel = kinematic_model_noBound ->getJointModel(joint);
412 auto type = jointModel->getType() ;
413 if (type == moveit::core::JointModel::REVOLUTE ) {
415 auto bound = jointModel->getVariableBounds().at(0);
416 bound.max_position_ = EIGEN_PI;
417 bound.min_position_ = -EIGEN_PI;
419 jointModel->setVariableBounds ( jointModel->getVariableNames().at(0), bound );
421 }
else if ( type == moveit::core::JointModel::PRISMATIC ) {
423 std::cout <<
"[WARNING FINDACTIONS::" << __func__ <<
"] I am doubling the bounds for your prismatic joint " 424 <<
"but I am not sure it is enough to make the tips colliding to find the loose pinches " << std::endl;
425 auto bound = jointModel->getVariableBounds().at(0);
426 bound.max_position_ *= 2;
427 bound.min_position_ *= 2;
429 jointModel->setVariableBounds ( jointModel->getVariableNames().at(0), bound );
433 std::cout <<
"[FINDACTIONS::" << __func__ <<
"] Why are you using a type " 434 << kinematic_model_noBound ->getJointModel(joint)->getType()
435 <<
" joint? Code not ready to temporarily delete the multiple dof bounds" 436 <<
" in the working done to find the loose pinches " << std::endl << std::endl;
448 robot_model::RobotModelPtr kinematic_model_noBound =
parserMoveIt->getCopyModel();
452 collision_detection::AllowedCollisionMatrix acm;
453 acm.setEntry(kinematic_model_noBound->getLinkModelNames(),
454 kinematic_model_noBound->getLinkModelNames(),
true);
456 for(
auto it : *mapOfLoosePinches) {
459 std::string tip1 =
parserMoveIt->getFingertipOfFinger(it.first.first);
460 std::string tip2 =
parserMoveIt->getFingertipOfFinger(it.first.second);
461 acm.setEntry(tip1, tip2,
false);
464 planning_scene::PlanningScene planning_scene(kinematic_model_noBound);
466 collision_detection::CollisionRequest collision_request;
467 collision_detection::CollisionResult collision_result;
468 collision_request.contacts =
true;
469 collision_request.max_contacts = 1000;
471 robot_state::RobotState kinematic_state(kinematic_model_noBound);
474 std::set < std::pair<std::string, std::string> > collidingFingers ;
476 collision_result.clear();
479 planning_scene.checkSelfCollision(collision_request, collision_result, kinematic_state, acm);
481 for (
auto cont : collision_result.contacts){
488 for (
auto mapEl = mapOfLoosePinches->cbegin(); mapEl != mapOfLoosePinches->cend() ; ) {
490 if (collidingFingers.count(mapEl->first) == 0 ) {
491 mapOfLoosePinches->erase(mapEl++);
503 unsigned int nMinCollision = strict ?
506 planning_scene::PlanningScene planning_scene (
parserMoveIt->getRobotModel() );
507 collision_detection::CollisionRequest collision_request;
508 collision_detection::CollisionResult collision_result;
509 collision_request.contacts =
true;
510 collision_request.max_contacts = 1000;
515 collision_detection::AllowedCollisionMatrix acm;
516 acm.setEntry(
parserMoveIt->getRobotModel()->getLinkModelNames(),
517 parserMoveIt->getRobotModel()->getLinkModelNames(),
true);
521 robot_state::RobotState kinematic_state(
parserMoveIt->getRobotModel());
525 collision_result.clear();
528 planning_scene.checkSelfCollision(collision_request, collision_result, kinematic_state, acm);
530 if (collision_result.contacts.size() >= nMinCollision ) {
533 std::set <std::string> tipsColliding;
534 for (
auto cont : collision_result.contacts){
536 tipsColliding.insert(cont.first.first);
537 tipsColliding.insert(cont.first.second);
538 depthSum += std::abs(cont.second.at(0).depth);
543 if (tipsColliding.size() != nFinger) {
555 auto itFind = mapOfMultPinches.find ( fingerColliding );
556 if ( itFind == mapOfMultPinches.end() ) {
558 mapOfMultPinches.insert ( std::make_pair (fingerColliding, pinch) );
561 if (itFind->second.insertActionState( jointPos, depthSum ) ) {
569 return mapOfMultPinches;
579 std::map <std::string, ActionTrig> trigMap;
581 for (
auto mapEl :
parserMoveIt->getFingertipsOfJointMap()) {
583 if (mapEl.second.size() != 1) {
587 if (
parserMoveIt->checkIfContinuosJoint(mapEl.first) == true ) {
592 double trigMax =
parserMoveIt->getBiggerBoundFromZero(mapEl.first).at(0) ;
594 ActionTrig action (
"trig", ActionPrimitive::Type::Trig);
607 std::map <std::string, ROSEE::ActionTrig> tipFlexMap;
609 for (
auto tipName :
parserMoveIt->getFingertipNames() ) {
611 if (
parserMoveIt->getNExclusiveJointsOfTip ( tipName,
false ) < 2 ) {
616 std::string theInterestingJoint =
parserMoveIt->getFirstActuatedParentJoint ( tipName,
false );
617 double tipFlexMax =
parserMoveIt->getBiggerBoundFromZero ( theInterestingJoint ).at(0) ;
620 ActionTrig action (
"tipFlex", ActionPrimitive::Type::TipFlex);
627 std::cout <<
"[FATAL ERROR FINDACTIONS::" << __func__ <<
"]: Inserting in tipFlexMap a tip already present??" << std::endl
628 <<
"I am returning a not completely filled map" << std::endl;
639 std::map <std::string, ROSEE::ActionTrig> fingFlexMap;
641 for (
auto tipName :
parserMoveIt->getFingertipNames() ) {
643 if (
parserMoveIt->getNExclusiveJointsOfTip ( tipName,
false ) < 2 ) {
648 std::string theInterestingJoint =
parserMoveIt->getFirstActuatedJointInFinger ( tipName );
649 double fingFlexMax =
parserMoveIt->getBiggerBoundFromZero ( theInterestingJoint ).at(0) ;
651 ActionTrig action (
"fingFlex", ActionPrimitive::Type::FingFlex);
658 std::cout <<
"[FATAL ERROR FINDACTIONS::" << __func__ <<
"]: Inserting in fingFlexMap a tip already present??n" << std::endl
659 <<
"I am returning a not completely filled map" << std::endl;
671 if ( itMap == trigMap.end() ) {
677 jp.insert ( std::make_pair ( it->getName(), jPos ));
681 jp.at ( jointName ).at(0) = trigValue;
691 JointPos jp = itMap->second.getJointPos();
693 jp.at (jointName).at(0) = trigValue;
694 itMap->second.setJointPos(jp);
708 for (
auto actJ :
parserMoveIt->getActiveJointModels()) {
710 const double* pos = kinematic_state->getJointPositions(actJ);
711 unsigned posSize =
sizeof(pos) /
sizeof(
double);
712 std::vector <double> vecPos(pos, pos + posSize);
713 jp.insert(std::make_pair(actJ->getName(), vecPos));
724 for (
auto fingerEl1 :
parserMoveIt->getFingertipOfFingerMap() ) {
725 for (
auto fingerEl2 :
parserMoveIt->getFingertipOfFingerMap() ) {
728 if (fingerEl1.first < fingerEl2.first) {
729 mapOfLoosePinches->insert (std::make_pair (std::make_pair (fingerEl1.first, fingerEl2.first),
ActionPinchLoose(fingerEl1.first, fingerEl2.first)));
731 }
else if (fingerEl1.first > fingerEl2.first) {
732 mapOfLoosePinches->insert (std::make_pair (std::make_pair (fingerEl2.first, fingerEl1.first),
ActionPinchLoose(fingerEl2.first, fingerEl1.first)));
738 for (
const auto mapEl : *mapOfPinches){
739 mapOfLoosePinches->erase(mapEl.first);
747 std::pair < std::string, std::string > tipsNames,
JointPos *jPos) {
751 for (
auto &jp : *jPos) {
753 jointsInvolvedCount.insert ( std::make_pair (jp.first, 1) );
770 std::vector < std::string> tips =
parserMoveIt->getFingertipsOfJointMap().at(jp.first);
773 if (std::find (tips.begin(), tips.end(), tipsNames.first) == tips.end() &&
774 std::find (tips.begin(), tips.end(), tipsNames.second) == tips.end() ) {
777 jointsInvolvedCount.at ( jp.first ) = 0;
781 return jointsInvolvedCount;
786 std::set< std::string > tipsNames,
JointPos *jPos) {
790 for (
auto &jp : *jPos) {
792 jointsInvolvedCount.insert ( std::make_pair (jp.first, 0) );
795 std::vector < std::string> tips =
parserMoveIt->getFingertipsOfJointMap().at(jp.first);
801 for (
auto fingInv : tipsNames ) {
802 if (std::find (tips.begin(), tips.end(), fingInv) != tips.end()) {
803 jointsInvolvedCount.at ( jp.first ) = 1 ;
808 if (jointsInvolvedCount.at ( jp.first ) == 0 ) {
814 return jointsInvolvedCount;
820 for (
auto joint :
parserMoveIt->getPassiveJointNames()){
821 kinematic_state->setJointPositions(joint, &pos);
832 kinematic_state->setToRandomPositions();
847 double fatherPos = kinematic_state->getJointPositions(el.second.first)[0];
851 p.DefineVar(
"x", &fatherPos);
852 p.SetExpr(el.second.second);
856 catch (mu::Parser::exception_type &e)
858 std::cout << e.GetMsg() << std::endl;
859 std::cout <<
"[FINDACTIONS " << __func__ <<
"] Parsing of non linear function for mimic joint " 860 <<
"'" << el.first <<
"'. Please be sure to put characther 'x' as (unique) variable for father position" 861 <<
"in the expression. Have you used syntax valid for muparser?. Expression found: '" 862 << el.second.second <<
"'" << std::endl;
869 std::vector<double> one_dof ;
870 one_dof.push_back(mimPos);
874 kinematic_state->getJointModel(el.first)->enforcePositionBounds(one_dof.data());
875 kinematic_state->setJointPositions(el.first, one_dof);
889 std::pair <std::string, std::string> fingersPair = std::make_pair (
894 if ( fingersPair.first.compare (fingersPair.second) > 0 ) {
895 auto temp = fingersPair.first;
896 fingersPair.first = fingersPair.second;
897 fingersPair.second = temp;
899 }
else if (fingersPair.first.compare (fingersPair.second) == 0 ) {
900 std::cout <<
"[FINDACTIONS " << __func__ <<
"] STRANGE ERROR: '" << tipsPair.first <<
901 "' and '" << tipsPair.second <<
"' are in the same finger '" << fingersPair.first <<
902 "' so this pair can't perform a pinch" << std::endl;
903 return std::pair<std::string, std::string>();
911 std::set <std::string> fingersSet;
912 for (
auto it : tipsSet) {
914 fingersSet.insert (
parserMoveIt->getFingerOfFingertip ( it ) );
918 if ( fingersSet.size() < tipsSet.size() ) {
919 std::cout <<
"[FINDACTIONS " << __func__ <<
"] STRANGE ERROR: " <<
920 "the tipsSet passed has some fingertips that belong to the same finger." 921 <<
" I will return an empty set " << std::endl;
923 return std::set <std::string>();
931 std::pair <std::string, std::string> tipsPair = std::make_pair (
933 parserMoveIt->getFingertipOfFinger(fingersPair.second) );
936 if ( tipsPair.first.compare (tipsPair.second) > 0 ) {
937 auto temp = tipsPair.first;
938 tipsPair.first = tipsPair.second;
939 tipsPair.second = temp;
941 }
else if (tipsPair.first.compare (tipsPair.second) == 0 ) {
942 std::cout <<
"[FINDACTIONS " << __func__ <<
"] STRANGE ERROR: '" << fingersPair.first <<
943 "' and '" << fingersPair.second <<
"' have the same fingertip '" << tipsPair.first <<
944 "' so this pair can't perform a pinch" << std::endl;
945 return std::pair<std::string, std::string>();
void setJointPos(JointPos)
Virtual class, Base of all the primitive actions.
std::map< std::string, ROSEE::ActionSingleJointMultipleTips > findSingleJointMultipleTips(unsigned int nFinger, std::string path2saveYaml)
std::map< std::string, std::pair< std::string, std::string > > mimicNLRelMap
std::map< std::string, ROSEE::ActionTrig > tipFlex()
We start from each tip.
void checkDistances(std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchLoose > *mapOfLoosePinches)
Principal function which fill the mapOfLoosePinches basing on minumun distance between tips...
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action.
void setJointsInvolvedCount(ROSEE::JointsInvolvedCount jointsInvolvedCount)
Class to describe the action of "pinching" with more than 2 tips (with 2 tips there is the ActionPinc...
void checkWhichTipsCollideWithoutBounds(std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchLoose > *mapOfLoosePinches)
Function similar to checkCollisions but used for Loose Pinches.
std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchTight > checkCollisions()
principal function which check for collisions with moveit functions when looking for tight pinches ...
std::pair< std::string, std::string > getFingersPair(std::pair< std::string, std::string > tipsPair) const
Giving as argument a pair of fingertips, this function return a pair of fingers that are the fingers ...
The action of pinch with two tips.
void setToDefaultPositionPassiveJoints(moveit::core::RobotState *kinematic_state)
set to DEFAULT_JOINT_POS all the passive joints (defined so in the urdf file).
std::map< std::set< std::string >, ROSEE::ActionMultiplePinchTight > findMultiplePinch(unsigned int nFinger, std::string path2saveYaml, bool strict=true)
Finder for MultiplePinch (a pinch done with more than 2 finger).
std::shared_ptr< ROSEE::ParserMoveIt > parserMoveIt
std::pair< std::string, std::string > getFingertipsPair(std::pair< std::string, std::string > fingersPair) const
Given the fingersPair, this function return the pair of their fingers, in lexicographical order...
#define N_EXP_COLLISION_MULTPINCH
void removeBoundsOfNotCollidingTips(const std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchLoose > *mapOfLoosePinches, robot_model::RobotModelPtr kinematic_model_noBound)
Support function to remove the joint limits from the model.
std::map< std::string, ROSEE::ActionTrig > fingFlex()
We start from each tip.
std::map< std::string, ActionTrig > trig()
trig is the action of closing a SINGLE finger towards the palm.
Type
Enum useful to discriminate each primitive action when, for example, we want to parse a file if you ...
JointPos getConvertedJointPos(const robot_state::RobotState *kinematic_state)
Utility function to take the actuated joint positions from a kinematic_state and returns the same inf...
The action of moving some joints (see later) of a single finger in a full clousure position towards t...
bool insertJointPosForTrigInMap(std::map< std::string, ActionTrig > &trigMap, ROSEE::ActionTrig action, std::string jointName, double trigValue)
Insert/update an ActionTrig in the trigMap.
static int binomial_coefficent(int n, int k)
std::map< std::set< std::string >, ROSEE::ActionMultiplePinchTight > checkCollisionsForMultiplePinch(unsigned int nFinger, bool strict)
support function for findMultiplePinch (a pinch done with more than 2 finger).
void setToRandomPositions(robot_state::RobotState *kinematic_state)
This function set the random position of joint considering:
void fillNotCollidingTips(std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchLoose > *mapOfLoosePinches, const std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchTight > *mapOfPinches)
function to "initialize" the map of ActionPinchLoose mapOfLoosePinches.
std::string getFingerInvolved() const
Specific method of trig to simply return a string instead of the full vector fingersInvolved that in ...
std::map< std::string, ROSEE::ActionTrig > findTrig(ROSEE::ActionPrimitive::Type actionType, std::string path2saveYaml)
Function to look for trigs (trig, tipFlex and fingFlex).
void setFingerInvolved(std::string)
The action of pinch with two tips.
FindActions(std::shared_ptr< ROSEE::ParserMoveIt > parserMoveit)
ROSEE::JointsInvolvedCount setOnlyDependentJoints(std::pair< std::string, std::string > tipsNames, JointPos *jPos)
Given the contact, we want to know the state of the joint to replicate it.
std::set< std::string > getFingersSet(std::set< std::string > tipsSet) const
Function used when looking for multiple pinches.
std::pair< std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchTight >, std::map< std::pair< std::string, std::string >, ROSEE::ActionPinchLoose > > findPinch(std::string path2saveYaml)
Function to look for pinches, both Tight and Loose ones.
Primitive which indicate a motion of n fingers moving ONLY ONE joint.
std::string createYamlFile(const std::map< std::set< std::string >, ActionPrimitive * > mapOfActions, const std::string actionName, std::string pathFolder)
Create/overwrite yaml file and emit info on it about each ActionPrimitive inside the given mapOfActio...
#define DEFAULT_JOINT_POS