30 int main (
int argc,
char **argv ) {
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") ) {
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::vector< ActionPrimitiveMap > getPrimitiveMap(ROSEE::ActionPrimitive::Type type) const
getter to take all the primitives maps of one type (
std::shared_ptr< ROSEE::ActionTimed > getTimed(std::string name) const
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::shared_ptr< ActionComposed > Ptr
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool init()
Initialization function using the ROS param ROSEEConfigPath.
A ActionComposed, which is formed by one or more Primitives (or even other composed). It is useful for example to create an action that grasp only with bending the tips (e.g. to take a dish from above) If the ActionComposed has the boolean value independent to true, it means that include indipendent sub-actions, so, each joint is used by at maximum by ONLY ONE of the sub-action inside. In this case the jointsInvolvedCount will contain only 0 or 1 values. If the ActionComposed is not independent, each joint position is calculated as the mean of all the joint position of the contained sub-actions that uses that joint. So each mean can include different primitives, so we used the jointsInvolvedCount vector to store the number of sub action that use each joint.
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). This function return the found multp...
ROSEE::ActionPrimitive::Ptr getPrimitive(std::string primitiveName, std::set< std::string > key) const
bool parseAllPrimitives(std::string pathFolder)
std::string getEndEffectorName() const
getter for the configure End-Effector name
std::string getUrdfString() const
get the whole urdf file parsed as a string
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.
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). The type of trig to be looked for is choosen...
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...
#define ROS_INFO_STREAM(args)
void print() const override
Print info about this action.
void setParam(const std::string &key, const XmlRpc::XmlRpcValue &v) const
#define ROS_ERROR_STREAM(args)
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. It fill the maps (returned as pair)...
std::string getSrdfString() const
get the whole srdf file parsed as a string
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...