30 int main (
int argc,
char **argv ) {
32 ros::init ( argc, argv,
"FindActions" );
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());
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 =
70 std::map < std::string, ROSEE::ActionSingleJointMultipleTips> singleJointMultipleTipsMap2 =
74 std::map < std::string, ROSEE::ActionSingleJointMultipleTips> singleJointMultipleTipsMap5 =
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;
203 yamlWorker.
createYamlFile (&schunkGrasp, folderForActions +
"/generics/");
208 0, 0.7, 0, 0.4,
"FingerSpread");
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/" );
237 0, 1, 0, 1,
"OpenWide");
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");
265 yamlWorker.
createYamlFile ( &actionTimed, folderForActions +
"/timeds/" );
268 std::cout <<
"The timed action parsed: " << std::endl;
269 mapsHandler.
getTimed(
"drill")->print();
std::string getSrdfString() const
get the whole srdf file parsed as a string
std::map< std::string, ROSEE::ActionSingleJointMultipleTips > findSingleJointMultipleTips(unsigned int nFinger, std::string path2saveYaml)
bool insertAction(ROSEE::Action::Ptr action, double marginBefore=0.0, double marginAfter=0.0, unsigned int jointPosIndex=0, double percentJointPos=1, std::string newActionName="")
Insert an action as last one in the time line.
std::string getUrdfString() const
get the whole urdf file parsed as a string
std::shared_ptr< ActionComposed > Ptr
int main(int argc, char **argv)
bool init()
Initialization function using the ROS param ROSEEConfigPath.
A ActionComposed, which is formed by one or more Primitives (or even other composed).
std::string getEndEffectorName() const
getter for the configure End-Effector name
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).
bool parseAllPrimitives(std::string pathFolder)
std::vector< ActionPrimitiveMap > getPrimitiveMap(ROSEE::ActionPrimitive::Type type) const
getter to take all the primitives maps of one type (
std::string getActionPath() const
get the path where emit and parse grasping actions
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
std::map< std::string, ROSEE::ActionTrig > findTrig(ROSEE::ActionPrimitive::Type actionType, std::string path2saveYaml)
Function to look for trigs (trig, tipFlex and fingFlex).
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...
void print() const override
Print info about this action.
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.
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...