********************* PARSING TEST and print... these things should not be here
**************************** COMPOSITE ACTION THINGS ************************************************
if (mapsHandler.getPrimitiveMap(ROSEE::ActionPrimitive::Type::Trig).size() > 0 && mapsHandler.getPrimitiveMap(ROSEE::ActionPrimitive::Type::Trig).at(0).size() == parserMoveIt->getNFingers() ) {
for (auto trig : mapsHandler.getPrimitiveMap("trig")) { grasp.sumAction (trig.second) ; } grasp.print();
std::cout << "PARSED COMPOSEd" << std::endl; mapsHandler.getGeneric("grasp")->print();
} else { //look if we have a single singleJointMultipleTips_MAXFINGER: it is 99% a grasp
**************************** SIMPLE ACTION MANUALLY CREATED ***********************************************
mapsHandler.parseAllGenerics (folderForActions + "/generics/"); //NOTE already called before
std::cout << "The parsed casual: " << std::endl; mapsHandler.getGeneric("casual")->print(); }
**************************** TIMED ACTION THINGS***************************** EXAMPLE ONLY VALID FOR SPECIFIC HANDS
32 ros::init ( argc, argv,
"FindActions" );
38 nh.setParam(
"/robot_description", parser.getUrdfString());
39 nh.setParam(
"/robot_description_semantic", parser.getSrdfString());
40 ROS_INFO_STREAM(
"FINDACTIONS: Set urdf and srdf file in the param server");
42 std::shared_ptr <ROSEE::ParserMoveIt> parserMoveIt = std::make_shared <ROSEE::ParserMoveIt> ();
43 if (! parserMoveIt->init (
"robot_description") ) {
44 ROS_ERROR_STREAM (
"FAILED parserMoveit Init, stopping execution");
48 parserMoveIt->parseNonLinearMimicRelations(parser.getUrdfString());
51 std::string folderForActions = parser.getActionPath();
55 auto maps = actionsFinder.findPinch(folderForActions +
"/primitives/");
57 std::map <std::string, ROSEE::ActionTrig> trigMap = actionsFinder.findTrig (ROSEE::ActionPrimitive::Type::Trig,
58 folderForActions +
"/primitives/") ;
60 std::map <std::string, ROSEE::ActionTrig> tipFlexMap = actionsFinder.findTrig (ROSEE::ActionPrimitive::Type::TipFlex,
61 folderForActions +
"/primitives/");
63 std::map <std::string, ROSEE::ActionTrig> fingFlexMap = actionsFinder.findTrig (ROSEE::ActionPrimitive::Type::FingFlex,
64 folderForActions +
"/primitives/");
65 unsigned int nFinger = 3;
66 std::map < std::string, ROSEE::ActionSingleJointMultipleTips> singleJointMultipleTipsMap =
67 actionsFinder.findSingleJointMultipleTips (nFinger, folderForActions +
"/primitives/") ;
70 std::map < std::string, ROSEE::ActionSingleJointMultipleTips> singleJointMultipleTipsMap2 =
71 actionsFinder.findSingleJointMultipleTips (nFinger, folderForActions +
"/primitives/") ;
74 std::map < std::string, ROSEE::ActionSingleJointMultipleTips> singleJointMultipleTipsMap5 =
75 actionsFinder.findSingleJointMultipleTips (nFinger, folderForActions +
"/primitives/") ;
77 auto mulPinch = actionsFinder.findMultiplePinch(3, folderForActions +
"/primitives/" );
87 std::cout <<
"PARSED MAP OF PINCHESTIGHT FROM YAML FILE:" << std::endl;
91 std::cout <<
"PARSED MAP OF PINCHESLOOSE FROM YAML FILE:" << std::endl;
95 std::cout <<
"PARSED MAP OF TRIGS FROM YAML FILE:" << std::endl;
99 std::cout <<
"PARSED MAP OF TIPFLEX FROM YAML FILE:" << std::endl;
103 std::cout <<
"PARSED MAP OF FINGFLEX FROM YAML FILE:" << std::endl;
107 std::cout <<
"PARSED MAP OF SINGLEJOINTMULTIPLETIPS_3 FROM YAML FILE:" << std::endl;
108 for (
auto &i : mapsHandler.
getPrimitiveMap(
"singleJointMultipleTips_3")) {
111 std::cout <<
"DEBUG MULTIPINCH PARSED: " << std::endl;
185 if (parser.getEndEffectorName().compare(
"schunk") == 0) {
194 schunkGrasp.sumAction (mapsHandler.
getPrimitive(
"trig",
"index"));
195 schunkGrasp.sumAction (mapsHandler.
getPrimitive(
"trig",
"middle"));
196 schunkGrasp.sumAction (mapsHandler.
getPrimitive(
"trig",
"ring"));
197 schunkGrasp.sumAction (mapsHandler.
getPrimitive(
"trig",
"pinky"));
200 schunkGrasp.sumAction (mapsHandler.
getPrimitive(
"trig",
"thumb"), 0.3);
203 yamlWorker.
createYamlFile (&schunkGrasp, folderForActions +
"/generics/");
207 actionTimed.insertAction( mapsHandler.
getPrimitive(
"singleJointMultipleTips_3",
"left_hand_Finger_Spread"),
208 0, 0.7, 0, 0.4,
"FingerSpread");
210 actionTimed.insertAction( mapsHandler.
getPrimitive(
"singleJointMultipleTips_3",
"left_hand_Thumb_Opposition"),
211 0, 0.7, 0, 0.47,
"Opposition");
213 ROSEE::Action::Ptr schunkTipFlexs = std::make_shared<ROSEE::ActionComposed>(
"TipFlexes",
true);
218 schunkTipFlexsCasted->sumAction (mapsHandler.
getPrimitive(
"tipFlex",
"middle"), 0.76);
219 schunkTipFlexsCasted->sumAction (mapsHandler.
getPrimitive(
"trig",
"thumb"), 0.8);
221 actionTimed.insertAction( schunkTipFlexs, 0.6, 0.2, 0, 1,
"TipFlexes");
225 yamlWorker.
createYamlFile ( &actionTimed, folderForActions +
"/timeds/" );
232 }
else if (parser.getEndEffectorName().compare(
"robotiq_3f") == 0) {
236 actionTimed.insertAction( mapsHandler.
getPrimitive(
"singleJointMultipleTips_2",
"palm_finger_1_joint"),
237 0, 1, 0, 1,
"OpenWide");
239 actionTimed.insertAction( mapsHandler.
getPrimitive(
"singleJointMultipleTips_3",
"finger_1_joint_1"),
240 0, 0, 0, 0.6,
"Grasp");
242 yamlWorker.
createYamlFile ( &actionTimed, folderForActions +
"/timeds/" );
245 }
else if (parserMoveIt->getHandName().compare(
"heri_II") == 0 ) {
250 ROSEE::Action::Ptr grasp3f = std::make_shared<ROSEE::ActionComposed>(
"grasp3f",
true);
251 std::shared_ptr<ROSEE::ActionComposed> grasp3f_casted = std::dynamic_pointer_cast<
ROSEE::ActionComposed> (grasp3f);
254 grasp3f_casted->sumAction(mapsHandler.
getPrimitive(
"trig",
"finger_2"));
255 grasp3f_casted->sumAction(mapsHandler.
getPrimitive(
"trig",
"thumb"));
261 actionTimed.insertAction( grasp3f, 0, 0, 0, 1,
"Grasp3f");
262 actionTimed.insertAction( mapsHandler.
getPrimitive(
"trig",
"finger_3"), 3, 0, 0, 1,
"TrigOn");
263 actionTimed.insertAction( mapsHandler.
getPrimitive(
"trig",
"finger_3"), 4, 0, 0, 0,
"TrigOff");
265 yamlWorker.
createYamlFile ( &actionTimed, folderForActions +
"/timeds/" );
268 std::cout <<
"The timed action parsed: " << std::endl;
269 mapsHandler.
getTimed(
"drill")->print();
std::shared_ptr< ActionComposed > Ptr
A ActionComposed, which is formed by one or more Primitives (or even other composed).
bool parseAllPrimitives(std::string pathFolder)
std::vector< ActionPrimitiveMap > getPrimitiveMap(ROSEE::ActionPrimitive::Type type) const
getter to take all the primitives maps of one type (
virtual bool sumAction(ROSEE::Action::Ptr action, double jointPosScaleFactor=1.0, unsigned int jointPosIndex=0)
Function to add another action to this one.
ROSEE::ActionPrimitive::Ptr getPrimitive(std::string primitiveName, std::set< std::string > key) const
std::shared_ptr< ROSEE::ActionTimed > getTimed(std::string name) const
std::shared_ptr< Action > Ptr
An action composed by other ones that must be executed one after other with some wait time (also 0) i...
Class to check which fingertips collide (for the pinch action at the moment)
Class responsible for parsing the YAML file providing the URDF, SRDF, the EE-HAL library implementati...
bool parseAllTimeds(std::string pathFolder)
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...