RemoteMotionModule.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 
00034 
00035 
00036 
00037 #ifndef __REMOTE_MOTION_MODULE_H__
00038 #define __REMOTE_MOTION_MODULE_H__
00039 
00040 #ifdef MIP_HOST_APPLE
00041 #include <applePatch.h>
00042 #endif
00043 
00044 #include <baselib.h>
00045 #include <MotionModule.h>
00046 #include <socketUDP.h>
00047 #include <SsUtils.h>
00048 
00049 
00050 using namespace std;
00051 
00052 
00053 
00054 namespace MipResources{
00056  /* @{ */
00057 
00058 
00059 
00065 class RemoteMotionModulePar : public MotionModulePar{
00066  private:
00067   SenderUDP*   _sender;
00068   ListenerUDP* _listener;
00069   
00070   
00071   bool parseMotionModuleParMessage(stringstream &ss, string &msg);
00072   
00073  protected:
00075   Decimal _providedMaxDrive(void){
00076    return 100000.0; //FIXME
00077   }
00079   Decimal _providedMaxTurnRate(void){
00080    return 100000.0; //FIXME
00081   }
00083   string  _providedName(){
00084    return string("PlayerPosition2d");
00085   }
00086  
00087  public:
00088   
00089   RemoteMotionModulePar(SenderUDP* sender, ListenerUDP* listener);
00090   
00091   SenderUDP* sender(){
00092    return _sender;
00093   }
00094 };
00095 
00096 
00100 class RemoteMotionModuleVar : public MotionModuleTState{};
00101 
00102 
00106 class RemoteMotionModule : public MotionModule{
00107  private:
00108   static const ResourcePlate _plate = MM_REM_RES;
00109  
00110  protected:
00111   /* PROMEMO from abstract class */
00112   /* MotionModulePar *_par; */
00113   /* Scan         _scan; */
00114   RemoteMotionModulePar *_remPar;
00115   RemoteMotionModuleVar *_remVar;
00116   
00118   MotionModuleTState _providedLocStep(){
00119    return MotionModuleTState(_remVar->pose,_remVar->linVel,_remVar->angVel,_remVar->timeStamp);
00120   };
00121   
00124   void _providedLocSet(MotionModuleState state){
00125    stringstream s;
00126    s << "pos ";
00127    SsUtils::encrypt(state.pose, s);
00128    string msg(s.str());
00129    _remPar->sender()->send(msg);
00130    bool wait = true;
00131   };
00132   
00133   virtual void _providedSetCommands(Decimal drive, Decimal turnrate){
00134    stringstream ss;
00135    ss << "ves ";
00136    SsUtils::encrypt(vel, ss);
00137    string msg(ss.str());
00138    sender->send(msg);
00139  
00140    stringstream ssd;
00141    ssd << "real msg -> " << msg;
00142    debug(5,ssd.str());
00143    ssd.str("");
00144    ssd << "returned vel -> " << vel.print();
00145    debug(5,ssd.str());
00146   }
00147  
00148  public:
00150   virtual ResourcePlate getPlate() const {
00151    return _plate;
00152   }
00153   
00155   RemoteMotionModule(SenderUDP* sender, ListenerUDP* listener, int argc, const char* argv[]);
00156 
00158   ~RemoteMotionModule(){
00159   }
00160 };
00161 
00162  /* @} */
00163  
00164 };// end namespace MipResources{
00165 
00166 
00167 
00168 #endif
00169 

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