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

ArSimpleConnector.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
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 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARSIMPLECONNECTOR_H
00028 #define ARSIMPLECONNECTOR_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ArSerialConnection.h"
00032 #include "ArTcpConnection.h"
00033 #include "ArArgumentBuilder.h"
00034 #include "ArArgumentParser.h"
00035 #include "ariaUtil.h"
00036 #include "ArSick.h"
00037 
00038 class ArRobot;
00039 
00040 
00041 
00043 
00060 class ArSimpleConnector
00061 {
00062 public:
00064   ArSimpleConnector(int *argc, char **argv);
00066   ArSimpleConnector(ArArgumentBuilder *arguments);
00068   ArSimpleConnector(ArArgumentParser *parser);
00070   ~ArSimpleConnector(void);
00072   bool setupRobot(ArRobot *robot);
00074   bool connectRobot(ArRobot *robot);
00076   bool setupLaser(ArSick *sick);
00078   bool setupSecondLaser(ArSick *sick);
00080   bool setupLaserArbitrary(ArSick *sick, int laserNumber);
00082   bool connectLaser(ArSick *sick);
00084   bool connectSecondLaser(ArSick *sick);
00086   bool connectLaserArbitrary(ArSick *sick, int laserNumber);
00088   bool parseArgs(void);
00090   bool parseArgs(ArArgumentParser *parser);
00092   void logOptions(void) const;
00094   void setMaxNumLasers(int maxNumLasers = 1);
00095 protected:
00097   class LaserData
00098   {
00099   public:
00100     LaserData(int number) 
00101       { myNumber = number; myConnect = false; myPort = NULL; 
00102       myRemoteTcpPort = 0; myFlipped = false; myFlippedReallySet = false; 
00103       myPowerControlled = true; myPowerControlledReallySet = false; 
00104       myDegrees = NULL; mySickDegrees = ArSick::DEGREES180; myIncrement = NULL;
00105       mySickIncrement = ArSick::INCREMENT_ONE; }
00106     virtual ~LaserData() {}
00107     int myNumber;
00108     // if we want to connect the laser
00109     bool myConnect;
00110     // the port we want to connect the laser on
00111     const char *myPort;
00112     // laser tcp port if we're doing a remote host
00113     int myRemoteTcpPort;  
00114     // if we have the laser flipped
00115     bool myFlipped;
00116     // if our flipped was really set
00117     bool myFlippedReallySet;
00118     // if we are controlling the laser power
00119     bool myPowerControlled;
00120     // if our flipped was really set
00121     bool myPowerControlledReallySet;
00122     // the degrees we want to use (for the sick)
00123     const char *myDegrees;
00124     // the enum value for those degrees
00125     ArSick::Degrees mySickDegrees;
00126     // the increment we want to use (for the sick)
00127     const char *myIncrement;
00128     // the angular res we want to use (for the sick)
00129     ArSick::Increment mySickIncrement;
00130     // our tcp connection
00131     ArTcpConnection myTcpConn;
00132     // our serial connection
00133     ArSerialConnection mySerConn;
00134   };
00135   int myMaxNumLasers;
00136   std::list<LaserData *> myLasers;
00137   
00139   bool parseLaserArgs(ArArgumentParser *parser, int laserNumber);
00141   void logLaserOptions(unsigned int laserNumber) const;
00142   void reset(void);
00143   // the robot we've set up (so we can find its params)
00144   ArRobot *myRobot; 
00145   // if we're using the sim or not
00146   bool myUsingSim;
00147   // if we're connecting via tcp (not to the sim), what remote host
00148   const char *myRemoteHost;
00149   // robot port, if there isn't one this'll be NULL, which will just
00150   // be the default of ArUtil::COM1
00151   const char *myRobotPort;
00152   // baud for the serial
00153   int myRobotBaud;
00154   // robot tcp port if we're doing a remote host (defaults to 8101)
00155   int myRemoteRobotTcpPort;
00156   
00157   // whether we're connecting to a remote sim or not (so we don't try
00158   // to open a port for the laser)
00159   bool myRemoteIsSim;
00160   // our parser
00161   ArArgumentParser *myParser;
00162   bool myOwnParser;
00163 
00164 
00165   // a few device connections to use to connect to the robot
00166   ArTcpConnection myRobotTcpConn;
00167   ArSerialConnection myRobotSerConn;
00168   // a few device connections to use to connect to the laser
00169   ArTcpConnection myLaserTcpConn;
00170   ArSerialConnection myLaserSerConn;
00171   // device connections to use to connect to the second laser
00172   ArTcpConnection myLaserTcpConn2;
00173   ArSerialConnection myLaserSerConn2;
00174 };
00175 
00176 #endif // ARSIMPLECONNECTOR_H

Generated on Wed Oct 19 12:56:37 2005 for Aria by  doxygen 1.4.0