メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ | 関連ページ

HIStepWalk.h

00001 #ifndef HID_STEPWALK_H
00002 #define HID_STEPWALK_H
00003 #include <WinBasis/WBWin.h>
00004 
00005 #if _MSC_VER > 1000
00006 #pragma once
00007 #endif // _MSC_VER > 1000
00008 
00009 #include <Device/DVDeviceManager.h>
00010 #include <Device/DVAdBase.h>
00011 #include <Base/Affine.h>
00012 
00013 namespace Spr{;
00014 using namespace std;
00015 
00016 #define SENSOR4 //センサーが4つのとき
00017 
00018 class SPR_DLL HIStepWalk{
00019     //  データを最大値と最小値で正規化するクラス.
00020     class SPR_DLL Sensor{
00021     public:
00022         float offsetMin;//キャリブレイション用に新たに作った
00023         float offsetMax;// 2002/6/18
00024 //      float offset; //上記の前まで江島さんのプログラムで使っていたもの
00025         float scale;
00026         float rawCur;
00027         float cur;
00028     public:
00029         Vec2f pos;  //  センサの位置(メートル単位)
00030         DVAdBase* ad;
00031         Sensor(){
00032 //          offset = 2.5f;
00033             offsetMin = 0.5f;//初期値(適当)
00034             offsetMax = 1.0f;//初期値(適当)
00035             scale = 2.0f;//初期値(適当?)
00036             rawCur = 0;
00037             cur = 0;
00038             ad = NULL;
00039         }
00040         void CalibMin(){
00041             if (ad) rawCur = ad->Voltage();
00042             if (rawCur < offsetMin) offsetMin = rawCur;
00043         }
00044         void CalibMax(){
00045             if (ad) rawCur = ad->Voltage();
00046             if (rawCur > offsetMax) offsetMax = rawCur;
00047         }
00048         /// 正規化後の値を返す(0から1).
00049         float Get(){
00050             if (ad) rawCur = ad->Voltage();
00051             cur = (rawCur - offsetMin) / scale;
00052 //          if (cur > 1) cur = 1; //1より大きくなってもいいんじゃないか?
00053 //          if (cur < 0) cur = 0; //0より小さくなってもいいんじゃないか?
00054 //          std::cout << "cur = " << cur << std::endl;
00055             return cur;
00056         }
00057         /*江島さんが作ったもの2002/6/18上記に変更
00058         void Calib(){
00059             if (ad) rawCur = ad->Voltage();
00060             if (rawCur < offset) offset = rawCur;
00061         }
00062         /// 正規化後の値を返す(0から1).
00063         float Get(){
00064             if (ad) rawCur = ad->Voltage();
00065             cur = (rawCur - offset) / scale;
00066             if (cur > 1) cur = 1;
00067             if (cur < 0) cur = 0;
00068             return cur;
00069         }
00070         */
00071     };
00072 
00073 public:
00074     Vec2f cogAve, cog, direction;
00075     float inner, resultOfInner[3], memoryOfInner;
00076 
00077     HIStepWalk();
00078     virtual ~HIStepWalk();
00079     /// 初期化
00080     bool Init(DVDeviceManager& devMan);
00081     /// 本体.だいたい20msごとに呼び出す.  
00082     void Step(float);
00083     float GetVelocity(){ return walkVel; }
00084     float GetPitch(){ return pitch; }
00085     float GetPitchParam(){ return pitchParam; }
00086     void  SetPitchParam(float p){ pitchParam = p; }
00087     Vec2f GetDirection(){ return direction; }
00088     void SetDirection(Vec2f vector){ direction = vector; }
00089     int GetStep(){ return step; }
00090     void Print(std::ostream& os) const;
00091     float GetSensorVoltage(int n){ return sensor[n].Get(); }
00092     ///キャリブレイション用
00093     void PSenRange();
00094     void PSenMax();
00095     void PSenMin();
00096     void SetCenterOfGravity(Vec2f& centerG);
00097     Vec2f GetCenterOfGravity(){ return centerOfGravity[0]; };
00098     void PSenCal();
00099     bool pSenCal; 
00100     bool printForCenterG;
00101     bool rotateSwitch;
00102     void SetThreshold(float t) { threshold = t; }
00103     void CloseSIGGRAPHFile();
00104 
00105     void DataOutput(float x, float y, float z);
00106 
00107     std::ofstream *dataFileSIGGRAPH;
00108     char* folderName;
00109     char folderNameBack[20];
00110     int fileNameTime;
00111     char fileTime[10];
00112 
00113     float jumpPower;
00114     void SetJump(float& jump);
00115 
00116 
00117 protected:
00118 
00119     bool SideStep();                ///サイドステップの検出
00120     Vec2f walkingDirection;         ///圧力センサのみから検出された現在の足踏み方向
00121     Vec2f gravityDiff;              ///現在の重心の(平均から見た)位置 
00122     int sideStep;                   ///サイドステップ数
00123     bool frontCheck;                ///正面を向いているかのチェック
00124     float frontGap;                 ///チェックの際正面からどれくらいのズレを無視するか
00125 
00126     DWORD dwLastTime;               ///<    StepWalkが前回呼び出された時のカウント
00127     DWORD dwTime;                   ///<    StepWalkが今回呼び出された時のカウント
00128     int step;                       ///<    歩数
00129     int backStep;                   ///<    後ろに進む
00130     bool BackStep(float value);     ///<    後ろに進むかどうか判断する
00131     float walkVel;                  ///<    歩行速度    
00132     unsigned long dwInterval;       ///<    足踏み間隔
00133     unsigned long dwStepTime;       ///<    足踏みを検出した瞬間の時刻
00134     float pitch;                    ///<    dwIntervalの逆数
00135     float pitchParam;               ///<    pitchの移動距離調整用変数
00136     bool flag_SIGGRAPH;             ///<    SIGGRAPHデータ取りようフラグ 
00137     float threshold;                ///<    移動判定の閾値
00138     /// センサー数, 前,左,右で3つのセンサー
00139 #ifndef SENSOR4
00140     enum {NSENSOR = 3};
00141 #else
00142     enum {NSENSOR = 4};
00143 #endif
00144     /// 前,左,右のセンサー
00145     Sensor sensor[NSENSOR];
00146 
00147     /// 履歴の数
00148     enum {CENTER_OF_GRAVITY_LEN = 6};
00149     /// 重心の座標(履歴を含む)
00150     Vec2f centerOfGravity[CENTER_OF_GRAVITY_LEN];
00151     /// 重心の移動速度
00152     float dCenterOfGravity;
00153 };
00154 
00155 }
00156 
00157 #endif

Springheadに対してSun Apr 16 01:57:53 2006に生成されました。  doxygen 1.4.1