Main MRPT website > C++ reference for MRPT 1.4.0
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-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
10#ifndef CPtuHokuyo_H
11#define CPtuHokuyo_H
12
15#include "CPtuDPerception.h"
16
17namespace 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
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 */
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
83
84 /** Destructor, delete observations of the vector */
85
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
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
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 */
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
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
189
190
191 }; // End of class
192
193 } // End of namespace
194
195} // End of namespace
196
197#endif
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
This software driver implements the protocol SCIP-2.0 for interfacing HOKUYO URG, UTM and UXM laser s...
Definition CHokuyoURG.h:66
This class implements initialization and comunication methods to control a generic Pan and Tilt Unit,...
Definition CPtuBase.h:24
std::vector< mrpt::hwdrivers::CPtuHokuyo::my_pos > v_my_pos
Definition CPtuHokuyo.h:76
void initialize()
This method can or cannot be implemented in the derived class, depending on the need for it.
void setHigh(const double &newHigh)
Method for limit map points obtained from a scan.
Definition CPtuHokuyo.h:130
std::vector< double > v_ptu_pos
Definition CPtuHokuyo.h:77
void refineVObs(const char &axis)
Load observations in a points map.
void loadConfig_sensorSpecific(const mrpt::utils::CConfigFileBase &configSource, const std::string &section)
See the class documentation at the top for expected parameters.
void calculateSensorPose(const char &axis, const double &pos, mrpt::obs::CObservation2DRangeScan &obs)
Calculate the sensor pose depending teh axis of movements and the ptu position.
bool continuousScan(char &axis, const double &velocity, double &initial, double &final)
Performs a continuous scan.
int minLengthVectors(mrpt::obs::CObservation2DRangeScan &obs1, mrpt::obs::CObservation2DRangeScan &obs2, const int &mode)
Calculate minimum lenght of 2 scan vectors.
bool singleScan(const char &axis, const int &tWait, const int &movements, const double &radPre, const int &mean)
Performs a simple scan.
bool obtainObs(mrpt::obs::CObservation2DRangeScan &obs)
Obtain a observation from the laser.
int obsPosition()
Obtain position of observations between first and second position in m_my_pos map.
bool init(const std::string &portPtu, const std::string &portHokuyo)
Initialization of laser and ptu.
int minLengthVectors(mrpt::obs::CObservation2DRangeScan &obs, std::vector< mrpt::obs::CObservation2DRangeScan > &vObsAux)
Calculate minimum lenght of scan vectors.
double saveObservation(const char &axis, const int &mean)
Save a observation from the laser into a vector of observations, calculating sensor position.
bool scan(char &axis, const int &tWait, double &initial, double &final, const double &radPre, const int &mean, const bool &interlaced=false)
Performs a complete scan.
bool saveVObs2File(const char *fname="Data.rawlog")
Show a graphic with the points obtained from the scan or a map.
int m_ptu_type
Specify type of ptu.
Definition CPtuHokuyo.h:63
bool savePitchAndDistances2File()
Save pitchs and raw distances of all scans.
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
bool saveVObsPoints2File(const char *fname="Data.pts", const bool &colours=false)
Save vector points of observations into a simple file.
CPtuHokuyo()
Default constructor.
~CPtuHokuyo()
Destructor, delete observations of the vector.
std::vector< mrpt::obs::CObservation2DRangeScan > vObs
Definition CPtuHokuyo.h:65
A "CObservation"-derived class that represents a 2D range scan measurement (typically from a laser sc...
This class allows loading and storing values and vectors of different types from a configuration text...
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Definition datetime.h:30
#define HWDRIVERS_IMPEXP
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timeStamp
Definition CPtuHokuyo.h:72



Page generated by Doxygen 1.9.7 for MRPT 1.4.0 SVN: at Tue Jun 13 13:56:43 UTC 2023