Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
12#include <mrpt/utils/CStream.h>
13#include <mrpt/synch.h>
19#include <mrpt/math/CPolygon.h>
21
22namespace mrpt
23{
24 namespace hwdrivers
25 {
26 /** This is the base, abstract class for "software drivers" interfaces to 2D scanners (laser range finders).
27 * Physical devices may be interfaced through a serial port, a USB connection,etc. but this class
28 * abstract those details throught the "binding" of the specific scanner driver to a given I/O channel,
29 * which must be set by calling "hwdrivers::C2DRangeFinderAbstract::bindIO". See also the derived classes.
30 *
31 * There is support for "exclusion polygons", areas where points, if detected, should be marked as invalid.
32 * Those areas are useful in cases where the scanner always detects part of the vehicle itself, and those
33 * points want to be ignored (see C2DRangeFinderAbstract::loadExclusionAreas).
34 *
35 * \sa hwdrivers::CSerialPort
36 * \ingroup mrpt_hwdrivers_grp
37 */
39 {
40 private:
44
45 /** For being thread-safe.
46 */
48
49 mrpt::obs::CObservation2DRangeScanPtr m_nextObservation; //!< A dynamic object used as buffer in doProcess
50
51 mrpt::obs::CObservation2DRangeScan::TListExclusionAreasWithRanges m_lstExclusionPolys; //!< A list of optional exclusion polygons, in coordinates relative to the vehicle, that is, taking into account the "sensorPose".
52 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 be marked as invalid.
53
54 bool m_showPreview; //!< If true, shows a 3D window with a preview of the grabber data
55 mrpt::gui::CDisplayWindow3DPtr m_win;
56
57 protected:
58 utils::CStream *m_stream; //!< The I/O channel (will be NULL if not bound).
59
60 /** Should be call by derived classes at "loadConfig" (loads exclusion areas AND exclusion angles).
61 * This loads a sequence of vertices of a polygon given by its (x,y) coordinates relative to the vehicle, that is, taking into account the "sensorPose".
62 * - exclusionZone%u_x
63 * - exclusionZone%u_y
64 * for %u=1,2,3,...
65 * All points within the 2D polygon will be ignored, for any Z, unless an optional entry is found:
66 * - exclusionZone%u_z=[z_min z_max]
67 * In that case, only the points within the 2D polygon AND the given range in Z will be ignored.
68 *
69 * The number of zones is variable, but they must start at 1 and be consecutive.
70 *
71 * This also loads any other common params (e.g. 'preview')
72 * \sa filterByExclusionAreas
73 */
75 const mrpt::utils::CConfigFileBase &configSource,
76 const std::string &iniSection );
77
78 /** Mark as invalid those points which (x,y) coordinates fall within the exclusion polygons.
79 * \sa loadExclusionAreas
80 */
82
83 /** Mark as invalid those ranges in a set of forbiden angle ranges.
84 * \sa loadExclusionAreas
85 */
87
88 /** Must be called inside the capture method to allow optional GUI preview of scans */
90
91 public:
92 C2DRangeFinderAbstract(); //!< Default constructor
93 virtual ~C2DRangeFinderAbstract(); //!< Destructor
94
95 void showPreview(bool enable=true) { m_showPreview=enable; } //!< Enables GUI visualization in real-time
96
97 /** Binds the object to a given I/O channel.
98 * The stream object must not be deleted before the destruction of this class.
99 * \sa hwdrivers::CSerialPort
100 */
101 void bindIO( mrpt::utils::CStream *streamIO );
102
103 /** Get the last observation from the sensor, if available, and unmarks it as being "the last one" (thus a new scan must arrive or subsequent calls will find no new observations).
104 */
106 bool &outThereIsObservation,
108 bool &hardwareError );
109
110 void doProcess(); //!< Main method for a CGenericSensor
111
112 /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it.
113 * This method MUST BE CALLED in a timely fashion by the user to allow the proccessing of incoming data. It can be run in a different thread safely.
114 */
115 virtual void doProcessSimple(
116 bool &outThereIsObservation,
118 bool &hardwareError ) = 0;
119
120 /** Enables the scanning mode (which may depend on the specific laser device); this must be called before asking for observations to assure that the protocol has been initializated.
121 * \return If everything works "true", or "false" if there is any error.
122 */
123 virtual bool turnOn() = 0;
124
125 /** Disables the scanning mode (this can be used to turn the device in low energy mode, if available)
126 * \return If everything works "true", or "false" if there is any error.
127 */
128 virtual bool turnOff() = 0;
129
130
131 }; // End of class
132 } // End of namespace
133} // End of namespace
134
135
136#endif
This is the base, abstract class for "software drivers" interfaces to 2D scanners (laser range finder...
virtual ~C2DRangeFinderAbstract()
Destructor.
void filterByExclusionAngles(mrpt::obs::CObservation2DRangeScan &obs) const
Mark as invalid those ranges in a set of forbiden angle ranges.
virtual bool turnOn()=0
Enables the scanning mode (which may depend on the specific laser device); this must be called before...
synch::CCriticalSection m_csChangeStream
For being thread-safe.
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 ...
void showPreview(bool enable=true)
Enables GUI visualization in real-time.
void loadCommonParams(const mrpt::utils::CConfigFileBase &configSource, const std::string &iniSection)
Should be call by derived classes at "loadConfig" (loads exclusion areas AND exclusion angles).
C2DRangeFinderAbstract()
Default constructor.
mrpt::obs::CObservation2DRangeScan m_lastObservation
mrpt::obs::CObservation2DRangeScan::TListExclusionAreasWithRanges m_lstExclusionPolys
A list of optional exclusion polygons, in coordinates relative to the vehicle, that is,...
void processPreview(const mrpt::obs::CObservation2DRangeScan &obs)
Must be called inside the capture method to allow optional GUI preview of scans.
mrpt::obs::CObservation2DRangeScanPtr m_nextObservation
A dynamic object used as buffer in doProcess.
void doProcess()
Main method for a CGenericSensor.
bool m_showPreview
If true, shows a 3D window with a preview of the grabber data.
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 ...
utils::CStream * m_stream
The I/O channel (will be NULL if not bound).
void bindIO(mrpt::utils::CStream *streamIO)
Binds the object to a given I/O channel.
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,...
virtual bool turnOff()=0
Disables the scanning mode (this can be used to turn the device in low energy mode,...
void filterByExclusionAreas(mrpt::obs::CObservation2DRangeScan &obs) const
Mark as invalid those points which (x,y) coordinates fall within the exclusion polygons.
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
std::vector< std::pair< mrpt::math::CPolygon, std::pair< double, double > > > TListExclusionAreasWithRanges
Used in filterByExclusionAreas.
This class provides simple critical sections functionality.
This class allows loading and storing values and vectors of different types from a configuration text...
This base class provides a common printf-like method to send debug information to std::cout,...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:39
#define HWDRIVERS_IMPEXP
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.2 for MRPT 1.4.0 SVN: at Mon Sep 20 00:21:40 UTC 2021