28 std::set <std::string> fingerNamesSet,
54 std::vector < JointPos > retVect;
58 retVect.push_back(it.first);
67 std::vector < ROSEE::ActionMultiplePinchTight::StateWithDepth > retVect;
71 retVect.push_back(it);
81 auto pairRet =
actionStates.insert ( std::make_pair (jp, depthSum) ) ;
83 if (! pairRet.second ) {
90 auto it = pairRet.first;
110 std::stringstream output;
111 output <<
"ActionName: " <<
name << std::endl;
113 output <<
"FingersInvolved: [";
115 output << fingName <<
", " ;
117 output.seekp (-2, output.cur);
118 output <<
"]" << std::endl;
120 output <<
"JointsInvolvedCount: " << std::endl;;
123 unsigned int nActState = 1;
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();
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;
150 out << YAML::Key << jointCount.first;
151 out << YAML::Value << jointCount.second;
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) {
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>() );
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;
unsigned int nFingersInvolved
Type
Enum useful to discriminate each action when, for example, we want to parse a file if you change thi...
Virtual class, Base of all the primitive actions. It has some implemented functions that a derived cl...
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints. The key is the name of the string...
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action. An ActionPrimitive and an ActionCom...
std::vector< ROSEE::ActionMultiplePinchTight::StateWithDepth > getActionStates() const
Specific get for the ActionMultiplePinchTight to return the state with the paired depthSum...
A base virtual class for the PinchTight and PinchLoose classes. It includes member and method that ar...
std::size_t size(custom_string const &s)
void print() const override
Overridable functions, if we want to make them more action-specific.
Type
Enum useful to discriminate each primitive action when, for example, we want to parse a file if you ...
std::set< StateWithDepth, depthComp > actionStates
For each multiple pinch possible, we want a set of action because we want to store (in general) more ...
ActionMultiplePinchTight()
void emitYaml(YAML::Emitter &) const override
Function to fill the argument passed with info about the action. Pure virtual because each derived cl...
bool insertActionState(JointPos, double depthSum)
function to insert a single action in the actionStates set of possible action. If the action is not s...
JointsInvolvedCount jointsInvolvedCount
JointPos getJointPos() const override
Get the position related to this action. Pure Virtual function: the derived class store this info dif...
const unsigned int maxStoredActionStates
bool fillFromYaml(YAML::const_iterator yamlIt) override
function to fill members of the Action with infos taken from yaml files
std::vector< ROSEE::JointPos > getAllJointPos() const override
Return all the joint position stored. If the concrete (derived from Action) has only one joint positi...
std::set< std::string > fingersInvolved