34 this->initialDescription = b.initialDescription;
35 this->subActions = b.subActions;
43 bSub.addString(
"description");
44 bSub.addList() = initialDescription.
asBottle();
47 bSub.addString(
"subactions");
48 Bottle& subs = bSub.addList();
49 for(
auto& subAction : subActions)
51 subs.addList()=subAction.asBottle();
56 bSub.addString(
"estimatedDriveEffects");
57 Bottle &subss = bSub.addList();
60 Bottle &ss = subss.addList();
61 ss.addString(estimatedDriveEffect.first.c_str());
62 ss.addDouble(estimatedDriveEffect.second);
73 if (!b.check(
"description")||!b.check(
"subactions"))
76 Bottle* bDesc = b.find(
"description").asList();
79 this->subActions.clear();
80 Bottle* bSub = b.find(
"subactions").asList();
81 for(
unsigned int i=0; i<bSub->size(); i++)
85 this->subActions.push_back(a);
89 bSub = b.find(
"estimatedDriveEffects").asList();
90 for(
unsigned int i=0; i<bSub->size(); i++)
92 string driveName = bSub->get(i).asList()->get(0).asString().c_str();
93 double driveEffect = bSub->get(i).asList()->get(1).asDouble();
107 string initial = this->
asBottle().toString().c_str();
108 string final = initial.c_str();
119 Bottle b(
final.c_str());
133 subActions.push_back(a);
138 list<Action> unrolled;
139 if (this->subActions.size() == 0) {
140 unrolled.push_back(*
this);
142 for(
const auto& it : subActions)
144 list<Action> subUnrolled = it.asPlan();
145 unrolled.splice(unrolled.end(), subUnrolled);
154 list<Action> unrolled = expressed.
asPlan();
163 driveEffects[sIt->first] += sIt->second;
167 for(list<Action>::iterator it = subActions.begin(); it != subActions.end() ; it++)
169 it->getPlanDrivesEffect(driveEffects);
174 return toString(this->initialDescription);
179 std::ostringstream oss;
180 oss<<
"Unrolling: "<<newRelation.
toString()<<endl;
181 list<Action> unrolled = this->
asPlan(newRelation);
183 for(list<Action>::iterator it = unrolled.begin() ; it!=unrolled.end(); it++,count++)
185 oss<<
'\t'<<count<<
")"<<it->description().toString()<<endl;
void fromBottle(const yarp::os::Bottle &b)
Create a Relation from a Bottle.
std::string complement_manner() const
Get the complement of manner of the relation.
virtual bool fromBottle(const yarp::os::Bottle &b)
Fill entity fields from a bottle representation.
virtual yarp::os::Bottle asBottle() const
Number of subactions composing this one.
yarp::os::Bottle asBottle(bool ignoreID=false) const
virtual void getPlanDrivesEffect(std::map< std::string, double > &driveEffects)
Estimate the effect of this plan on a specific drive, by summing all the effects of subplans to this ...
Represent any entity that can be stored within the OPC.
void append(Action &a)
Append a subaction to create a composite one.
virtual std::string toString() const
Return string representation of this Relation.
std::string subject() const
Get the name of the relation's subject.
std::string complement_time() const
Get the complement of time of the relation.
virtual std::list< Action > asPlan() const
Get an unrolled plan description.
void replace_all(std::string &in, const std::string &plain, const std::string &tok)
Simple search and replace function for strings;.
Represents an action, whether composite or not.
Relation description() const
Return initialDescription as Relation.
std::string complement_place() const
Get the complement of place of the relation.
std::string object() const
Get the name of the relation's object.
virtual bool fromBottle(const yarp::os::Bottle &b)
Fill entity fields from a bottle representation.
void setInitialDescription(const Relation &r)
Represent a relation between two entities.
virtual yarp::os::Bottle asBottle() const
Return the entity as a bottle.
std::map< std::string, double > estimatedDriveEffects
Estimated effects on the drive.
std::string m_entity_type
virtual std::string toString() const
Return a human readable description of the entity.
Action express(const Relation &r) const