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

lineFinderExample.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 "Aria.h"
00027 
00038 int main(int argc, char **argv)
00039 {
00040   Aria::init();
00041 
00042   ArSimpleConnector connector(&argc, argv);
00043   ArRobot robot;
00044   ArSick sick;
00045 
00046   if (!Aria::parseArgs() || argc > 1)
00047   {
00048     Aria::logOptions();
00049     Aria::shutdown();
00050     exit(1);
00051   }
00052   
00053   ArKeyHandler keyHandler;
00054   Aria::setKeyHandler(&keyHandler);
00055   robot.attachKeyHandler(&keyHandler);
00056 
00057 
00058   robot.addRangeDevice(&sick);
00059 
00060   // Create the ArLineFinder object. Set it to log lots of information about its
00061   // processing.
00062   ArLineFinder lineFinder(&sick);
00063   lineFinder.setVerbose(true);
00064 
00065   // Add key callbacks that simply call the ArLineFinder::getLinesAndSaveThem()
00066   // function, which searches for lines in the current set of laser sensor
00067   // readings, and saves them in files with the names 'points' and 'lines'.
00068   ArFunctorC<ArLineFinder> findLineCB(&lineFinder, 
00069                   &ArLineFinder::getLinesAndSaveThem);
00070   keyHandler.addKeyHandler('f', &findLineCB);
00071   keyHandler.addKeyHandler('F', &findLineCB);
00072 
00073   
00074   ArLog::log(ArLog::Normal, "lineFinderExample: connecting to robot...");
00075   if (!connector.connectRobot(&robot))
00076   {
00077     printf("Could not connect to robot... exiting\n");
00078     Aria::shutdown();
00079     return 1;
00080   }
00081   robot.runAsync(true);
00082 
00083   // now set up the laser
00084   ArLog::log(ArLog::Normal, "lineFinderExample: connecting to SICK laser...");
00085   connector.setupLaser(&sick);
00086   sick.runAsync();
00087   if (!sick.blockingConnect())
00088   {
00089     printf("Could not connect to SICK laser... exiting\n");
00090     Aria::shutdown();
00091     return 1;
00092   }
00093 
00094   printf("If you press the 'f' key the points and lines found will be saved\n");
00095   printf("Into the 'points' and 'lines' file in the current working directory\n");
00096 
00097   robot.waitForRunExit();
00098   return 0;
00099 }
00100 
00101 
00102 

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