void ArLaserFilter::processReadings(void) { myLaser->lockDevice(); selfLockDevice(); const std::list<ArSensorReading *> *rdRawReadings; std::list<ArSensorReading *>::const_iterator rdIt; if ((rdRawReadings = myLaser->getRawReadings()) == NULL) { selfUnlockDevice(); myLaser->unlockDevice(); return; } size_t rawSize = myRawReadings->size(); size_t rdRawSize = myLaser->getRawReadings()->size(); while (rawSize < rdRawSize) { myRawReadings->push_back(new ArSensorReading); rawSize++; } // set where the pose was taken myCurrentBuffer.setPoseTaken( myLaser->getCurrentRangeBuffer()->getPoseTaken()); myCurrentBuffer.setEncoderPoseTaken( myLaser->getCurrentRangeBuffer()->getEncoderPoseTaken()); std::list<ArSensorReading *>::iterator it; ArSensorReading *rdReading; ArSensorReading *reading; #ifdef DEBUGRANGEFILTER FILE *file = NULL; file = ArUtil::fopen("/mnt/rdsys/tmp/filter", "w"); #endif std::map<int, ArSensorReading *> readingMap; int numReadings = 0; // first pass to copy the readings and put them into a map for (rdIt = rdRawReadings->begin(), it = myRawReadings->begin(); rdIt != rdRawReadings->end() && it != myRawReadings->end(); rdIt++, it++) { rdReading = (*rdIt); reading = (*it); *reading = *rdReading; readingMap[numReadings] = reading; numReadings++; } char buf[1024]; int i; int j; ArSensorReading *lastAddedReading = NULL; // now walk through the readings to filter them for (i = 0; i < numReadings; i++) { reading = readingMap[i]; // if we're ignoring this reading then just get on with life if (reading->getIgnoreThisReading()) continue; if (myMaxRange >= 0 && reading->getRange() > myMaxRange) { reading->setIgnoreThisReading(true); continue; } if (lastAddedReading != NULL) { if (lastAddedReading->getPose().findDistanceTo(reading->getPose()) < 50) { #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%.1f too close from last %6.0f\n", reading->getSensorTh(), lastAddedReading->getPose().findDistanceTo( reading->getPose())); #endif reading->setIgnoreThisReading(true); continue; } #ifdef DEBUGRANGEFILTER else if (file != NULL) fprintf(file, "%.1f from last %6.0f\n", reading->getSensorTh(), lastAddedReading->getPose().findDistanceTo( reading->getPose())); #endif } buf[0] = '\0'; bool goodAll = true; bool goodAny = false; if (myAnyFactor <= 0) goodAny = true; for (j = i - 1; (j >= 0 && //good && fabs(ArMath::subAngle(readingMap[j]->getSensorTh(), reading->getSensorTh())) <= myAngleToCheck); j--) { if (readingMap[j]->getIgnoreThisReading()) { #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6s", buf, "i"); #endif continue; } #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d", buf, readingMap[j]->getRange()); #endif if (myAllFactor > 0 && !checkRanges(reading->getRange(), readingMap[j]->getRange(), myAllFactor)) goodAll = false; if (myAnyFactor > 0 && checkRanges(reading->getRange(), readingMap[j]->getRange(), myAnyFactor)) goodAny = true; } #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d*", buf, reading->getRange()); #endif for (j = i + 1; (j < numReadings && //good && fabs(ArMath::subAngle(readingMap[j]->getSensorTh(), reading->getSensorTh())) <= myAngleToCheck); j++) { if (readingMap[j]->getIgnoreThisReading()) { #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6s", buf, "i"); #endif continue; } #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d", buf, readingMap[j]->getRange()); #endif if (myAllFactor > 0 && !checkRanges(reading->getRange(), readingMap[j]->getRange(), myAllFactor)) goodAll = false; if (myAnyFactor > 0 && checkRanges(reading->getRange(), readingMap[j]->getRange(), myAnyFactor)) goodAny = true; } if (!goodAll || !goodAny) reading->setIgnoreThisReading(true); else lastAddedReading = reading; #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%5.1f %6d %c\t%s\n", reading->getSensorTh(), reading->getRange(), good ? 'g' : 'b', buf); #endif } #ifdef DEBUGRANGEFILTER if (file != NULL) fclose(file); #endif laserProcessReadings(); selfUnlockDevice(); myLaser->unlockDevice(); }
void ArUrg::sensorInterp(void) { ArTime readingRequested; std::string reading; myReadingMutex.lock(); if (myReading.empty()) { myReadingMutex.unlock(); return; } readingRequested = myReadingRequested; reading = myReading; myReading = ""; myReadingMutex.unlock(); ArTime time = readingRequested; ArPose pose; int ret; int retEncoder; ArPose encoderPose; //time.addMSec(-13); if (myRobot == NULL || !myRobot->isConnected()) { pose.setPose(0, 0, 0); encoderPose.setPose(0, 0, 0); } else if ((ret = myRobot->getPoseInterpPosition(time, &pose)) < 0 || (retEncoder = myRobot->getEncoderPoseInterpPosition(time, &encoderPose)) < 0) { ArLog::log(ArLog::Normal, "%s: reading too old to process", getName()); return; } ArTransform transform; transform.setTransform(pose); unsigned int counter = 0; if (myRobot != NULL) counter = myRobot->getCounter(); lockDevice(); myDataMutex.lock(); //double angle; int i; int len = reading.size(); int range; int big; int little; //int onStep; std::list<ArSensorReading *>::reverse_iterator it; ArSensorReading *sReading; bool ignore; for (it = myRawReadings->rbegin(), i = 0; it != myRawReadings->rend() && i < len - 1; it++, i += 2) { ignore = false; big = reading[i] - 0x30; little = reading[i+1] - 0x30; range = (big << 6 | little); if (range < 20) { /* Well that didn't work... // if the range is 1 to 5 that means it has low intensity, which // could be black or maybe too far... try ignoring it and see if // it helps with too much clearing if (range >= 1 || range <= 5) ignore = true; */ range = 4096; } sReading = (*it); sReading->newData(range, pose, encoderPose, transform, counter, time, ignore, 0); } myDataMutex.unlock(); laserProcessReadings(); unlockDevice(); }
void ArUrg_2_0::sensorInterp(void) { ArTime readingRequested; std::string reading; myReadingMutex.lock(); if (myReading.empty()) { myReadingMutex.unlock(); return; } readingRequested = myReadingRequested; reading = myReading; myReading = ""; myReadingMutex.unlock(); ArTime time = readingRequested; ArPose pose; int ret; int retEncoder; ArPose encoderPose; //time.addMSec(-13); if (myRobot == NULL || !myRobot->isConnected()) { pose.setPose(0, 0, 0); encoderPose.setPose(0, 0, 0); } else if ((ret = myRobot->getPoseInterpPosition(time, &pose)) < 0 || (retEncoder = myRobot->getEncoderPoseInterpPosition(time, &encoderPose)) < 0) { ArLog::log(ArLog::Normal, "%s: reading too old to process", getName()); return; } ArTransform transform; transform.setTransform(pose); unsigned int counter = 0; if (myRobot != NULL) counter = myRobot->getCounter(); lockDevice(); myDataMutex.lock(); //double angle; int i; int len = reading.size(); int range; int giant; int big; int little; //int onStep; std::list<ArSensorReading *>::reverse_iterator it; ArSensorReading *sReading; int iMax; int iIncr; if (myUseThreeDataBytes) { iMax = len - 2; iIncr = 3; } else { iMax = len - 1; iIncr = 2; } bool ignore; for (it = myRawReadings->rbegin(), i = 0; it != myRawReadings->rend() && i < iMax; //len - 2; it++, i += iIncr) //3) { ignore = false; if (myUseThreeDataBytes) { giant = reading[i] - 0x30; big = reading[i+1] - 0x30; little = reading[i+2] - 0x30; range = (giant << 12 | big << 6 | little); } else { big = reading[i] - 0x30; little = reading[i+1] - 0x30; range = (big << 6 | little); } if (range < myDMin) range = myDMax+1; sReading = (*it); sReading->newData(range, pose, encoderPose, transform, counter, time, ignore, 0); } myDataMutex.unlock(); int previous = getCumulativeBuffer()->size(); laserProcessReadings(); int now = getCumulativeBuffer()->size(); unlockDevice(); }
void ArSZSeries::sensorInterp(void) { ArSZSeriesPacket *packet; while (1) { myPacketsMutex.lock(); if (myPackets.empty()) { myPacketsMutex.unlock(); return; } packet = myPackets.front(); myPackets.pop_front(); myPacketsMutex.unlock(); //set up the times and poses ArTime time = packet->getTimeReceived(); ArPose pose; int ret; int retEncoder; ArPose encoderPose; int dist; int j; unsigned char *buf = (unsigned char *) packet->getBuf(); // this value should be found more empirically... but we used 1/75 // hz for the lms2xx and it was fine, so here we'll use 1/50 hz for now if (!time.addMSec(-30)) { ArLog::log(ArLog::Normal, "%s::sensorInterp() error adding msecs (-30)", getName()); } if (myRobot == NULL || !myRobot->isConnected()) { pose.setPose(0, 0, 0); encoderPose.setPose(0, 0, 0); } else if ((ret = myRobot->getPoseInterpPosition(time, &pose)) < 0 || (retEncoder = myRobot->getEncoderPoseInterpPosition(time, &encoderPose)) < 0) { ArLog::log(ArLog::Normal, "%s::sensorInterp() reading too old to process", getName()); delete packet; continue; } ArTransform transform; transform.setTransform(pose); unsigned int counter = 0; if (myRobot != NULL) counter = myRobot->getCounter(); lockDevice(); myDataMutex.lock(); //std::list<ArSensorReading *>::reverse_iterator it; ArSensorReading *reading; myNumChans = packet->getNumReadings(); double eachAngularStepWidth; int eachNumberData; // PS - test for SZ-16D, each reading is .36 degrees for 270 degrees if (packet->getNumReadings() == 751) { eachNumberData = packet->getNumReadings(); } else { ArLog::log(ArLog::Normal, "%s::sensorInterp() The number of readings is not correct = %d", getName(), myNumChans); // PS 12/6/12 - unlock before continuing delete packet; myDataMutex.unlock(); unlockDevice(); continue; } // If we don't have any sensor readings created at all, make 'em all if (myRawReadings->size() == 0) { for (j = 0; j < eachNumberData; j++) { myRawReadings->push_back(new ArSensorReading); } } if (eachNumberData > myRawReadings->size()) { ArLog::log(ArLog::Terse, "%s::sensorInterp() Bad data, in theory have %d readings but can only have 751... skipping this packet", getName(), eachNumberData); // PS 12/6/12 - unlock and delete before continuing delete packet; myDataMutex.unlock(); unlockDevice(); continue; } std::list<ArSensorReading *>::iterator it; double atDeg; int onReading; double start; double increment; eachAngularStepWidth = .36; if (myFlipped) { start = mySensorPose.getTh() + 135; increment = -eachAngularStepWidth; } else { start = -(mySensorPose.getTh() + 135); increment = eachAngularStepWidth; } int readingIndex; bool ignore = false; for (atDeg = start, it = myRawReadings->begin(), readingIndex = 0, onReading = 0; onReading < eachNumberData; atDeg += increment, it++, readingIndex++, onReading++) { reading = (*it); dist = (((buf[readingIndex * 2] & 0x3f)<< 8) | (buf[(readingIndex * 2) + 1])); // note max distance is 16383 mm, if the measurement // object is not there, distance will still be 16383 /* ArLog::log(ArLog::Normal, "reading %d first half = 0x%x, second half = 0x%x dist = %d", readingIndex, buf[(readingIndex *2)+1], buf[readingIndex], dist); */ reading->resetSensorPosition(ArMath::roundInt(mySensorPose.getX()), ArMath::roundInt(mySensorPose.getY()), atDeg); reading->newData(dist, pose, encoderPose, transform, counter, time, ignore, 0); // no reflector yet //printf("dist = %d, pose = %d, encoderPose = %d, transform = %d, counter = %d, time = %d, igore = %d", // dist, pose, encoderPose, transform, counter, // time, ignore); } /* ArLog::log(ArLog::Normal, "Received: %s %s scan %d numReadings %d", packet->getCommandType(), packet->getCommandName(), myScanCounter, onReading); */ myDataMutex.unlock(); /* ArLog::log( ArLog::Terse, "%s::sensorInterp() Telegram number = %d ", getName(), packet->getTelegramNumByte2()); */ laserProcessReadings(); unlockDevice(); delete packet; } }
void ArLMS1XX::sensorInterp(void) { ArLMS1XXPacket *packet; while (1) { myPacketsMutex.lock(); if (myPackets.empty()) { myPacketsMutex.unlock(); return; } packet = myPackets.front(); myPackets.pop_front(); myPacketsMutex.unlock(); // if its not a reading packet just skip it if (strcasecmp(packet->getCommandName(), "LMDscandata") != 0) { delete packet; continue; } //set up the times and poses ArTime time = packet->getTimeReceived(); ArPose pose; int ret; int retEncoder; ArPose encoderPose; // this value should be found more empirically... but we used 1/75 // hz for the lms2xx and it was fine, so here we'll use 1/50 hz for now time.addMSec(-20); if (myRobot == NULL || !myRobot->isConnected()) { pose.setPose(0, 0, 0); encoderPose.setPose(0, 0, 0); } else if ((ret = myRobot->getPoseInterpPosition(time, &pose)) < 0 || (retEncoder = myRobot->getEncoderPoseInterpPosition(time, &encoderPose)) < 0) { ArLog::log(ArLog::Normal, "%s: reading too old to process", getName()); delete packet; continue; } ArTransform transform; transform.setTransform(pose); unsigned int counter = 0; if (myRobot != NULL) counter = myRobot->getCounter(); lockDevice(); myDataMutex.lock(); int i; int dist; //int onStep; std::list<ArSensorReading *>::reverse_iterator it; ArSensorReading *reading; // read the extra stuff myVersionNumber = packet->bufToUByte2(); myDeviceNumber = packet->bufToUByte2(); mySerialNumber = packet->bufToUByte4(); myDeviceStatus1 = packet->bufToUByte(); myDeviceStatus2 = packet->bufToUByte(); myMessageCounter = packet->bufToUByte2(); myScanCounter = packet->bufToUByte2(); myPowerUpDuration = packet->bufToUByte4(); myTransmissionDuration = packet->bufToUByte4(); myInputStatus1 = packet->bufToUByte(); myInputStatus2 = packet->bufToUByte(); myOutputStatus1 = packet->bufToUByte(); myOutputStatus2 = packet->bufToUByte(); myReserved = packet->bufToUByte2(); myScanningFreq = packet->bufToUByte4(); myMeasurementFreq = packet->bufToUByte4(); if (myDeviceStatus1 != 0 || myDeviceStatus2 != 0) ArLog::log(myLogLevel, "%s: DeviceStatus %d %d", myDeviceStatus1, myDeviceStatus2); /* printf("Received: %s %s ver %d devNum %d serNum %d scan %d sf %d mf %d\n", packet->getCommandType(), packet->getCommandName(), myVersionNumber, myDeviceNumber, mySerialNumber, myScanCounter, myScanningFreq, myMeasurementFreq); */ myNumberEncoders = packet->bufToUByte2(); //printf("\tencoders %d\n", myNumberEncoders); if (myNumberEncoders > 0) ArLog::log(myLogLevel, "%s: Encoders %d", getName(), myNumberEncoders); for (i = 0; i < myNumberEncoders; i++) { packet->bufToUByte4(); packet->bufToUByte2(); //printf("\t\t%d\t%d %d\n", i, eachEncoderPosition, eachEncoderSpeed); } myNumChans = packet->bufToUByte2(); if (myNumChans > 1) ArLog::log(myLogLevel, "%s: NumChans %d", getName(), myNumChans); //printf("\tnumchans %d\n", myNumChans); char eachChanMeasured[1024]; int eachScalingFactor; int eachScalingOffset; double eachStartingAngle; double eachAngularStepWidth; int eachNumberData; for (i = 0; i < myNumChans; i++) { eachChanMeasured[0] = '\0'; packet->bufToStr(eachChanMeasured, sizeof(eachChanMeasured)); // if this isn't the data we want then skip it if (strcasecmp(eachChanMeasured, "DIST1") != 0 && strcasecmp(eachChanMeasured, "DIST2") != 0) continue; eachScalingFactor = packet->bufToUByte4(); // FIX should be real eachScalingOffset = packet->bufToUByte4(); // FIX should be real eachStartingAngle = packet->bufToByte4() / 10000.0; eachAngularStepWidth = packet->bufToUByte2() / 10000.0; eachNumberData = packet->bufToUByte2(); /* ArLog::log(myLogLevel, "%s: %s start %.1f step %.2f numReadings %d", getName(), eachChanMeasured, eachStartingAngle, eachAngularStepWidth, eachNumberData); */ /* printf("\t\t%s\tscl %d %d ang %g %g num %d\n", eachChanMeasured, eachScalingFactor, eachScalingOffset, eachStartingAngle, eachAngularStepWidth, eachNumberData); */ // If we don't have any sensor readings created at all, make 'em all if (myRawReadings->size() == 0) for (i = 0; i < eachNumberData; i++) myRawReadings->push_back(new ArSensorReading); if (eachNumberData > myRawReadings->size()) { ArLog::log(ArLog::Terse, "%s: Bad data, in theory have %d readings but can only have 541... skipping this packet\n", getName(), eachNumberData); printf("%s\n", packet->getBuf()); continue; } std::list<ArSensorReading *>::iterator it; double atDeg; int onReading; double start; double increment; if (myFlipped) { start = mySensorPose.getTh() + eachStartingAngle - 90.0 + eachAngularStepWidth * eachNumberData; increment = -eachAngularStepWidth; } else { start = mySensorPose.getTh() + eachStartingAngle - 90.0; increment = eachAngularStepWidth; } bool ignore; for (//atDeg = mySensorPose.getTh() + eachStartingAngle - 90.0, //atDeg = mySensorPose.getTh() + eachStartingAngle - 90.0 + eachAngularStepWidth * eachNumberData, atDeg = start, it = myRawReadings->begin(), onReading = 0; onReading < eachNumberData; //atDeg += eachAngularStepWidth, //atDeg -= eachAngularStepWidth, atDeg += increment, it++, onReading++) { ignore = false; if (atDeg < getStartDegrees() || atDeg > getEndDegrees()) ignore = true; reading = (*it); dist = packet->bufToUByte2(); if (dist == 0) { ignore = true; } /* else if (!ignore && dist < 150) { //ignore = true; ArLog::log(ArLog::Normal, "%s: Reading at %.1f %s is %d (not ignoring, just warning)", getName(), atDeg, eachChanMeasured, dist); } */ reading->resetSensorPosition(ArMath::roundInt(mySensorPose.getX()), ArMath::roundInt(mySensorPose.getY()), atDeg); reading->newData(dist, pose, encoderPose, transform, counter, time, ignore, 0); // no reflector yet } /* ArLog::log(ArLog::Normal, "Received: %s %s scan %d numReadings %d", packet->getCommandType(), packet->getCommandName(), myScanCounter, onReading); */ } myDataMutex.unlock(); laserProcessReadings(); unlockDevice(); delete packet; } }
void ArLaserFilter::processReadings(void) { myLaser->lockDevice(); selfLockDevice(); const std::list<ArSensorReading *> *rdRawReadings; std::list<ArSensorReading *>::const_iterator rdIt; if ((rdRawReadings = myLaser->getRawReadings()) == NULL) { selfUnlockDevice(); myLaser->unlockDevice(); return; } size_t rawSize = myRawReadings->size(); size_t rdRawSize = myLaser->getRawReadings()->size(); while (rawSize < rdRawSize) { myRawReadings->push_back(new ArSensorReading); rawSize++; } // set where the pose was taken myCurrentBuffer.setPoseTaken( myLaser->getCurrentRangeBuffer()->getPoseTaken()); myCurrentBuffer.setEncoderPoseTaken( myLaser->getCurrentRangeBuffer()->getEncoderPoseTaken()); std::list<ArSensorReading *>::iterator it; ArSensorReading *rdReading; ArSensorReading *reading; #ifdef DEBUGRANGEFILTER FILE *file = NULL; //file = ArUtil::fopen("/mnt/rdsys/tmp/filter", "w"); file = ArUtil::fopen("/tmp/filter", "w"); #endif std::map<int, ArSensorReading *> readingMap; int numReadings = 0; // first pass to copy the readings and put them into a map for (rdIt = rdRawReadings->begin(), it = myRawReadings->begin(); rdIt != rdRawReadings->end() && it != myRawReadings->end(); rdIt++, it++) { rdReading = (*rdIt); reading = (*it); *reading = *rdReading; readingMap[numReadings] = reading; numReadings++; } // if we're not doing any filtering, just short circuit out now if (myAllFactor <= 0 && myAnyFactor <= 0 && myAnyMinRange <= 0) { laserProcessReadings(); copyReadingCount(myLaser); selfUnlockDevice(); myLaser->unlockDevice(); #ifdef DEBUGRANGEFILTER if (file != NULL) fclose(file); #endif return; } char buf[1024]; int i; int j; //ArSensorReading *lastAddedReading = NULL; // now walk through the readings to filter them for (i = 0; i < numReadings; i++) { reading = readingMap[i]; // if we're ignoring this reading then just get on with life if (reading->getIgnoreThisReading()) continue; /* Taking this check out since the base class does it now and if * it gets marked ignore now it won't get used for clearing * cumulative readings if (myMaxRange >= 0 && reading->getRange() > myMaxRange) { #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%.1f beyond max range at %d\n", reading->getSensorTh(), reading->getRange()); #endif reading->setIgnoreThisReading(true); continue; } */ if (myAnyMinRange >= 0 && reading->getRange() < myAnyMinRange && (reading->getSensorTh() < myAnyMinRangeLessThanAngle || reading->getSensorTh() > myAnyMinRangeGreaterThanAngle)) { #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%.1f within min range at %d\n", reading->getSensorTh(), reading->getRange()); #endif reading->setIgnoreThisReading(true); continue; } /* if (lastAddedReading != NULL) { if (lastAddedReading->getPose().findDistanceTo(reading->getPose()) < 50) { #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%.1f too close from last %6.0f\n", reading->getSensorTh(), lastAddedReading->getPose().findDistanceTo( reading->getPose())); #endif reading->setIgnoreThisReading(true); continue; } #ifdef DEBUGRANGEFILTER else if (file != NULL) fprintf(file, "%.1f from last %6.0f\n", reading->getSensorTh(), lastAddedReading->getPose().findDistanceTo( reading->getPose())); #endif } */ buf[0] = '\0'; bool goodAll = true; bool goodAny = false; bool goodMinRange = true; if (myAnyFactor <= 0) goodAny = true; for (j = i - 1; (j >= 0 && //good && fabs(ArMath::subAngle(readingMap[j]->getSensorTh(), reading->getSensorTh())) <= myAngleToCheck); j--) { /* You can't skip these, or you get onesided filtering if (readingMap[j]->getIgnoreThisReading()) { #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6s", buf, "i"); #endif continue; } */ #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d", buf, readingMap[j]->getRange()); #endif if (myAllFactor > 0 && !checkRanges(reading->getRange(), readingMap[j]->getRange(), myAllFactor)) goodAll = false; if (myAnyFactor > 0 && checkRanges(reading->getRange(), readingMap[j]->getRange(), myAnyFactor)) goodAny = true; if (myAnyMinRange > 0 && (reading->getSensorTh() < myAnyMinRangeLessThanAngle || reading->getSensorTh() > myAnyMinRangeGreaterThanAngle) && readingMap[j]->getRange() <= myAnyMinRange) goodMinRange = false; } #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d*", buf, reading->getRange()); #endif for (j = i + 1; (j < numReadings && //good && fabs(ArMath::subAngle(readingMap[j]->getSensorTh(), reading->getSensorTh())) <= myAngleToCheck); j++) { // you can't ignore these or you get one sided filtering /* if (readingMap[j]->getIgnoreThisReading()) { #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6s", buf, "i"); #endif continue; } */ #ifdef DEBUGRANGEFILTER sprintf(buf, "%s %6d", buf, readingMap[j]->getRange()); #endif if (myAllFactor > 0 && !checkRanges(reading->getRange(), readingMap[j]->getRange(), myAllFactor)) goodAll = false; if (myAnyFactor > 0 && checkRanges(reading->getRange(), readingMap[j]->getRange(), myAnyFactor)) goodAny = true; if (myAnyMinRange > 0 && (reading->getSensorTh() < myAnyMinRangeLessThanAngle || reading->getSensorTh() > myAnyMinRangeGreaterThanAngle) && readingMap[j]->getRange() <= myAnyMinRange) goodMinRange = false; } if (!goodAll || !goodAny || !goodMinRange) reading->setIgnoreThisReading(true); /* else lastAddedReading = reading; */ #ifdef DEBUGRANGEFILTER if (file != NULL) fprintf(file, "%5.1f %6d %c\t%s\n", reading->getSensorTh(), reading->getRange(), goodAll && goodAny && goodMinRange ? 'g' : 'b', buf); #endif } #ifdef DEBUGRANGEFILTER if (file != NULL) fclose(file); #endif laserProcessReadings(); copyReadingCount(myLaser); selfUnlockDevice(); myLaser->unlockDevice(); }