Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArLaserReflectorDevice.cpp

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
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   ArRangeDevice(laser->getCurrentRangeBuffer()->getSize(), 
00037         laser->getCumulativeRangeBuffer()->getSize(), name,
00038         laser->getMaxRange()), */
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,  // mm length of arrow
00049                                           77,  // above the normal laser
00050                       200, // default refresh
00051                       "DefaultOff"), // defaults to off but can be turned on
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   // specifically do nothing since this is just here for debugging
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 

Generated on Tue Feb 20 10:51:40 2007 for Aria by  doxygen 1.4.0