RemKhepServer.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 
00029 
00030 #ifndef __REM_KHEP_SERVER_H_
00031 #define __REM_KHEP_SERVER_H_
00032 
00033 #include <IPCommModule.h>
00034 #include <CommonOptions.h>
00035 
00036 #include <remKhepComm.h>
00037 
00038 #ifdef MIP_PLATFORM_ARM
00039  #include <Korebot.h>
00040 #else
00041  #include <MotionModule.h>
00042 #endif
00043 
00044 #include <URG04LXmm.h>
00045 
00046 // this is 22500 but means 25000 :)
00047 // #define SAMPLE_TIME_USEC 49500
00048 #define SAMPLE_TIME_USEC 30000
00049 #define WAIT_TIME_USEC 1000
00050 
00051 #define KHS_COMM_DEBUG 0
00052 #define KHS_TIME_DEBUG 0
00053 #define KHS_EXECUTE_DEBUG 0
00054 
00055 using namespace std;
00056 using namespace MipResources;
00057 
00058 enum CommRateTypes {
00059  FIXED,
00060  VARIABLE,
00061  NUM_COMM_RATE_TYPES
00062 };
00063 
00067 class KheperaServerOptions : public Options{
00068  public:
00069   IntOption*   urg04lxActive;
00070   IntOption*   korebotActive;
00071   StringOption* commRateType;
00072   
00073   string getObjectName() const{
00074    return "KheperaServerOptions";
00075   }
00076   
00077   KheperaServerOptions();
00078 };
00079 
00080 
00084 class KheperaServer : MIPObject{
00085  
00086  private:
00087   char _stateBuffer[70];
00088   int _stateBufferCounter;
00089   int _numSentState;
00090   
00091   stringstream _ssWarning;
00092   stringstream _ssDebug;
00093   
00094   URG04LXmm* _urg04lx;
00095 #ifdef MIP_PLATFORM_ARM
00096   Korebot*  _korebot;
00097 #endif
00098   
00099   KheperaServerOptions _options;
00100   
00101 //   bool _newVelocity;
00102   bool _newTState;
00103   Decimal _driveToBeSet;
00104   Decimal _turnrateToBeSet;
00105   MotionModuleTState _motionModuleTStateToBeSet;
00106   MotionModuleTState _lastMotionModuleTState;
00107   
00108   int   _sendPort;
00109   string _senderAddr;
00110   int   _listPort;
00111   
00112   ListenerUDP* _listener;
00113   SenderUDP*  _sender;
00114   
00115   vector<string> _incomingPackets;
00116   vector<string> _incomingPacketsSenders;
00117   vector<string> _outcomingPackets;
00118   
00119   Timer _execCmdsTimer;
00120   
00121   CommRateTypes _commRateType;
00122   
00123   string getObjectName() const {
00124    return "KheperaServer";
00125   }
00126   
00127  public:
00128   
00130   KheperaServer(int argc, const char* argv[]);
00131   
00133   bool searchConnection();
00134   
00136   void receiveCommands();
00137   
00139   void parseCommands();
00140   
00142   void executeCommands();
00143 };
00144 
00145 
00146 #endif

Generated on Mon Feb 20 07:01:07 2017 for MIP by  doxygen 1.5.6