17 #define APPERTURE 4.712385 // in radian <=> 270° 39 m_sensorPose(0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
41 m_beamApperture(.25 *
M_PI / 180.0),
46 CIbeoLuxETH::~CIbeoLuxETH()
49 dataCollectionThread.join();
53 std::this_thread::sleep_for(10ms);
56 void CIbeoLuxETH::dataCollection()
59 unsigned char msgIn[1], Header[20], ScanListHeader[44], ScanPointData[10];
60 unsigned int datatype, numScanpoints, angleTicks, SPlayer,
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);
94 m_client.readAsync(msgIn, 1, 100, 10);
101 m_client.readAsync(msgIn, 1, 100, 10);
102 if (msgIn[0] == 0xC2)
108 m_client.readAsync(Header, 20, 100, 10);
109 datatype = Header[10] * 0x100 + Header[11];
132 std::cerr <<
"UNKNOWN packet of type " << hex
133 << datatype <<
" received!!\n";
140 mrpt::make_aligned_shared<CObservation3DRangeScan>();
141 newObs->hasPoints3D =
true;
142 newObs->maxRange = 200.00;
144 m_client.readAsync(ScanListHeader, 44, 10, 10);
147 numScanpoints = ScanListHeader[29] * 0x100 + ScanListHeader[28];
148 angleTicks = ScanListHeader[23] * 0x100 + ScanListHeader[22];
150 for (
unsigned int i = 0; i < numScanpoints; ++i)
152 bool dropPacket =
false;
154 m_client.readAsync(ScanPointData, 10, 10, 10);
156 ScanPointData[0] & 0x0F;
159 SPHangle = (char)ScanPointData[3] * 0x100 +
161 SPdistance = ScanPointData[5] * 0x100 + ScanPointData[4];
170 if ((SPHangle < -((
int)angleTicks) / 2) ||
171 (SPHangle > (int)angleTicks / 2))
178 if ((SPdistance < 30) || (SPdistance > 20000))
188 CPoint3D cartesianPoint = convertToCartesian(
197 newObs->points3D_x.push_back(cartesianPoint.
x());
198 newObs->points3D_y.push_back(cartesianPoint.
y());
199 newObs->points3D_z.push_back(cartesianPoint.z());
204 appendObservation(newObs);
212 makeCommandHeader(msg);
213 makeStopCommand(msg);
214 m_client.writeAsync(&msg[0], 28);
222 float rho, phi, theta;
226 phi = -hrad + (
M_PI / 2);
229 x = rho * sin(phi) * cos(theta);
230 y = rho * sin(phi) * sin(theta);
237 double CIbeoLuxETH::convertTicksToHRad(
int hticks,
int hticksPerRotation)
239 return M_PI * 2 * hticks / hticksPerRotation;
242 double CIbeoLuxETH::convertLayerToRad(
int scanlayer)
249 vangle = -0.02094395103;
252 vangle = -0.006981317009;
255 vangle = 0.006981317009;
258 vangle = 0.02094395103;
262 std::cerr <<
"Layer: " << scanlayer <<
"! Returning " << vangle
270 void CIbeoLuxETH::loadConfig_sensorSpecific(
274 float pose_x, pose_y, pose_z, pose_yaw, pose_pitch, pose_roll;
275 bool faillNotFound =
false;
276 pose_x = configSource.
read_float(iniSection,
"pose_x", 0, faillNotFound);
277 pose_y = configSource.
read_float(iniSection,
"pose_y", 0, faillNotFound);
278 pose_z = configSource.
read_float(iniSection,
"pose_z", 0, faillNotFound);
280 configSource.
read_float(iniSection,
"pose_yaw", 0, faillNotFound);
282 configSource.
read_float(iniSection,
"pose_pitch", 0, faillNotFound);
284 configSource.
read_float(iniSection,
"pose_roll", 0, faillNotFound);
291 void CIbeoLuxETH::makeCommandHeader(
unsigned char*
buffer)
320 void CIbeoLuxETH::makeStartCommand(
unsigned char*
buffer)
331 void CIbeoLuxETH::makeStopCommand(
unsigned char*
buffer)
342 void CIbeoLuxETH::makeTypeCommand(
unsigned char*
buffer)
362 void CIbeoLuxETH::initialize()
373 dataCollectionThread = std::thread(&CIbeoLuxETH::dataCollection,
this);
376 void CIbeoLuxETH::doProcess()
double x() const
Common members of all points & poses classes.
const unsigned char PacketFound
double DEG2RAD(const double x)
Degrees to radians.
const unsigned char SaveData
Contains classes for various device interfaces.
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
This "software driver" implements the communication protocol for interfacing a Ibeo Lux laser scanner...
const unsigned char SearchForC2
const unsigned char SearchForC0
This class allows loading and storing values and vectors of different types from a configuration text...
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.