boost::shared_ptr<ActionObject> SceneEffector::GetActionObject(const Predicate& predicate) { if (predicate.name != GetPredicate()) { GetLog()->Error() << "(SceneEffector) ERROR: invalid predicate" << predicate.name << "\n"; return boost::shared_ptr<ActionObject>(); } string scene; if (! predicate.GetValue(predicate.begin(), scene)) { GetLog()->Error() << "ERROR: (SceneEffector) scene filename expected\n"; return boost::shared_ptr<ActionObject>(); }; boost::shared_ptr<ParameterList> parameters( new ParameterList(predicate.parameter)); parameters->Pop_Front(); return boost::shared_ptr<ActionObject>( new SceneAction(GetPredicate(), scene, parameters)); }
boost::shared_ptr<ActionObject> InitEffector::GetActionObject(const Predicate& predicate) { if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (InitEffector) invalid predicate" << predicate.name << "\n"; return boost::shared_ptr<ActionObject>(); } std::string name; predicate.GetValue(predicate.begin(),"teamname",name); int unum = 0; predicate.GetValue(predicate.begin(),"unum",unum); return boost::shared_ptr<ActionObject>(new InitAction(GetPredicate(),name,unum)); }
void SoccerBehavior::ParseVision(const Predicate& predicate) { ParseObjectVision(predicate); // find the PerfectVision data about the object Predicate::Iterator iter(predicate); // advance to the section about object 'name' if (! predicate.FindParameter(iter,"mypos")) { return; } // read my position VisionSense sense; predicate.GetValue(iter,mMyPos); }
boost::shared_ptr<ActionObject> DriveEffector::GetActionObject(const Predicate& predicate) { if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (DriveEffector) invalid predicate" << predicate.name << "\n"; return boost::shared_ptr<ActionObject>(); } Vector3f force; if (! predicate.GetValue(predicate.begin(), force)) { GetLog()->Error() << "ERROR: (DriveEffector) Vector3f parameter expected\n"; return boost::shared_ptr<ActionObject>(new ActionObject(GetPredicate())); } return boost::shared_ptr<ActionObject>(new DriveAction(GetPredicate(),force)); }
shared_ptr<ActionObject> HMDPEffector::GetActionObject(const Predicate& predicate) { //std::cout << " GetActionObject called " << std::endl; if (predicate.name != GetPredicate()) { GetLog()->Error() << "ERROR: (HMDPEffector) invalid predicate" << predicate.name << "\n"; return shared_ptr<ActionObject>(); } std::string message; if (!predicate.GetValue(predicate.begin(), message)) { GetLog()->Error() << "ERROR: (HMDPEffector) Some Problem while receiving the HMDP Message\n"; return shared_ptr<ActionObject>(); }; inMessage = inMessage + message + "\r\n"; //std::cout << inMessage << std::endl; return shared_ptr<ActionObject>(new HMDPAction(GetPredicate(), inMessage)); }
void SoccerBehavior::ParseObjectVision(const Predicate& predicate) { for ( Predicate::Iterator iter(predicate); iter != iter.end(); ++iter ) { // extract the element as a parameter list Predicate::Iterator paramIter = iter; if (! predicate.DescentList(paramIter)) { continue; } // read the object name string name; if (! predicate.GetValue(paramIter,name)) { continue; } // try read the 'id' section string strId; if (predicate.GetValue(paramIter,"id", strId)) { name += strId; } // try to lookup the VisionObject TVisionObjectMap::iterator visiter = mVisionObjectMap.find(name); if (visiter == mVisionObjectMap.end()) { continue; } VisionObject vo = (*visiter).second; // find the 'pol' entry in the object's section Predicate::Iterator polIter = paramIter; if (! predicate.FindParameter(polIter,"pol")) { continue; } // read the position vector VisionSense sense; if ( (! predicate.AdvanceValue(polIter,sense.distance)) || (! predicate.AdvanceValue(polIter,sense.theta)) || (! predicate.AdvanceValue(polIter,sense.phi)) ) { continue; } // update the vision map // cerr << "+++" << endl; // cerr << "VO " << vo << endl; // cerr << "D " << sense.distance << endl; // cerr << "T " << sense.theta << endl; // cerr << "P " << sense.phi << endl; // cerr << "---" << endl; mVisionMap[vo] = sense; } }