Main MRPT website > C++ reference for MRPT 1.9.9
C2DRangeFinderAbstract.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef C2DRangeFinderAbstract_H
10 #define C2DRangeFinderAbstract_H
11 
17 #include <mrpt/math/CPolygon.h>
19 
20 namespace mrpt
21 {
22 namespace hwdrivers
23 {
24 /** This is the base, abstract class for "software drivers" interfaces to 2D
25  * scanners (laser range finders).
26  * Physical devices may be interfaced through a serial port, a USB
27  * connection,etc. but this class
28  * abstract those details throught the "binding" of the specific scanner
29  * driver to a given I/O channel,
30  * which must be set by calling "hwdrivers::C2DRangeFinderAbstract::bindIO".
31  * See also the derived classes.
32  *
33  * There is support for "exclusion polygons", areas where points, if detected,
34  * should be marked as invalid.
35  * Those areas are useful in cases where the scanner always detects part of
36  * the vehicle itself, and those
37  * points want to be ignored (see
38  * C2DRangeFinderAbstract::loadExclusionAreas).
39  *
40  * \sa comms::CSerialPort
41  * \ingroup mrpt_hwdrivers_grp
42  */
45 {
46  private:
50 
51  /** For being thread-safe.
52  */
54 
55  /** A dynamic object used as buffer in doProcess */
57 
58  /** A list of optional exclusion polygons, in coordinates relative to the
59  * vehicle, that is, taking into account the "sensorPose". */
62  /** A list of pairs of angles <init,end> such as all sensor ranges falling
63  * in those forbiden angles will be marked as invalid. */
64  std::vector<std::pair<double, double>> m_lstExclusionAngles;
65 
66  /** If true, shows a 3D window with a preview of the grabber data */
69 
70  protected:
71  /** The I/O channel (will be nullptr if not bound). */
73 
74  /** Should be call by derived classes at "loadConfig" (loads exclusion areas
75  *AND exclusion angles).
76  * This loads a sequence of vertices of a polygon given by its (x,y)
77  *coordinates relative to the vehicle, that is, taking into account the
78  *"sensorPose".
79  * - exclusionZone%u_x
80  * - exclusionZone%u_y
81  * for %u=1,2,3,...
82  * All points within the 2D polygon will be ignored, for any Z, unless an
83  *optional entry is found:
84  * - exclusionZone%u_z=[z_min z_max]
85  * In that case, only the points within the 2D polygon AND the given
86  *range in Z will be ignored.
87  *
88  * The number of zones is variable, but they must start at 1 and be
89  *consecutive.
90  *
91  * This also loads any other common params (e.g. 'preview')
92  * \sa filterByExclusionAreas
93  */
94  void loadCommonParams(
95  const mrpt::config::CConfigFileBase& configSource,
96  const std::string& iniSection);
97 
98  /** Mark as invalid those points which (x,y) coordinates fall within the
99  * exclusion polygons.
100  * \sa loadExclusionAreas
101  */
103 
104  /** Mark as invalid those ranges in a set of forbiden angle ranges.
105  * \sa loadExclusionAreas
106  */
108 
109  /** Must be called inside the capture method to allow optional GUI preview
110  * of scans */
112 
113  public:
114  /** Default constructor */
116  /** Destructor */
117  virtual ~C2DRangeFinderAbstract();
118 
119  /** Enables GUI visualization in real-time */
120  void showPreview(bool enable = true) { m_showPreview = enable; }
121  /** Binds the object to a given I/O channel.
122  * The stream object must not be deleted before the destruction of this
123  * class.
124  * \sa comms::CSerialPort
125  */
126  void bindIO(mrpt::io::CStream* streamIO);
127 
128  /** Get the last observation from the sensor, if available, and unmarks it
129  * as being "the last one" (thus a new scan must arrive or subsequent calls
130  * will find no new observations).
131  */
132  void getObservation(
133  bool& outThereIsObservation,
134  mrpt::obs::CObservation2DRangeScan& outObservation,
135  bool& hardwareError);
136 
137  /** Main method for a CGenericSensor */
138  void doProcess();
139 
140  /** Specific laser scanner "software drivers" must process here new data
141  * from the I/O stream, and, if a whole scan has arrived, return it.
142  * This method MUST BE CALLED in a timely fashion by the user to allow the
143  * proccessing of incoming data. It can be run in a different thread safely.
144  */
145  virtual void doProcessSimple(
146  bool& outThereIsObservation,
147  mrpt::obs::CObservation2DRangeScan& outObservation,
148  bool& hardwareError) = 0;
149 
150  /** Enables the scanning mode (which may depend on the specific laser
151  * device); this must be called before asking for observations to assure
152  * that the protocol has been initializated.
153  * \return If everything works "true", or "false" if there is any error.
154  */
155  virtual bool turnOn() = 0;
156 
157  /** Disables the scanning mode (this can be used to turn the device in low
158  * energy mode, if available)
159  * \return If everything works "true", or "false" if there is any error.
160  */
161  virtual bool turnOff() = 0;
162 
163 }; // End of class
164 } // End of namespace
165 } // End of namespace
166 
167 #endif
mrpt::hwdrivers::C2DRangeFinderAbstract::bindIO
void bindIO(mrpt::io::CStream *streamIO)
Binds the object to a given I/O channel.
Definition: C2DRangeFinderAbstract.cpp:43
mrpt::hwdrivers::C2DRangeFinderAbstract::m_win
mrpt::gui::CDisplayWindow3D::Ptr m_win
Definition: C2DRangeFinderAbstract.h:68
mrpt::obs::CObservation2DRangeScan
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
Definition: CObservation2DRangeScan.h:56
mrpt::hwdrivers::C2DRangeFinderAbstract::turnOn
virtual bool turnOn()=0
Enables the scanning mode (which may depend on the specific laser device); this must be called before...
mrpt::hwdrivers::C2DRangeFinderAbstract::doProcessSimple
virtual void doProcessSimple(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)=0
Specific laser scanner "software drivers" must process here new data from the I/O stream,...
mrpt::hwdrivers::C2DRangeFinderAbstract::filterByExclusionAngles
void filterByExclusionAngles(mrpt::obs::CObservation2DRangeScan &obs) const
Mark as invalid those ranges in a set of forbiden angle ranges.
Definition: C2DRangeFinderAbstract.cpp:182
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::C2DRangeFinderAbstract::showPreview
void showPreview(bool enable=true)
Enables GUI visualization in real-time.
Definition: C2DRangeFinderAbstract.h:120
mrpt::hwdrivers::C2DRangeFinderAbstract::m_hardwareError
bool m_hardwareError
Definition: C2DRangeFinderAbstract.h:49
CDisplayWindow3D.h
mrpt::hwdrivers::C2DRangeFinderAbstract::C2DRangeFinderAbstract
C2DRangeFinderAbstract()
Default constructor.
Definition: C2DRangeFinderAbstract.cpp:25
mrpt::hwdrivers::C2DRangeFinderAbstract::getObservation
void getObservation(bool &outThereIsObservation, mrpt::obs::CObservation2DRangeScan &outObservation, bool &hardwareError)
Get the last observation from the sensor, if available, and unmarks it as being "the last one" (thus ...
Definition: C2DRangeFinderAbstract.cpp:53
mrpt::hwdrivers::C2DRangeFinderAbstract::~C2DRangeFinderAbstract
virtual ~C2DRangeFinderAbstract()
Destructor.
Definition: C2DRangeFinderAbstract.cpp:39
CConfigFileBase.h
mrpt::hwdrivers::C2DRangeFinderAbstract
This is the base, abstract class for "software drivers" interfaces to 2D scanners (laser range finder...
Definition: C2DRangeFinderAbstract.h:43
mrpt::hwdrivers::C2DRangeFinderAbstract::turnOff
virtual bool turnOff()=0
Disables the scanning mode (this can be used to turn the device in low energy mode,...
COutputLogger.h
mrpt::hwdrivers::C2DRangeFinderAbstract::m_lstExclusionPolys
mrpt::obs::CObservation2DRangeScan::TListExclusionAreasWithRanges m_lstExclusionPolys
A list of optional exclusion polygons, in coordinates relative to the vehicle, that is,...
Definition: C2DRangeFinderAbstract.h:61
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::obs::CObservation2DRangeScan::TListExclusionAreasWithRanges
std::vector< std::pair< mrpt::math::CPolygon, std::pair< double, double > >> TListExclusionAreasWithRanges
Used in filterByExclusionAreas.
Definition: CObservation2DRangeScan.h:80
mrpt::hwdrivers::C2DRangeFinderAbstract::m_stream
mrpt::io::CStream * m_stream
The I/O channel (will be nullptr if not bound).
Definition: C2DRangeFinderAbstract.h:72
mrpt::hwdrivers::C2DRangeFinderAbstract::loadCommonParams
void loadCommonParams(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)
Should be call by derived classes at "loadConfig" (loads exclusion areas AND exclusion angles).
Definition: C2DRangeFinderAbstract.cpp:98
mrpt::hwdrivers::C2DRangeFinderAbstract::m_nextObservation
mrpt::obs::CObservation2DRangeScan::Ptr m_nextObservation
A dynamic object used as buffer in doProcess.
Definition: C2DRangeFinderAbstract.h:56
CGenericSensor.h
mrpt::hwdrivers::C2DRangeFinderAbstract::m_csChangeStream
std::mutex m_csChangeStream
For being thread-safe.
Definition: C2DRangeFinderAbstract.h:53
mrpt::gui::CDisplayWindow3D::Ptr
std::shared_ptr< CDisplayWindow3D > Ptr
Definition: CDisplayWindow3D.h:120
mrpt::hwdrivers::C2DRangeFinderAbstract::m_lastObservationIsNew
bool m_lastObservationIsNew
Definition: C2DRangeFinderAbstract.h:48
mrpt::hwdrivers::CGenericSensor
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
Definition: CGenericSensor.h:70
mrpt::hwdrivers::C2DRangeFinderAbstract::m_showPreview
bool m_showPreview
If true, shows a 3D window with a preview of the grabber data.
Definition: C2DRangeFinderAbstract.h:67
CPolygon.h
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
mrpt::obs::CObservation2DRangeScan::Ptr
std::shared_ptr< CObservation2DRangeScan > Ptr
Definition: CObservation2DRangeScan.h:58
mrpt::hwdrivers::C2DRangeFinderAbstract::processPreview
void processPreview(const mrpt::obs::CObservation2DRangeScan &obs)
Must be called inside the capture method to allow optional GUI preview of scans.
Definition: C2DRangeFinderAbstract.cpp:188
mrpt::hwdrivers::C2DRangeFinderAbstract::m_lastObservation
mrpt::obs::CObservation2DRangeScan m_lastObservation
Definition: C2DRangeFinderAbstract.h:47
mrpt::hwdrivers::C2DRangeFinderAbstract::m_lstExclusionAngles
std::vector< std::pair< double, double > > m_lstExclusionAngles
A list of pairs of angles <init,end> such as all sensor ranges falling in those forbiden angles will ...
Definition: C2DRangeFinderAbstract.h:64
mrpt::hwdrivers::C2DRangeFinderAbstract::m_csLastObservation
std::mutex m_csLastObservation
Definition: C2DRangeFinderAbstract.h:53
string
GLsizei const GLchar ** string
Definition: glext.h:4101
CArchive.h
mrpt::hwdrivers::C2DRangeFinderAbstract::filterByExclusionAreas
void filterByExclusionAreas(mrpt::obs::CObservation2DRangeScan &obs) const
Mark as invalid those points which (x,y) coordinates fall within the exclusion polygons.
Definition: C2DRangeFinderAbstract.cpp:173
mrpt::hwdrivers::C2DRangeFinderAbstract::doProcess
void doProcess()
Main method for a CGenericSensor.
Definition: C2DRangeFinderAbstract.cpp:70
CObservation2DRangeScan.h
mrpt::io::CStream
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:30



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST