00001 #ifndef __COMPLEX_MOVEMENT_H__
00002 #define __COMPLEX_MOVEMENT_H__
00003
00004 #include "BeoSub/BeeBrain/Globals.H"
00005 #include "BeoSub/BeeBrain/PreMotorComplex.H"
00006 #include "BeoSub/BeeBrain/ActionInput.H"
00007
00008 class PreMotorComplex;
00009
00010
00011 typedef void (PreMotorComplex::*FnPtr)(const SensorInput);
00012 typedef void (PreMotorComplex::*Vis_FnPtr) (const VisionInput&);
00013
00014 class ComplexMovement {
00015 public:
00016
00017 ComplexMovement();
00018 ~ComplexMovement();
00019
00020 friend class PreMotorComplex;
00021
00022
00023 void addMove(FnPtr funcPointer, NumMoves num, const double d);
00024 void addMove(FnPtr funcPointer, NumMoves num, const Angle a);
00025
00026
00027 void addMove(Vis_FnPtr funcPointer, NumMoves num, const rutz::shared_ptr<Point3D> p);
00028 void addMove(Vis_FnPtr funcPointer, NumMoves num, const rutz::shared_ptr<Angle> a);
00029
00030 private:
00031
00032
00033
00034 std::vector<FnPtr> W_onceFuncs;
00035 std::vector<SensorInput> W_onceParams;
00036
00037 std::vector<FnPtr> W_reFuncs;
00038 std::vector<SensorInput> W_reParams;
00039
00040
00041 std::vector<Vis_FnPtr> Vis_onceFuncs;
00042 std::vector<VisionInput> Vis_onceParams;
00043
00044 std::vector<Vis_FnPtr> Vis_reFuncs;
00045 std::vector<VisionInput> Vis_reParams;
00046
00047
00048
00049 void addRepeatMove(FnPtr funcPointer, const double d, const Angle a);
00050 void addOnceMove(FnPtr funcPointer, const double d, const Angle a);
00051
00052
00053 void addRepeatMove(Vis_FnPtr funcPointer, const rutz::shared_ptr<Point3D> p, const rutz::shared_ptr<Angle> a);
00054 void addOnceMove(Vis_FnPtr funcPointer, const rutz::shared_ptr<Point3D> p, const rutz::shared_ptr<Angle> a);
00055
00056
00057
00058 };
00059
00060
00061
00062
00063 ComplexMovement::ComplexMovement() {}
00064 ComplexMovement::~ComplexMovement() {}
00065
00066
00067
00068 void ComplexMovement::addMove(FnPtr funcPointer, NumMoves num, const double d) {
00069
00070 if(num == ONCE)
00071 addOnceMove(funcPointer, d, Angle(-1));
00072 else if(num == REPEAT)
00073 addRepeatMove(funcPointer, d, Angle(-1));
00074 else
00075 LINFO("DID NOT ADD MOVE");
00076
00077 }
00078
00079 void ComplexMovement::addMove(FnPtr funcPointer, NumMoves num, const Angle a) {
00080
00081 if(num == ONCE)
00082 addOnceMove(funcPointer, -1.0, a);
00083 else if(num == REPEAT)
00084 addRepeatMove(funcPointer, -1.0, a);
00085 else
00086 LINFO("DID NOT ADD MOVE");
00087
00088 }
00089
00090
00091 void ComplexMovement::addMove(Vis_FnPtr funcPointer, NumMoves num, const rutz::shared_ptr<Point3D> p) {
00092
00093 rutz::shared_ptr<Angle> a;
00094
00095 if(num == ONCE)
00096 addOnceMove(funcPointer, p, a);
00097 else if(num == REPEAT)
00098 addRepeatMove(funcPointer, p, a);
00099 else
00100 LINFO("DID NOT ADD MOVE");
00101 }
00102
00103 void ComplexMovement::addMove(Vis_FnPtr funcPointer, NumMoves num, const rutz::shared_ptr<Angle> a) {
00104
00105 rutz::shared_ptr<Point3D> p;
00106 if(num == ONCE)
00107 addOnceMove(funcPointer, p, a);
00108 else if(num == REPEAT)
00109 addRepeatMove(funcPointer, p, a);
00110 else
00111 LINFO("DID NOT ADD MOVE");
00112
00113 }
00114
00115
00116
00117
00118
00119
00120 void ComplexMovement::addRepeatMove(FnPtr funcPointer, const double d, const Angle a) {
00121
00122 W_reFuncs.push_back(NULL);
00123 W_reFuncs[W_reFuncs.size() - 1] = funcPointer;
00124 SensorInput params(d, a);
00125 W_reParams.push_back(params);
00126
00127 }
00128
00129 void ComplexMovement::addOnceMove(FnPtr funcPointer, const double d, const Angle a) {
00130
00131 W_onceFuncs.push_back(NULL);
00132 W_onceFuncs[W_onceFuncs.size() - 1] = funcPointer;
00133 SensorInput params(d, a);
00134 W_onceParams.push_back(params);
00135
00136 }
00137
00138
00139
00140 void ComplexMovement::addOnceMove(Vis_FnPtr funcPointer, const rutz::shared_ptr<Point3D> p, const rutz::shared_ptr<Angle> a) {
00141 Vis_onceFuncs.push_back(NULL);
00142 Vis_onceFuncs[Vis_onceFuncs.size() - 1] = funcPointer;
00143 VisionInput params(p, a);
00144 Vis_onceParams.push_back(params);
00145
00146 }
00147
00148 void ComplexMovement::addRepeatMove(Vis_FnPtr funcPointer, const rutz::shared_ptr<Point3D> p, const rutz::shared_ptr<Angle> a) {
00149 Vis_reFuncs.push_back(NULL);
00150 Vis_reFuncs[Vis_reFuncs.size() - 1] = funcPointer;
00151 VisionInput params(p, a);
00152 Vis_reParams.push_back(params);
00153 }
00154
00155
00156
00157
00158 #endif