Go to the documentation of this file.00001 #include "Move2DPathFollowerActPosHasGuideNoisyVarRel.h"
00002
00003
00004 Move2DPathFollowerActPosHasGuideNoisyVarRel::Move2DPathFollowerActPosHasGuideNoisyVarRel(SharedPointer<Map2DPosVar> robotPosVar, SharedPointer<BooleanVariable> hasGuideVar, SharedPointer<Map2DPath> path, SharedPointer<ProblemParams> params)
00005 {
00006 this->path = path;
00007 this->hasGuideVar = hasGuideVar;
00008 this->posVar = robotPosVar;
00009 this->params = params;
00010
00011 pathFollower = SharedPointer<Move2DPathFollowerActPosVarRel>( new Move2DPathFollowerActPosVarRel(robotPosVar, path));
00012 this->addSourceVar(this->hasGuideVar);
00013 this->addSourceVar(this->posVar);
00014 this->setDestVariable(this->posVar);
00015 }
00016
00017 Move2DPathFollowerActPosHasGuideNoisyVarRel::~Move2DPathFollowerActPosHasGuideNoisyVarRel(void)
00018 {
00019 }
00020
00021 vector<SharedPointer<RelEntry> > Move2DPathFollowerActPosHasGuideNoisyVarRel::getProb(map<string, SharedPointer<IVariableValue> > sourceVals)
00022 {
00023
00024
00025 vector<SharedPointer<RelEntry> > result2 = pathFollower->getProb(sourceVals);
00026 SharedPointer<Map2DPosValue> robotCurPos = dynamic_pointer_cast<Map2DPosValue>(sourceVals[posVar->getVariableName()]);
00027 SharedPointer<VariableValue> hasGuideVal = dynamic_pointer_cast<VariableValue>(sourceVals[hasGuideVar->getVariableName()]);
00028
00029
00030 vector<SharedPointer<RelEntry> > result;
00031 for(int i = 0 ; i < result2.size(); i ++ )
00032 {
00033 SharedPointer<RelEntry> curRelEntry = result2[i];
00034 if(sourceVals[this->hasGuideVar->getVariableName()]->getIndex() == BooleanVariable::TrueValueIndex)
00035 {
00036
00037 SharedPointer<RelEntry> relEntry (new RelEntry());
00038 relEntry->destValues.insert(curRelEntry->destValues.begin(), curRelEntry->destValues.end());
00039 relEntry->prob = 1.0;
00040 result.push_back(relEntry);
00041
00042 }
00043 else
00044 {
00045
00046 SharedPointer<RelEntry> newEntry (new RelEntry());
00047 newEntry->destValues.insert(curRelEntry->destValues.begin(), curRelEntry->destValues.end());
00048 newEntry->prob = params->AUVBlindMoveProb;
00049 result.push_back(newEntry);
00050
00051
00052
00053
00054 SharedPointer<Map2DPosValue> srcPos = dynamic_pointer_cast<Map2DPosValue>(sourceVals[posVar->getVariableName()]);
00055 SharedPointer<Map2DPosValue> destPos = dynamic_pointer_cast<Map2DPosValue>(curRelEntry->destValues[posVar->getVariableName()]);
00056
00057 vector<SharedPointer<Map2DPosValue> > destAdjVars = posVar->getDestSidePosPerpendicularToMovement(srcPos, destPos);
00058
00059 double noisyProb = (1 - params->AUVBlindMoveProb) / destAdjVars.size();
00060
00061 for(int i = 0 ; i < destAdjVars .size(); i++)
00062 {
00063 SharedPointer<Map2DPosValue>& noisyVar = destAdjVars[i];
00064
00065 SharedPointer<RelEntry> newEntry2 ( new RelEntry());
00066
00067
00068 newEntry2->destValues[posVar->getVariableName()] = noisyVar;
00069 newEntry2->prob = noisyProb;
00070 result.push_back(newEntry2);
00071 }
00072 }
00073
00074 }
00075
00076
00077 return result;
00078 }