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

ArSimpleConnector.h

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 #ifndef ARSIMPLECONNECTOR_H
00027 #define ARSIMPLECONNECTOR_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ArSerialConnection.h"
00031 #include "ArTcpConnection.h"
00032 #include "ArArgumentBuilder.h"
00033 #include "ArArgumentParser.h"
00034 #include "ariaUtil.h"
00035 #include "ArSick.h"
00036 
00037 class ArRobot;
00038 
00039 
00040 
00042 
00082 class ArSimpleConnector
00083 {
00084 public:
00086   AREXPORT ArSimpleConnector(int *argc, char **argv);
00088   AREXPORT ArSimpleConnector(ArArgumentBuilder *arguments);
00090   AREXPORT ArSimpleConnector(ArArgumentParser *parser);
00092   AREXPORT ~ArSimpleConnector(void);
00094   AREXPORT bool setupRobot(ArRobot *robot);
00096   AREXPORT bool connectRobot(ArRobot *robot);
00098   AREXPORT bool setupLaser(ArSick *sick);
00100   AREXPORT bool setupSecondLaser(ArSick *sick);
00102   AREXPORT bool setupLaserArbitrary(ArSick *sick, int laserNumber);
00104   AREXPORT bool connectLaser(ArSick *sick);
00106   AREXPORT bool connectSecondLaser(ArSick *sick);
00108   AREXPORT bool connectLaserArbitrary(ArSick *sick, int laserNumber);
00110   AREXPORT bool parseArgs(void);
00112   AREXPORT bool parseArgs(ArArgumentParser *parser);
00114   AREXPORT void logOptions(void) const;
00116   AREXPORT void setMaxNumLasers(int maxNumLasers = 1);
00117 protected:
00119   class LaserData
00120   {
00121   public:
00122     LaserData(int number) 
00123       { myNumber = number; myConnect = false; myPort = NULL; 
00124       myRemoteTcpPort = 0; myFlipped = false; myFlippedReallySet = false; 
00125       myPowerControlled = true; myPowerControlledReallySet = false; 
00126       myDegrees = NULL; mySickDegrees = ArSick::DEGREES180; myIncrement = NULL;
00127       mySickIncrement = ArSick::INCREMENT_ONE; myUnits = NULL; 
00128       mySickUnits = ArSick::UNITS_1MM; myBits = NULL; 
00129       mySickBits = ArSick::BITS_1REFLECTOR; }
00130     virtual ~LaserData() {}
00131     int myNumber;
00132     // if we want to connect the laser
00133     bool myConnect;
00134     // the port we want to connect the laser on
00135     const char *myPort;
00136     // laser tcp port if we're doing a remote host
00137     int myRemoteTcpPort;  
00138     // if we have the laser flipped
00139     bool myFlipped;
00140     // if our flipped was really set
00141     bool myFlippedReallySet;
00142     // if we are controlling the laser power
00143     bool myPowerControlled;
00144     // if our flipped was really set
00145     bool myPowerControlledReallySet;
00146     // the degrees we want to use (for the sick)
00147     const char *myDegrees;
00148     // the enum value for those degrees
00149     ArSick::Degrees mySickDegrees;
00150     // the increment we want to use
00151     const char *myIncrement;
00152     // the angular res we want to use (the sick value)
00153     ArSick::Increment mySickIncrement;
00155     const char *myUnits;
00156     // the units we want to use (the sick value)
00157     ArSick::Units mySickUnits;
00159     const char *myBits;
00160     // the units we want to use (the sick value)
00161     ArSick::Bits mySickBits;
00162     // our tcp connection
00163     ArTcpConnection myTcpConn;
00164     // our serial connection
00165     ArSerialConnection mySerConn;
00166   };
00167   int myMaxNumLasers;
00168   std::list<LaserData *> myLasers;
00169   
00171   AREXPORT bool parseLaserArgs(ArArgumentParser *parser, int laserNumber);
00173   AREXPORT void logLaserOptions(unsigned int laserNumber) const;
00174   void reset(void);
00175   // the robot we've set up (so we can find its params)
00176   ArRobot *myRobot; 
00177   // if we're using the sim or not
00178   bool myUsingSim;
00179   // if we're connecting via tcp (not to the sim), what remote host
00180   const char *myRemoteHost;
00181   // robot port, if there isn't one this'll be NULL, which will just
00182   // be the default of ArUtil::COM1
00183   const char *myRobotPort;
00184   // baud for the serial
00185   int myRobotBaud;
00186   // robot tcp port if we're doing a remote host (defaults to 8101)
00187   int myRemoteRobotTcpPort;
00188   
00189   // whether we're connecting to a remote sim or not (so we don't try
00190   // to open a port for the laser)
00191   bool myRemoteIsSim;
00192   // our parser
00193   ArArgumentParser *myParser;
00194   bool myOwnParser;
00195 
00196 
00197   // a few device connections to use to connect to the robot
00198   ArTcpConnection myRobotTcpConn;
00199   ArSerialConnection myRobotSerConn;
00200   // a few device connections to use to connect to the laser
00201   ArTcpConnection myLaserTcpConn;
00202   ArSerialConnection myLaserSerConn;
00203   // device connections to use to connect to the second laser
00204   ArTcpConnection myLaserTcpConn2;
00205   ArSerialConnection myLaserSerConn2;
00206 
00207   ArRetFunctorC<bool, ArSimpleConnector> myParseArgsCB;
00208   ArConstFunctorC<ArSimpleConnector> myLogOptionsCB;
00209 };
00210 
00211 #endif // ARSIMPLECONNECTOR_H

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