00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "ArExport.h"
00027 #include "ariaOSDef.h"
00028 #include "ArLaserReflectorDevice.h"
00029 #include "ArSensorReading.h"
00030 #include "ArRobot.h"
00031
00032 AREXPORT ArLaserReflectorDevice::ArLaserReflectorDevice(ArRangeDevice *laser,
00033 ArRobot *robot,
00034 const char *name) :
00035
00036
00037
00038
00039 ArRangeDevice(361, 361, name, 32000),
00040 myProcessCB(this, &ArLaserReflectorDevice::processReadings)
00041 {
00042 myLaser = laser;
00043 myRobot = robot;
00044 if (myRobot != NULL)
00045 myRobot->addSensorInterpTask(myName.c_str(), 10, &myProcessCB);
00046 setCurrentDrawingData(new ArDrawingData("polyDots",
00047 ArColor(0xb0, 0xb0, 0xff),
00048 60,
00049 77,
00050 200,
00051 "DefaultOff"),
00052 true);
00053 }
00054
00055 AREXPORT ArLaserReflectorDevice::~ArLaserReflectorDevice()
00056 {
00057 if (myRobot != NULL)
00058 myRobot->remSensorInterpTask(&myProcessCB);
00059 }
00060
00061 AREXPORT void ArLaserReflectorDevice::setRobot(ArRobot *robot)
00062 {
00063
00064 }
00065
00066 AREXPORT void ArLaserReflectorDevice::processReadings(void)
00067 {
00068 int i;
00069 ArSensorReading *reading;
00070 myLaser->lockDevice();
00071 lockDevice();
00072
00073 const std::list<ArSensorReading *> *rawReadings;
00074 std::list<ArSensorReading *>::const_iterator rawIt;
00075 rawReadings = myLaser->getRawReadings();
00076 myCurrentBuffer.beginRedoBuffer();
00077
00078 if (rawReadings->begin() != rawReadings->end())
00079 {
00080 for (rawIt = rawReadings->begin(); rawIt != rawReadings->end(); rawIt++)
00081 {
00082 reading = (*rawIt);
00083 if (!reading->getIgnoreThisReading() && reading->getExtraInt() > 0)
00084 myCurrentBuffer.redoReading(reading->getPose().getX(),
00085 reading->getPose().getY());
00086 }
00087 }
00088
00089 myCurrentBuffer.endRedoBuffer();
00090
00091 unlockDevice();
00092 myLaser->unlockDevice();
00093 }
00094