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()
50 dataCollectionThread.join();
54 std::this_thread::sleep_for(10ms);
57 void CIbeoLuxETH::dataCollection()
60 unsigned char msgIn[1], Header[20], ScanListHeader[44], ScanPointData[10];
61 unsigned int datatype, numScanpoints, angleTicks, SPlayer,
64 unsigned char msg[32];
67 m_client.connect(m_ip, m_port);
70 makeCommandHeader(msg);
72 m_client.writeAsync(&msg[0], 32);
75 makeCommandHeader(msg);
76 makeStartCommand(msg);
77 m_client.writeAsync(&msg[0], 28);
84 m_client.readAsync(msgIn, 1, 100, 10);
88 m_client.readAsync(msgIn, 1, 100, 10);
95 m_client.readAsync(msgIn, 1, 100, 10);
102 m_client.readAsync(msgIn, 1, 100, 10);
103 if (msgIn[0] == 0xC2)
109 m_client.readAsync(Header, 20, 100, 10);
110 datatype = Header[10] * 0x100 + Header[11];
133 std::cerr <<
"UNKNOWN packet of type " << hex
134 << datatype <<
" received!!\n";
141 mrpt::make_aligned_shared<CObservation3DRangeScan>();
142 newObs->hasPoints3D =
true;
143 newObs->maxRange = 200.00;
145 m_client.readAsync(ScanListHeader, 44, 10, 10);
148 numScanpoints = ScanListHeader[29] * 0x100 + ScanListHeader[28];
149 angleTicks = ScanListHeader[23] * 0x100 + ScanListHeader[22];
151 for (
unsigned int i = 0; i < numScanpoints; ++i)
153 bool dropPacket =
false;
155 m_client.readAsync(ScanPointData, 10, 10, 10);
157 ScanPointData[0] & 0x0F;
160 SPHangle = (char)ScanPointData[3] * 0x100 +
162 SPdistance = ScanPointData[5] * 0x100 + ScanPointData[4];
171 if ((SPHangle < -((
int)angleTicks) / 2) ||
172 (SPHangle > (int)angleTicks / 2))
179 if ((SPdistance < 30) || (SPdistance > 20000))
189 CPoint3D cartesianPoint = convertToCartesian(
198 newObs->points3D_x.push_back(cartesianPoint.
x());
199 newObs->points3D_y.push_back(cartesianPoint.
y());
200 newObs->points3D_z.push_back(cartesianPoint.z());
205 appendObservation(newObs);
213 makeCommandHeader(msg);
214 makeStopCommand(msg);
215 m_client.writeAsync(&msg[0], 28);
223 float rho, phi, theta;
227 phi = -hrad + (
M_PI / 2);
230 x = rho * sin(phi) * cos(theta);
231 y = rho * sin(phi) * sin(theta);
238 double CIbeoLuxETH::convertTicksToHRad(
int hticks,
int hticksPerRotation)
240 return M_PI * 2 * hticks / hticksPerRotation;
243 double CIbeoLuxETH::convertLayerToRad(
int scanlayer)
250 vangle = -0.02094395103;
253 vangle = -0.006981317009;
256 vangle = 0.006981317009;
259 vangle = 0.02094395103;
263 std::cerr <<
"Layer: " << scanlayer <<
"! Returning " << vangle
271 void CIbeoLuxETH::loadConfig_sensorSpecific(
275 float pose_x, pose_y, pose_z, pose_yaw, pose_pitch, pose_roll;
276 bool faillNotFound =
false;
277 pose_x = configSource.
read_float(iniSection,
"pose_x", 0, faillNotFound);
278 pose_y = configSource.
read_float(iniSection,
"pose_y", 0, faillNotFound);
279 pose_z = configSource.
read_float(iniSection,
"pose_z", 0, faillNotFound);
281 configSource.
read_float(iniSection,
"pose_yaw", 0, faillNotFound);
283 configSource.
read_float(iniSection,
"pose_pitch", 0, faillNotFound);
285 configSource.
read_float(iniSection,
"pose_roll", 0, faillNotFound);
292 void CIbeoLuxETH::makeCommandHeader(
unsigned char*
buffer)
321 void CIbeoLuxETH::makeStartCommand(
unsigned char*
buffer)
332 void CIbeoLuxETH::makeStopCommand(
unsigned char*
buffer)
343 void CIbeoLuxETH::makeTypeCommand(
unsigned char*
buffer)
363 void CIbeoLuxETH::initialize()
374 dataCollectionThread = std::thread(&CIbeoLuxETH::dataCollection,
this);
377 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
std::shared_ptr< CObservation3DRangeScan > Ptr
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
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...
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 distance(const TPoint2D &p1, const TPoint2D &p2)
Gets the distance between two points in a 2D space.