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

restrictedvisionperceptor.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: restrictedvisionperceptor.h,v 1.1 2006/02/28 17:20:45 jamu 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 RESTRICTEDVISIONPERCEPTOR_H
00023 #define RESTRICTEDVISIONPERCEPTOR_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 RestrictedVisionPerceptor : 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; //position relative to perceptor
00045         //string name; // name of the object
00046 
00047 
00048         ObjectData& operator=(const ObjectData& rhs)
00049         {
00050             mObj     = rhs.mObj;
00051             mRelPos  = rhs.mRelPos;
00052             mTheta   = rhs.mTheta;
00053             mPhi     = rhs.mPhi;
00054             mDist    = rhs.mDist;
00055         }
00056 
00057         int operator==(const ObjectData& rhs) const
00058         { return mDist == rhs.mDist; }
00059         int operator<(const ObjectData& rhs) const
00060         { return mDist < rhs.mDist; }
00061     };
00062 
00063     typedef std::list<ObjectData> TObjectList;
00064 
00065 public:
00066     RestrictedVisionPerceptor();
00067     virtual ~RestrictedVisionPerceptor();
00068 
00070     bool Percept(boost::shared_ptr<oxygen::PredicateList> predList);
00071 
00086     void SetNoiseParams(float sigma_dist, float sigma_phi,
00087                         float sigma_theta, float cal_error_abs);
00088 
00090     void SetSenseMyPos(bool sense);
00091 
00095     void AddNoise(bool add_noise);
00096 
00098     void SetStaticSenseAxis(bool static_axis);
00099 
00101     void SetViewCones(unsigned int hAngle, unsigned int vAngle);
00102 
00112     void SetPanRange(int lower, int upper);
00120     void SetTiltRange(int lower, int upper);
00121 
00128     void SetPanTilt(float pan, float tilt);
00135     void ChangePanTilt(float pan, float tilt);
00139     float GetPan() const;
00143     float GetTilt() const;
00144 
00145 protected:
00147     virtual bool ConstructInternal();
00148 
00150     void SetupVisibleObjects(TObjectList& visibleObjects);
00151 
00153     bool StaticAxisPercept(boost::shared_ptr<oxygen::PredicateList> predList);
00154 
00158     bool DynamicAxisPercept(boost::shared_ptr<oxygen::PredicateList> predList);
00159 
00161     bool CheckOcclusion(const salt::Vector3f& my_pos, const ObjectData& od) const;
00162 
00165     void AddSense(oxygen::Predicate& predicate, ObjectData& od) const;
00166 
00168     void RestrictedVisionPerceptor::ApplyNoise(ObjectData& od) const;
00169 
00170     virtual void OnLink();
00171     virtual void OnUnlink();
00172 
00173 protected:
00175     salt::Vector3f mError;
00176 
00178     bool mSenseMyPos;
00179 
00181     float mSigmaDist;
00183     float mSigmaTheta;
00185     float mSigmaPhi;
00187     float mCalErrorAbs;
00189     bool mAddNoise;
00190 
00194     bool mStaticSenseAxis;
00195 
00197     unsigned int mHViewCone;
00199     unsigned int mVViewCone;
00201     float mPan;
00203     int mPanLower;
00205     int mPanUpper;
00207     float mTilt;
00209     int mTiltLower;
00211     int mTiltUpper;
00212 
00214     boost::shared_ptr<oxygen::RayCollider> mRay;
00215 
00217     NormalRngPtr mDistRng;
00219     NormalRngPtr mThetaRng;
00221     NormalRngPtr mPhiRng;
00222 
00223     boost::shared_ptr<oxygen::Scene> mActiveScene;
00225     boost::shared_ptr<oxygen::Transform> mTransformParent;
00227     boost::shared_ptr<oxygen::SceneServer> mSceneServer;
00229     boost::shared_ptr<AgentState> mAgentState;
00230 };
00231 
00232 DECLARE_CLASS(RestrictedVisionPerceptor);
00233 
00234 #endif //VISIONPERCEPTOR_H

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