Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

visionperceptor.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: visionperceptor.h,v 1.6 2004/07/21 08:53:02 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #ifndef VISIONPERCEPTOR_H
00023 #define VISIONPERCEPTOR_H
00024 
00025 #include <salt/random.h>
00026 #include <oxygen/agentaspect/perceptor.h>
00027 #include <oxygen/physicsserver/raycollider.h>
00028 #include <oxygen/sceneserver/sceneserver.h>
00029 #include <oxygen/sceneserver/transform.h>
00030 #include <soccer/agentstate/agentstate.h>
00031 
00032 class VisionPerceptor : public oxygen::Perceptor
00033 {
00034 protected:
00035     typedef boost::shared_ptr<salt::NormalRNG<> > NormalRngPtr;
00036 
00037     struct ObjectData
00038     {
00039         boost::shared_ptr<ObjectState> mObj;
00040 
00041         float mTheta;  // angle in the X-Y (horizontal) plane
00042         float mPhi;    // latitude angle
00043         float mDist;  // distance between perceptor and object
00044         salt::Vector3f mRelPos;
00045 
00046         ObjectData& operator=(const ObjectData& rhs)
00047         {
00048             mObj     = rhs.mObj;
00049             mRelPos  = rhs.mRelPos;
00050             mTheta   = rhs.mTheta;
00051             mPhi     = rhs.mPhi;
00052             mDist    = rhs.mDist;
00053         }
00054 
00055         int operator==(const ObjectData& rhs) const
00056         { return mDist == rhs.mDist; }
00057         int operator<(const ObjectData& rhs) const
00058         { return mDist < rhs.mDist; }
00059     };
00060 
00061     typedef std::list<ObjectData> TObjectList;
00062 
00063 public:
00064     VisionPerceptor();
00065     virtual ~VisionPerceptor();
00066 
00068     bool Percept(boost::shared_ptr<oxygen::PredicateList> predList);
00069 
00084     void SetNoiseParams(float sigma_dist, float sigma_phi,
00085                         float sigma_theta, float cal_error_abs);
00086 
00088     void SetSenseMyPos(bool sense);
00089 
00093     void AddNoise(bool add_noise);
00094 
00098     void UseRandomNoise(bool random_noise);
00099 
00101     void SetStaticSenseAxis(bool static_axis);
00102 
00103 protected:
00105     virtual bool ConstructInternal();
00106 
00108     void SetupVisibleObjects(TObjectList& visibleObjects);
00109 
00111     bool StaticAxisPercept(boost::shared_ptr<oxygen::PredicateList> predList);
00112 
00116     bool DynamicAxisPercept(boost::shared_ptr<oxygen::PredicateList> predList);
00117 
00119     bool CheckOcclusion(const salt::Vector3f& my_pos, const ObjectData& od) const;
00120 
00123     void AddSense(oxygen::Predicate& predicate, ObjectData& od) const;
00124 
00126     void VisionPerceptor::ApplyNoise(ObjectData& od) const;
00127 
00128     virtual void OnLink();
00129     virtual void OnUnlink();
00130 
00131 protected:
00133     salt::Vector3f mError;
00134 
00136     bool mSenseMyPos;
00137 
00139     float mSigmaDist;
00141     float mSigmaTheta;
00143     float mSigmaPhi;
00145     float mCalErrorAbs;
00147     bool mAddNoise;
00149     bool mUseRandomNoise;
00150 
00154     bool mStaticSenseAxis;
00155 
00157     boost::shared_ptr<oxygen::RayCollider> mRay;
00158 
00160     NormalRngPtr mDistRng;
00162     NormalRngPtr mThetaRng;
00164     NormalRngPtr mPhiRng;
00165 
00166     boost::shared_ptr<oxygen::Scene> mActiveScene;
00168     boost::shared_ptr<oxygen::Transform> mTransformParent;
00170     boost::shared_ptr<oxygen::SceneServer> mSceneServer;
00172     boost::shared_ptr<AgentState> mAgentState;
00173 };
00174 
00175 DECLARE_CLASS(VisionPerceptor);
00176 
00177 #endif //VISIONPERCEPTOR_H

Generated on Thu Apr 6 15:25:40 2006 for rcssserver3d by  doxygen 1.4.4