46 std::vector < ROSEE::ActionPinchLoose::StateWithDistance > retVect;
50 retVect.push_back(it);
72 std::vector < JointPos > retVect;
76 retVect.push_back(it.first);
84 auto pairRet =
actionStates.insert ( std::make_pair (jp, dist) ) ;
88 auto it = pairRet.first;
108 std::stringstream output;
110 output <<
"ActionName: " <<
name << std::endl;
112 output <<
"FingersInvolved: [";
114 output << fingName <<
", " ;
116 output.seekp (-2, output.cur);
117 output <<
"]" << std::endl;
119 output <<
"JointsInvolvedCount: " << std::endl;;
122 unsigned int nActState = 1;
124 output <<
"Action_State_" << nActState <<
" :" << std::endl;
126 output <<
"\t" <<
"JointStates:" << std::endl;
127 output << itemSet.first;
128 output <<
"\t" <<
"Distance:" << std::endl;
129 output <<
"\t\tdistance " << 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 <<
"JointStates" << 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 <<
"distance" << 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 ActionPinchLoose::" << __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 (
"JointStates") == 0 ) {
215 jointPos = asEl->second.as <
JointPos >();
217 }
else if (asEl->first.as<std::string>().compare (
"Optional") == 0 ) {
218 distance = asEl->second[
"distance"].as <
double >();
222 std::cerr <<
"[ERROR ActionPinchLoose::" << __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, distance));
231 std::cerr <<
"[ERROR ActionPinchLoose::" << __func__ <<
"not know key " << key <<
232 " found in the yaml file" << std::endl;
Type
Enum useful to discriminate each action when, for example, we want to parse a file if you change thi...
std::vector< ROSEE::JointPos > getAllJointPos() const override
Return all the joint position stored.
Virtual class, Base of all the primitive actions.
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action.
std::set< StateWithDistance, distComp > actionStates
For each pair, we want a set of action because we want to store (in general) more possible way to do ...
A base virtual class for the PinchTight and PinchLoose classes.
JointPos getJointPos() const override
Get the position related to this action.
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 ...
JointsInvolvedCount jointsInvolvedCount
const unsigned int maxStoredActionStates
bool fillFromYaml(YAML::const_iterator yamlIt) override
function to fill members of the Action with infos taken from yaml files
void emitYaml(YAML::Emitter &) const override
Function to fill the argument passed with info about the action.
std::vector< ROSEE::ActionPinchLoose::StateWithDistance > getActionStates() const
Specific get for this action to return the state with distance info.
std::set< std::string > fingersInvolved
bool insertActionState(JointPos, double distance)
function to insert a single action in the actionStates set of possible action.