Main MRPT website > C++ reference for MRPT 1.3.2
CPtuHokuyo.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-2015, 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 
10 #ifndef CPtuHokuyo_H
11 #define CPtuHokuyo_H
12 
15 #include "CPtuDPerception.h"
16 
17 namespace mrpt
18 {
19  namespace hwdrivers
20  {
21  /** The objetive of this class is to coordinate PTU movements and
22  * Hokuyo scans, adding the posibility of save the points earned
23  * in several different formats, limit valids points and view
24  * them on a grahic.
25  * \ingroup mrpt_hwdrivers_grp
26  */
27 
29 
30  struct ThreadParams
31  {
32  char axis;
34  double scan_vel; // Velocity of continuous scan
36  };
37 
39  {
40 
42 
43  protected:
44 
45  std::string m_ptu_port;
46  char m_axis;
47  double m_velocity, m_initial, m_final, m_hokuyo_frec;
48 
49  /** See the class documentation at the top for expected parameters */
50  void loadConfig_sensorSpecific(
51  const mrpt::utils::CConfigFileBase &configSource,
52  const std::string &section );
53 
54  public:
55 
58 
59  /** Specify type of ptu. Current options are:
60  * m_ptu_type = 0 => CPtuDPerception
61  * m_ptu_type = 1 => CPtuMicos
62  */
64 
65  std::vector<mrpt::obs::CObservation2DRangeScan> vObs;
66 
67  // High between ptu tilt axis and hokuyo laser scan
68  double high;
69 
70  struct my_pos
71  {
73  double pos;
74  };
75 
76  std::vector<mrpt::hwdrivers::CPtuHokuyo::my_pos> v_my_pos;
77  std::vector<double> v_ptu_pos, v_ptu_time;
78 
79 
80  /** Default constructor */
81 
82  CPtuHokuyo();
83 
84  /** Destructor, delete observations of the vector */
85 
86  ~CPtuHokuyo();
87 
88  /** Initialization of laser and ptu */
89 
90  bool init(const std::string &portPtu, const std::string &portHokuyo);
91 
92  /** Performs a complete scan
93  * \param <axis> Pan or Till
94  * \param <tWait> Wait time betwen commands
95  * \param <initial> initial position
96  * \param <final> final position
97  * \param <radPre> radians precision for the scan
98  * \param <interlaced> if interlaced==true performs a double sweep
99  */
100 
101  bool scan(char &axis, const int &tWait, double &initial, double &final, const double &radPre, const int &mean, const bool &interlaced=false);
102 
103  /** Performs a continuous scan */
104 
105  bool continuousScan(char &axis, const double &velocity, double &initial, double &final);
106 
107  /** Show a graphic with the points obtained from the scan or a map*/
108  //bool showGraphic(mrpt::maps::CSimplePointsMap *theMap=0);
109 
110  /** Save a simple points map into a simple file (if colours==true save points with a color) */
111  //bool saveMap2File(mrpt::maps::CSimplePointsMap &theMap, char* fname="Data.pts", const bool &colours=false);
112 
113  /** Save vector of observations in a CFileOutputStream file */
114 
115  bool saveVObs2File(const char *fname="Data.rawlog");
116 
117  /** Save vector points of observations into a simple file */
118 
119  bool saveVObsPoints2File(const char *fname="Data.pts",const bool &colours=false);
120 
121  /** Save pitchs and raw distances of all scans */
122 
123  bool savePitchAndDistances2File();
124 
125  /** Method for limit map points obtained from a scan */
126  //void limit(mrpt::maps::CSimplePointsMap &theMap);
127 
128  /** Set high between ptu tilt axis and hokuyo laser scan */
129 
130  void setHigh(const double &newHigh) { high = newHigh; }
131 
132  /** Obtain a observation from the laser */
133 
134  bool obtainObs( mrpt::obs::CObservation2DRangeScan & obs );
135 
136  /** This method can or cannot be implemented in the derived class, depending on the need for it.
137  * \exception This method must throw an exception with a descriptive message if some critical error is found.
138  */
139  void initialize();
140 
141  /** This method will be invoked at a minimum rate of "process_rate" (Hz)
142  * \exception This method must throw an exception with a descriptive message if some critical error is found.
143  */
144  void doProcess();
145 
146 
147  private:
148 
149  /** Save a observation from the laser into a vector of
150  * observations, calculating sensor position
151  */
152 
153  double saveObservation(const char &axis, const int &mean);
154 
155  /** Performs a simple scan
156  * \param <axis> Pan or Till
157  * \param <tWait> Wait time betwen commands
158  * \param <movements> number total of movements
159  * \param <radPre> radians precision for the scan
160  * \param <vObs> reference to obsevations vector for save the observation
161  */
162 
163  bool singleScan(const char &axis, const int &tWait, const int &movements, const double &radPre, const int &mean);
164 
165  /** Calculate minimum lenght of scan vectors */
166 
167  int minLengthVectors(mrpt::obs::CObservation2DRangeScan &obs, std::vector<mrpt::obs::CObservation2DRangeScan> &vObsAux);
168 
169  /** Calculate minimum lenght of 2 scan vectors */
170 
171  int minLengthVectors(mrpt::obs::CObservation2DRangeScan &obs1, mrpt::obs::CObservation2DRangeScan &obs2, const int &mode);
172 
173  /** Load observations in a points map */
174  //void loadObs2PointsMap(mrpt::maps::CSimplePointsMap &theMap);
175 
176  /** Limit the valid position of scan points */
177  //bool limitScan(const char &axis, double &low, double &high, mrpt::maps::CSimplePointsMap &theMap);
178 
179  /** Refine the observations obtains from a continuous scan */
180  void refineVObs(const char &axis);
181 
182  /** Calculate the sensor pose depending teh axis of movements and the ptu position */
183 
184  void calculateSensorPose(const char &axis, const double &pos, mrpt::obs::CObservation2DRangeScan &obs);
185 
186  /** Obtain position of observations between first and second position in m_my_pos map */
187 
188  int obsPosition();
189 
190 
191  }; // End of class
192 
193  } // End of namespace
194 
195 } // End of namespace
196 
197 #endif
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:30
class HWDRIVERS_IMPEXP CPtuHokuyo
The objetive of this class is to coordinate PTU movements and Hokuyo scans, adding the posibility of ...
Definition: CPtuHokuyo.h:28
This class implements initialization and comunication methods to control a generic Pan and Tilt Unit...
Definition: CPtuBase.h:23
std::vector< double > v_ptu_time
Definition: CPtuHokuyo.h:77
This class allows loading and storing values and vectors of different types from a configuration text...
std::vector< mrpt::obs::CObservation2DRangeScan > vObs
Definition: CPtuHokuyo.h:65
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
void setHigh(const double &newHigh)
Method for limit map points obtained from a scan.
Definition: CPtuHokuyo.h:130
This software driver implements the protocol SCIP-2.0 for interfacing HOKUYO URG, UTM and UXM laser s...
Definition: CHokuyoURG.h:62
mrpt::system::TTimeStamp timeStamp
Definition: CPtuHokuyo.h:72
#define HWDRIVERS_IMPEXP
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
int m_ptu_type
Specify type of ptu.
Definition: CPtuHokuyo.h:63
std::vector< mrpt::hwdrivers::CPtuHokuyo::my_pos > v_my_pos
Definition: CPtuHokuyo.h:76



Page generated by Doxygen 1.8.11 for MRPT 1.3.2 SVN:Unversioned directory at Sun May 1 08:45:24 UTC 2016