RemoteMotionModule.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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;
00077 }
00079 Decimal _providedMaxTurnRate(void){
00080 return 100000.0;
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
00112
00113
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 };
00165
00166
00167
00168 #endif
00169