本文整理汇总了C++中Hypothesis::getObservationGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ Hypothesis::getObservationGroup方法的具体用法?C++ Hypothesis::getObservationGroup怎么用?C++ Hypothesis::getObservationGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hypothesis
的用法示例。
在下文中一共展示了Hypothesis::getObservationGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTarget
void Observations::setTarget(UnitObserver* o) {
UnitObserverType type = o->getType();
if (mPendingRequests.empty() && type != GLOBAL) {
//nothing to do
o->setIdle();
//EventLog::GetInstance().logEvent("IDLE "+o->getName());
return;
}
LOG_INFO("Setting new target for observer "+o->getName());
//if we have the same number of observers as hypotheses, then don't move them from their target group after it is set
if (mNumObservers >= mNumObservableGroups && o->hasTargetUnits()) {
//see if we're requesting this hypothesis again
std::deque<Hypothesis*>::iterator hit = std::find(mPendingRequests.begin(), mPendingRequests.end(), o->getHypothesis());
if (hit != mPendingRequests.end()) {
o->setTarget(o->getHypothesis(), o->getTargetGroup(), (float)o->getAltitude(), o->getTargetDuration());
mPendingRequests.erase(hit);
}
//EventLog::GetInstance().logEvent("FULL "+o->getName());
return;
}
switch (type) {
case GLOBAL: {
//move to the centre of the observed groups
/*std::vector<dtCore::RefPtr<UnitGroup> > groups = theApp->getTargets()->groupUnits(5000, RED);
if (groups.size() > 0) {
UnitGroup* g = groups[0].get();
osg::Vec3 centre = g->getCentre();
float radius = g->getRadius();
centre.z() += radius;
o->setTarget(centre, 1);
}*/
}
break;
case SEQUENTIAL: {
//nearest neighbour (+ priorities) from start position, and wait 5 seconds
float dMax = theApp->getTerrain()->GetHorizontalSize() * sqrt(2); //size of map
std::deque<Hypothesis*>::iterator it;
float dMin = std::numeric_limits<float>::max();
dtCore::RefPtr<UnitGroup> group;
Hypothesis* hypothesis = NULL;
for (it = mPendingRequests.begin(); it != mPendingRequests.end(); it++) {
dtCore::RefPtr<UnitGroup> g = (*it)->getObservationGroup();
float d = (g->getCentre() - o->getPosition()).length();
//normalise
d /= dMax;
//add in hypothesis priorities
float p = d + (*it)->getPriority();
//
LOG_INFO("Hypothesis group "+boost::lexical_cast<std::string>((*it)->getName())+": Priority "+boost::lexical_cast<std::string>(p)+" ("+boost::lexical_cast<std::string>(d)+" + "+boost::lexical_cast<std::string>((*it)->getPriority()))
//std::cout << (*it)->getName() << ":d" << d <<",t"<<(*it)->getPriority()<<",p"<<p<<std::endl;
if (p < dMin) {
dMin = p;
group = g;
hypothesis = *it;
}
}
//dtCore::RefPtr<UnitGroup> u = nearestNeighbour(o->getPosition(), mPendingRequests);
//o->setTarget(u.get(), 500, 2);
//TODO set duration and altitude properly
o->setTarget(hypothesis, group.get(), 500, theApp->getObservationDuration());
mPendingRequests.erase(std::find(mPendingRequests.begin(), mPendingRequests.end(), hypothesis));
}
break;
case ROUND_ROBIN: {
if (!mPendingRequests.empty()) {
//EventLog::GetInstance().logEvent("OBST "+mPendingRequests.front()->getName());
o->setTarget(mPendingRequests.front(), mPendingRequests.front()->getObservationGroup().get(), 500, theApp->getObservationDuration());
mPendingRequests.pop_front();
}
/*std::queue<Hypothesis*>::iterator it = mPendingRequests.begin();
if (it != mPendingRequests.end()) {
mPendingRequests.erase(it);
}*/
}
break;
case THREAT: {
//calculate resultant threat of observing each target
//decide what target each observee is going to...
//conf > 0.5. conf decays (or variance increases) without observations.
//target certainty... take closest if conf < 0.5 or if variance = global variance
//err, lets just take closest for now...
osg::Vec3 oPos = theApp->mapPointToTerrain(o->getPosition());
std::deque<Hypothesis*>::iterator it;
dtCore::RefPtr<UnitGroup> group;
Hypothesis* hypothesis = NULL;
UnitGroup* predictedGroup = NULL;
UnitGroup* closestGroup = NULL;
float confidence = 0;
float minLeeway = std::numeric_limits<float>::max();
for (it = mPendingRequests.begin(); it != mPendingRequests.end(); it++) {
dtCore::RefPtr<UnitGroup> g = (*it)->getObservationGroup();
osg::Vec3 gPos = g->getCentreCurrent();
//float gRadius = g->getRadius();
std::vector<dtCore::RefPtr<UnitGroup> > targetGroups = (*it)->getTargetGroups();
//.........这里部分代码省略.........