Sensor.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006-2011, SRI International (R)
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as published by
00006  * the Free Software Foundation, either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #pragma once
00019 
00020 #ifndef __OpenKarto_Sensor_h__
00021 #define __OpenKarto_Sensor_h__
00022 
00023 #include <OpenKarto/List.h>
00024 #include <OpenKarto/Object.h>
00025 
00026 namespace karto
00027 {
00028 
00030 
00031 
00035   typedef List<Vector2d> Vector2dList;
00036 
00040 
00041   class SensorData;
00042 
00046   class KARTO_EXPORT Sensor : public Object
00047   {
00048     KARTO_RTTI();
00049 
00050   protected:
00055     Sensor(const Identifier& rName);
00056 
00057     //@cond EXCLUDE
00061     virtual ~Sensor();
00062     //@endcond
00063     
00064   public:
00069     inline const Pose2& GetOffsetPose() const
00070     {
00071       return m_pOffsetPose->GetValue();
00072     }
00073     
00078     inline void SetOffsetPose(const Pose2& rPose)
00079     {
00080       m_pOffsetPose->SetValue(rPose);
00081     }
00082 
00086     virtual void Validate() = 0;
00087 
00092     virtual void Validate(SensorData* pSensorData) = 0;
00093 
00094   private:
00095     // restrict the following functions
00096     Sensor(const Sensor&);
00097     const Sensor& operator=(const Sensor&);
00098 
00099   private:
00103     Parameter<Pose2>* m_pOffsetPose;
00104   }; // Sensor
00105 
00109   KARTO_TYPE(Sensor);
00110 
00114   typedef SmartPointer<Sensor> SensorPtr;
00115   
00119   typedef List<SensorPtr> SensorList;
00120 
00124 
00131   class Drive : public Sensor
00132   {
00133     KARTO_RTTI();
00134 
00135   public:
00140     Drive(const Identifier& rName)
00141       : Sensor(rName)
00142     {
00143     }
00144 
00145   protected:
00146     //@cond EXCLUDE
00150     virtual ~Drive()
00151     {
00152     }
00153     //@endcond
00154 
00155   public:
00156     virtual void Validate()
00157     {
00158     }
00159 
00163     virtual void Validate(SensorData* pSensorData)
00164     {
00165       if (pSensorData == NULL)
00166       {
00167         throw Exception("SensorData == NULL");
00168       }
00169     }
00170 
00171   private:
00172     // restrict the following functions
00173     Drive(const Drive&);
00174     const Drive& operator=(const Drive&);
00175   }; // class Drive
00176 
00180   KARTO_TYPE(Drive);
00181 
00185 
00193   typedef enum
00194   {
00195     LaserRangeFinder_Custom = 0,
00196 
00197     LaserRangeFinder_Sick_LMS100 = 1,
00198     LaserRangeFinder_Sick_LMS200 = 2,
00199     LaserRangeFinder_Sick_LMS291 = 3,
00200 
00201     LaserRangeFinder_Hokuyo_UTM_30LX = 4,
00202     LaserRangeFinder_Hokuyo_URG_04LX = 5    
00203   } LaserRangeFinderType;
00204 
00208   KARTO_EXPORT void RegisterLaserRangeFinderType();
00209 
00213   KARTO_AUTO_TYPE(LaserRangeFinderType, &RegisterLaserRangeFinderType);
00214 
00218 
00219   class LocalizedLaserScan;
00220   class CoordinateConverter;
00221   class LaserRangeFinder;
00222 
00247   class KARTO_EXPORT LaserRangeFinder : public Sensor
00248   {
00249     KARTO_RTTI();
00250 
00251   protected:
00252     //@cond EXCLUDE
00256     virtual ~LaserRangeFinder();
00257     //@endcond
00258     
00259   public:   
00264     inline kt_double GetMinimumRange() const
00265     {
00266       return m_pMinimumRange->GetValue();
00267     }
00268 
00273     inline void SetMinimumRange(kt_double minimumRange)
00274     {
00275       m_pMinimumRange->SetValue(minimumRange);
00276       
00277       SetRangeThreshold(GetRangeThreshold());
00278     }
00279 
00284     inline kt_double GetMaximumRange() const
00285     {
00286       return m_pMaximumRange->GetValue();
00287     }
00288 
00293     inline void SetMaximumRange(kt_double maximumRange)
00294     {
00295       m_pMaximumRange->SetValue(maximumRange);
00296 
00297       SetRangeThreshold(GetRangeThreshold());
00298     }
00299 
00304     inline kt_double GetRangeThreshold() const
00305     {
00306       return m_pRangeThreshold->GetValue();
00307     }
00308 
00313     void SetRangeThreshold(kt_double rangeThreshold);
00314 
00319     inline kt_double GetMinimumAngle() const
00320     {
00321       return m_pMinimumAngle->GetValue();
00322     }
00323     
00328     inline void SetMinimumAngle(kt_double minimumAngle)
00329     {
00330       m_pMinimumAngle->SetValue(minimumAngle);
00331 
00332       Update();
00333     }
00334 
00339     inline kt_double GetMaximumAngle() const
00340     {
00341       return m_pMaximumAngle->GetValue();
00342     }
00343     
00348     inline void SetMaximumAngle(kt_double maximumAngle)
00349     {
00350       m_pMaximumAngle->SetValue(maximumAngle);
00351 
00352       Update();
00353     }
00354     
00359     inline kt_double GetAngularResolution() const
00360     {
00361       return m_pAngularResolution->GetValue();
00362     }
00363     
00368     void SetAngularResolution(kt_double angularResolution);
00369 
00374     inline kt_int64s GetType()
00375     {
00376       return m_pType->GetValue();
00377     }
00378 
00383     inline kt_int32u GetNumberOfRangeReadings() const
00384     {
00385       return m_NumberOfRangeReadings;
00386     }
00387 
00391     virtual void Validate();
00392 
00397     virtual void Validate(SensorData* pSensorData);
00398 
00407     const Vector2dList GetPointReadings(LocalizedLaserScan* pLocalizedLaserScan, CoordinateConverter* pCoordinateConverter, kt_bool ignoreThresholdPoints = true, kt_bool flipY = false) const;
00408 
00409   public:
00416     static LaserRangeFinder* CreateLaserRangeFinder(LaserRangeFinderType type, const Identifier& rName);
00417 
00418   private:
00423     LaserRangeFinder(const Identifier& rName);
00424     
00428     void Update()
00429     {
00430       m_NumberOfRangeReadings = static_cast<kt_int32u>(math::Round((GetMaximumAngle() - GetMinimumAngle()) / GetAngularResolution()) + 1);
00431     }
00432 
00433   private:
00434     LaserRangeFinder(const LaserRangeFinder&);
00435     const LaserRangeFinder& operator=(const LaserRangeFinder&);
00436 
00437   private:
00438     // sensor m_Parameters
00439     Parameter<kt_double>* m_pMinimumAngle;
00440     Parameter<kt_double>* m_pMaximumAngle;
00441 
00442     Parameter<kt_double>* m_pAngularResolution;
00443 
00444     Parameter<kt_double>* m_pMinimumRange;
00445     Parameter<kt_double>* m_pMaximumRange;
00446 
00447     Parameter<kt_double>* m_pRangeThreshold;
00448 
00449     ParameterEnum* m_pType;
00450 
00451     kt_int32u m_NumberOfRangeReadings;    
00452   }; // LaserRangeFinder
00453 
00457   KARTO_TYPE(LaserRangeFinder);
00458 
00462   typedef SmartPointer<LaserRangeFinder> LaserRangeFinderPtr;
00463   
00465 
00466 }
00467 
00468 #endif // __OpenKarto_Sensor_h__


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Thu Aug 27 2015 14:07:25