00001
00002 #ifndef INCLUDED_WalkCalibration_h_
00003 #define INCLUDED_WalkCalibration_h_
00004
00005 #include "ControlBase.h"
00006 #include "StringInputControl.h"
00007 #include "FileInputControl.h"
00008 #include "ToggleControl.h"
00009 #include "Events/EventRouter.h"
00010
00011
00012
00013
00014
00015
00016
00017 class WalkCalibration : public ControlBase, public EventListener {
00018 public:
00019
00020 WalkCalibration();
00021
00022
00023 ~WalkCalibration();
00024
00025 virtual ControlBase * activate(MotionManager::MC_ID disp_id, Socket * gui);
00026
00027 virtual void refresh();
00028
00029 virtual void deactivate() {
00030 erouter->removeListener(this);
00031 ControlBase::deactivate();
00032 }
00033
00034 virtual ControlBase* doSelect();
00035
00036
00037 virtual void processEvent(const EventBase& e);
00038
00039 virtual ControlBase * takeInput(const std::string& msg);
00040
00041 virtual void setHilights(const std::vector<unsigned int>& hi);
00042
00043 virtual void hilightFirst();
00044
00045 protected:
00046 enum {
00047 ROOT,
00048 CHOOSE,
00049 READY,
00050 MOVING,
00051 READING_1,
00052 READING_2,
00053 CLEAR,
00054 } st;
00055
00056
00057 enum dataSource {
00058 fs,
00059 fr,
00060 sr,
00061 br,
00062 bs,
00063 r,
00064 NUM_SRC
00065 } curType;
00066
00067 static void loadData(const std::string& name, std::vector<float*>& data);
00068 static void saveData(const std::string& name, const std::vector<float*>& data);
00069 static void clearData(std::vector<float*>& data);
00070
00071 void setupRoot();
00072 void setupChoose();
00073 void setupReady();
00074 void setupMoving();
00075 void setupReading1();
00076 void setupReading2();
00077 void setupClear();
00078
00079 unsigned int getType();
00080 unsigned int getFirstIndex(dataSource t);
00081 unsigned int getSecondIndex(dataSource t);
00082 char * getIndexName(unsigned int t);
00083 char * getFirstMeasure(dataSource t);
00084 char * getSecondMeasure(dataSource t);
00085
00086 float arclen(float d, float a, float sign);
00087 void addSample();
00088 void addSample(std::vector<float*>& dat, float x, float y, float a);
00089 static void report(unsigned int row, float cmd, float actual);
00090 static void err(const std::string& str);
00091
00092 float old_x;
00093 float old_y;
00094 float old_a;
00095 unsigned int startTime;
00096 unsigned int stopTime;
00097
00098 ControlBase * help;
00099 FileInputControl * load;
00100 StringInputControl * save;
00101 ControlBase * measure;
00102 ControlBase * clear;
00103 ToggleControl * polar;
00104 ToggleControl * rect;
00105 bool isPolar;
00106 std::string lastLoad;
00107
00108 float firstIn;
00109 float secondIn;
00110 std::vector<float*> data[NUM_SRC];
00111 unsigned int cnts[NUM_SRC];
00112 static char * datanames[NUM_SRC];
00113
00114 std::string status;
00115
00116 private:
00117 WalkCalibration(const WalkCalibration& );
00118 WalkCalibration& operator=(const WalkCalibration& );
00119 };
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 #endif