17 #define APPERTURE 4.712385 // in radian <=> 270° 40 m_sensorPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
42 m_beamApperture(.25*
M_PI/180.0),
47 CIbeoLuxETH::~CIbeoLuxETH()
57 void CIbeoLuxETH::dataCollection()
60 unsigned char msgIn[1], Header[20], ScanListHeader[44], ScanPointData[10];
61 unsigned int datatype, numScanpoints, angleTicks, SPlayer, SPdistance;
63 unsigned char msg[32];
66 m_client.connect(m_ip, m_port);
69 makeCommandHeader(msg);
71 m_client.writeAsync(&msg[0], 32);
74 makeCommandHeader(msg);
75 makeStartCommand(msg);
76 m_client.writeAsync(&msg[0], 28);
83 m_client.readAsync(msgIn, 1, 100, 10);
87 m_client.readAsync(msgIn, 1, 100, 10);
91 m_client.readAsync(msgIn, 1, 100, 10);
95 m_client.readAsync(msgIn, 1, 100, 10);
99 m_client.readAsync(Header, 20, 100, 10);
100 datatype = Header[10] * 0x100 + Header[11];
123 std::cerr <<
"UNKNOWN packet of type " << hex << datatype <<
" received!!\n";
129 CObservation3DRangeScanPtr newObs = CObservation3DRangeScan::Create();
130 newObs->hasPoints3D =
true;
131 newObs->maxRange = 200.00;
133 m_client.readAsync(ScanListHeader, 44, 10, 10);
136 numScanpoints = ScanListHeader[29] * 0x100 + ScanListHeader[28];
137 angleTicks = ScanListHeader[23] * 0x100 + ScanListHeader[22];
139 for (
unsigned int i = 0; i < numScanpoints; ++i)
141 bool dropPacket =
false;
143 m_client.readAsync(ScanPointData, 10, 10, 10);
144 SPlayer = ScanPointData[0] & 0x0F;
146 SPHangle = (char)ScanPointData[3] * 0x100 + ScanPointData[2];
147 SPdistance = ScanPointData[5] * 0x100 + ScanPointData[4];
155 if ((SPHangle < -((
int)angleTicks)/2) || (SPHangle > (int)angleTicks/2))
160 if ((SPdistance < 30) || (SPdistance > 20000))
170 CPoint3D cartesianPoint = convertToCartesian(
171 convertLayerToRad(SPlayer),
172 convertTicksToHRad(SPHangle, angleTicks),
176 newObs->points3D_x.push_back(cartesianPoint.
x());
177 newObs->points3D_y.push_back(cartesianPoint.
y());
178 newObs->points3D_z.push_back(cartesianPoint.z());
183 appendObservation( newObs );
191 makeCommandHeader(msg);
192 makeStopCommand(msg);
193 m_client.writeAsync(&msg[0], 28);
201 float rho, phi, theta;
205 phi = -hrad+(
M_PI/2);
208 x = rho * sin (phi) * cos (theta);
209 y = rho * sin (phi) * sin (theta);
216 double CIbeoLuxETH::convertTicksToHRad(
int hticks,
int hticksPerRotation)
218 return M_PI*2 * hticks / hticksPerRotation;
221 double CIbeoLuxETH::convertLayerToRad(
int scanlayer)
228 vangle = -0.02094395103;
231 vangle = -0.006981317009;
234 vangle = 0.006981317009;
237 vangle = 0.02094395103;
241 std::cerr <<
"Layer: " << scanlayer <<
"! Returning " << vangle <<
" as angle.\n";
251 float pose_x, pose_y, pose_z, pose_yaw, pose_pitch, pose_roll;
252 bool faillNotFound =
false;
253 pose_x = configSource.
read_float(iniSection,
"pose_x",0,faillNotFound);
254 pose_y = configSource.
read_float(iniSection,
"pose_y",0,faillNotFound);
255 pose_z = configSource.
read_float(iniSection,
"pose_z",0,faillNotFound);
256 pose_yaw = configSource.
read_float(iniSection,
"pose_yaw",0,faillNotFound);
257 pose_pitch = configSource.
read_float(iniSection,
"pose_pitch",0,faillNotFound);
258 pose_roll = configSource.
read_float(iniSection,
"pose_roll",0,faillNotFound);
260 m_sensorPose =
CPose3D( pose_x, pose_y, pose_z,
265 void CIbeoLuxETH::makeCommandHeader(
unsigned char*
buffer)
294 void CIbeoLuxETH::makeStartCommand(
unsigned char*
buffer)
305 void CIbeoLuxETH::makeStopCommand(
unsigned char*
buffer)
316 void CIbeoLuxETH::makeTypeCommand(
unsigned char*
buffer)
334 void CIbeoLuxETH::initialize()
347 void CIbeoLuxETH::doProcess()
double x() const
Common members of all points & poses classes.
const unsigned char PacketFound
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
const unsigned char SaveData
Contains classes for various device interfaces.
This "software driver" implements the communication protocol for interfacing a Ibeo Lux laser scanner...
const unsigned char SearchForC2
This class allows loading and storing values and vectors of different types from a configuration text...
const unsigned char SearchForC0
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time...
This namespace contains representation of robot actions and observations.
GLsizei const GLchar ** string
A class used to store a 3D point.
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
TThreadHandle createThreadFromObjectMethod(CLASS *obj, void(CLASS::*func)(PARAM), PARAM param)
Creates a new thread running a non-static method (so it will have access to "this") from another meth...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
const unsigned char SearchForAF
const unsigned char SearchForFE
double BASE_IMPEXP distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.
void BASE_IMPEXP joinThread(const TThreadHandle &threadHandle)
Waits until the given thread ends.