Sensor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011, SRI International (R)
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #ifndef __OpenKarto_Sensor_h__
21 #define __OpenKarto_Sensor_h__
22 
23 #include <OpenKarto/List.h>
24 #include <OpenKarto/Object.h>
25 
26 namespace karto
27 {
28 
30 
31 
36 
40 
41  class SensorData;
42 
46  class KARTO_EXPORT Sensor : public Object
47  {
48  KARTO_RTTI();
49 
50  protected:
55  Sensor(const Identifier& rName);
56 
57  //@cond EXCLUDE
61  virtual ~Sensor();
62  //@endcond
63 
64  public:
69  inline const Pose2& GetOffsetPose() const
70  {
71  return m_pOffsetPose->GetValue();
72  }
73 
78  inline void SetOffsetPose(const Pose2& rPose)
79  {
80  m_pOffsetPose->SetValue(rPose);
81  }
82 
86  virtual void Validate() = 0;
87 
92  virtual void Validate(SensorData* pSensorData) = 0;
93 
94  private:
95  // restrict the following functions
96  Sensor(const Sensor&);
97  const Sensor& operator=(const Sensor&);
98 
99  private:
104  }; // Sensor
105 
110 
115 
120 
124 
131  class Drive : public Sensor
132  {
133  KARTO_RTTI();
134 
135  public:
140  Drive(const Identifier& rName)
141  : Sensor(rName)
142  {
143  }
144 
145  protected:
146  //@cond EXCLUDE
150  virtual ~Drive()
151  {
152  }
153  //@endcond
154 
155  public:
156  virtual void Validate()
157  {
158  }
159 
163  virtual void Validate(SensorData* pSensorData)
164  {
165  if (pSensorData == NULL)
166  {
167  throw Exception("SensorData == NULL");
168  }
169  }
170 
171  private:
172  // restrict the following functions
173  Drive(const Drive&);
174  const Drive& operator=(const Drive&);
175  }; // class Drive
176 
180  KARTO_TYPE(Drive);
181 
185 
193  typedef enum
194  {
196 
200 
204 
209 
214 
218 
219  class LocalizedLaserScan;
220  class CoordinateConverter;
221  class LaserRangeFinder;
222 
248  {
249  KARTO_RTTI();
250 
251  protected:
252  //@cond EXCLUDE
256  virtual ~LaserRangeFinder();
257  //@endcond
258 
259  public:
264  inline kt_double GetMinimumRange() const
265  {
266  return m_pMinimumRange->GetValue();
267  }
268 
273  inline void SetMinimumRange(kt_double minimumRange)
274  {
275  m_pMinimumRange->SetValue(minimumRange);
276 
277  SetRangeThreshold(GetRangeThreshold());
278  }
279 
284  inline kt_double GetMaximumRange() const
285  {
286  return m_pMaximumRange->GetValue();
287  }
288 
293  inline void SetMaximumRange(kt_double maximumRange)
294  {
295  m_pMaximumRange->SetValue(maximumRange);
296 
297  SetRangeThreshold(GetRangeThreshold());
298  }
299 
305  {
306  return m_pRangeThreshold->GetValue();
307  }
308 
313  void SetRangeThreshold(kt_double rangeThreshold);
314 
319  inline kt_double GetMinimumAngle() const
320  {
321  return m_pMinimumAngle->GetValue();
322  }
323 
328  inline void SetMinimumAngle(kt_double minimumAngle)
329  {
330  m_pMinimumAngle->SetValue(minimumAngle);
331 
332  Update();
333  }
334 
339  inline kt_double GetMaximumAngle() const
340  {
341  return m_pMaximumAngle->GetValue();
342  }
343 
348  inline void SetMaximumAngle(kt_double maximumAngle)
349  {
350  m_pMaximumAngle->SetValue(maximumAngle);
351 
352  Update();
353  }
354 
360  {
361  return m_pAngularResolution->GetValue();
362  }
363 
368  void SetAngularResolution(kt_double angularResolution);
369 
375  {
376  return m_pType->GetValue();
377  }
378 
384  {
385  return m_NumberOfRangeReadings;
386  }
387 
391  virtual void Validate();
392 
397  virtual void Validate(SensorData* pSensorData);
398 
407  const Vector2dList GetPointReadings(LocalizedLaserScan* pLocalizedLaserScan, CoordinateConverter* pCoordinateConverter, kt_bool ignoreThresholdPoints = true, kt_bool flipY = false) const;
408 
409  public:
416  static LaserRangeFinder* CreateLaserRangeFinder(LaserRangeFinderType type, const Identifier& rName);
417 
418  private:
423  LaserRangeFinder(const Identifier& rName);
424 
428  void Update()
429  {
430  m_NumberOfRangeReadings = static_cast<kt_int32u>(math::Round((GetMaximumAngle() - GetMinimumAngle()) / GetAngularResolution()) + 1);
431  }
432 
433  private:
435  const LaserRangeFinder& operator=(const LaserRangeFinder&);
436 
437  private:
438  // sensor m_Parameters
441 
443 
446 
448 
450 
452  }; // LaserRangeFinder
453 
458 
463 
465 
466 }
467 
468 #endif // __OpenKarto_Sensor_h__
List< SensorPtr > SensorList
Definition: Sensor.h:119
bool kt_bool
Definition: Types.h:145
kt_int32u GetNumberOfRangeReadings() const
Definition: Sensor.h:383
List< Vector2d > Vector2dList
Definition: Sensor.h:35
const Pose2 & GetOffsetPose() const
Definition: Sensor.h:69
kt_int32u m_NumberOfRangeReadings
Definition: Sensor.h:451
#define KARTO_EXPORT
Definition: Macros.h:78
Parameter< kt_double > * m_pMinimumAngle
Definition: Sensor.h:439
kt_double GetAngularResolution() const
Definition: Sensor.h:359
LaserRangeFinderType
Definition: Sensor.h:193
kt_double Round(kt_double value)
Definition: Math.h:114
Parameter< Pose2 > * m_pOffsetPose
Definition: Sensor.h:103
void SetMinimumAngle(kt_double minimumAngle)
Definition: Sensor.h:328
void SetMaximumRange(kt_double maximumRange)
Definition: Sensor.h:293
void SetOffsetPose(const Pose2 &rPose)
Definition: Sensor.h:78
Parameter< kt_double > * m_pAngularResolution
Definition: Sensor.h:442
virtual void Validate(SensorData *pSensorData)
Definition: Sensor.h:163
uint32_t kt_int32u
Definition: Types.h:111
void SetMaximumAngle(kt_double maximumAngle)
Definition: Sensor.h:348
#define KARTO_RTTI()
Definition: Meta.h:198
Parameter< kt_double > * m_pRangeThreshold
Definition: Sensor.h:447
Parameter< kt_double > * m_pMinimumRange
Definition: Sensor.h:444
SmartPointer< Sensor > SensorPtr
Definition: Sensor.h:114
KARTO_TYPE(Grid< kt_int8u >)
Parameter< kt_double > * m_pMaximumRange
Definition: Sensor.h:445
kt_double GetMinimumAngle() const
Definition: Sensor.h:319
ParameterEnum * m_pType
Definition: Sensor.h:449
kt_int64s GetType()
Definition: Sensor.h:374
void SetMinimumRange(kt_double minimumRange)
Definition: Sensor.h:273
double kt_double
Definition: Types.h:160
Drive(const Identifier &rName)
Definition: Sensor.h:140
Parameter< kt_double > * m_pMaximumAngle
Definition: Sensor.h:440
SmartPointer< LaserRangeFinder > LaserRangeFinderPtr
Definition: Sensor.h:462
signed long long kt_int64s
Definition: Types.h:127
kt_double GetMaximumAngle() const
Definition: Sensor.h:339
Definition: Any.cpp:20
KARTO_EXPORT void RegisterLaserRangeFinderType()
Definition: Sensor.cpp:34
kt_double GetMinimumRange() const
Definition: Sensor.h:264
kt_double GetRangeThreshold() const
Definition: Sensor.h:304
KARTO_AUTO_TYPE(LaserRangeFinderType,&RegisterLaserRangeFinderType)
kt_double GetMaximumRange() const
Definition: Sensor.h:284


nav2d_karto
Author(s): Sebastian Kasperski
autogenerated on Tue Nov 7 2017 06:02:36