28 std::set <std::string> fingerNamesSet,
40 return (actionStates.begin()->first);
44 auto it = actionStates.begin();
54 std::vector < JointPos > retVect;
55 retVect.reserve ( actionStates.size() );
57 for (
auto it : actionStates ) {
58 retVect.push_back(it.first);
67 std::vector < ROSEE::ActionMultiplePinchTight::StateWithDepth > retVect;
68 retVect.reserve ( actionStates.size() );
70 for (
auto it : actionStates ) {
71 retVect.push_back(it);
81 auto pairRet = actionStates.insert ( std::make_pair (jp, depthSum) ) ;
83 if (! pairRet.second ) {
88 if (actionStates.size() > maxStoredActionStates) {
90 auto it = pairRet.first;
92 if ( (++it) == actionStates.end() ){
94 actionStates.erase(pairRet.first);
99 auto lastElem = actionStates.end();
101 actionStates.erase(lastElem);
110 std::stringstream output;
111 output <<
"ActionName: " <<
name << std::endl;
113 output <<
"FingersInvolved: [";
114 for (
auto fingName : fingersInvolved){
115 output << fingName <<
", " ;
117 output.seekp (-2, output.cur);
118 output <<
"]" << std::endl;
120 output <<
"JointsInvolvedCount: " << std::endl;;
121 output << jointsInvolvedCount << std::endl;
123 unsigned int nActState = 1;
124 for (
auto itemSet : actionStates) {
125 output <<
"Action_State_" << nActState <<
" :" << std::endl;
127 output <<
"\t" <<
"JointStates:" << std::endl;
128 output << itemSet.first;
129 output <<
"\t" <<
"DepthSum:" << itemSet.second <<std::endl;
135 std::cout << output.str();
142 out << YAML::Key << YAML::Flow << fingersInvolved;
144 unsigned int nCont = 1;
145 out << YAML::Value << YAML::BeginMap;
146 out << YAML::Key <<
"PrimitiveType" << YAML::Value << primitiveType;
147 out << YAML::Key <<
"ActionName" << YAML::Value <<
name;
148 out << YAML::Key <<
"JointsInvolvedCount" << YAML::Value << YAML::BeginMap;
149 for (
const auto &jointCount : jointsInvolvedCount ) {
150 out << YAML::Key << jointCount.first;
151 out << YAML::Value << jointCount.second;
155 for (
const auto & actionState : actionStates) {
157 std::string contSeq =
"ActionState_" + std::to_string(nCont);
158 out << YAML::Key << contSeq;
160 out << YAML::Value << YAML::BeginMap;
162 out << YAML::Key <<
"JointPos" << YAML::Value << YAML::BeginMap;
163 for (
const auto &joint : actionState.first) {
164 out << YAML::Key << joint.first;
165 out << YAML::Value << YAML::Flow << joint.second;
170 out << YAML::Key <<
"Optional" << YAML::Value << YAML::BeginMap;
171 out << YAML::Key <<
"DepthSum" << YAML::Value << actionState.second;
184 std::vector <std::string> fingInvolvedVect = yamlIt->first.as <std::vector < std::string >> ();
185 for (
const auto &it : fingInvolvedVect) {
186 fingersInvolved.insert(it);
189 for ( YAML::const_iterator keyValue = yamlIt->second.begin(); keyValue != yamlIt->second.end(); ++keyValue) {
191 std::string key = keyValue->first.as<std::string>();
192 if (key.compare(
"JointsInvolvedCount") == 0) {
195 }
else if (key.compare (
"ActionName") == 0 ) {
196 name = keyValue->second.as <std::string> ();
198 }
else if (key.compare (
"PrimitiveType") == 0) {
200 keyValue->second.as <
unsigned int>() );
201 if (parsedType != primitiveType ) {
202 std::cerr <<
"[ERROR ActionMultPinch::" << __func__ <<
" parsed a type " << parsedType <<
203 " but this object has primitive type " << primitiveType << std::endl;
207 }
else if (key.compare(0, 12,
"ActionState_") == 0) {
211 for(YAML::const_iterator asEl = keyValue->second.begin(); asEl != keyValue->second.end(); ++asEl) {
214 if (asEl->first.as<std::string>().compare (
"JointPos") == 0 ) {
215 jointPos = asEl->second.as <
JointPos >();
217 }
else if (asEl->first.as<std::string>().compare (
"Optional") == 0 ) {
218 depthSum = asEl->second[
"DepthSum"].as <
double >();
222 std::cerr <<
"[ERROR ActionMultPinch::" << __func__ <<
"not know key "
223 << asEl->first.as<std::string>() <<
224 " found in the yaml file at this level" << std::endl;
228 actionStates.insert ( std::make_pair (jointPos, depthSum));
231 std::cerr <<
"[ERROR ActionMultPinch::" << __func__ <<
"not know key " << key <<
232 " found in the yaml file" << std::endl;
237 nFingersInvolved = fingersInvolved.size();