test
Dependencies: mbed ros_lib_kinetic nhk19mr2_can_info splitData SerialHalfDuplex_HM
Diff: Walk/Walk.h
- Revision:
- 32:dc684a0b8448
- Parent:
- 29:7d8b8011a88d
- Child:
- 34:89d701e15cdf
diff -r 86eb746eaed4 -r dc684a0b8448 Walk/Walk.h --- a/Walk/Walk.h Thu Feb 28 03:52:09 2019 +0000 +++ b/Walk/Walk.h Thu Feb 28 08:48:21 2019 +0000 @@ -1,17 +1,21 @@ #ifndef INCLUDED_WALK_H #define INCLUDED_WALK_H #include "OneLeg.h" -enum OrbitPattern +enum TriangleParams { - TRIANGLE, + OFFSET_X_M, + OFFSET_Y_M, + STRIDE_M, + HEIGHT_M, + BUFFER_HEIGHT_M, }; //下記の論文を参照 //https://static1.squarespace.com/static/542ddec8e4b0158794bd1036/t/5a861d1cc83025f3d460dfc3/1518738728029/gait-design-optimization-Final.pdf class TriangleOrbit { float reverse_tanbeta_; //論文のβのtan - float start_x_m_; - float start_y_m_; + float offset_x_m_; + float offset_y_m_; float stride_m_; float height_m_; //足上げ幅 float buffer_height_m_; //着地直前で止める高さ @@ -24,14 +28,38 @@ int StrideLineAccel_(OneLeg &leg, float phasetime_s); //着地中に慣性力を考慮して加減速 public: - void SetTriangleParam(float start_x_m, float start_y_m, float stride_m, float height_m, float buffer_height_m, + void SetTriangleParam(float offset_x_m, float offset_y_m, float stride_m, float height_m, float buffer_height_m, float stridetime_s, float toptime_s, float buffer_time_s); int GetOrbit(OneLeg &leg, float phasetime_s); float GetOneWalkTime(); //足一周の時間 + void ChangeOneParam(TriangleParams param, float val); }; +struct LineParam +{ + float time_s; //次の点に到達するまでにかける時間 + float x_m; + float y_m; +}; +class FreeLineOrbit +{ + LineParam lineparams_[10]; //pointの数はmax10としている。多めにとっているだけ。 + int point_num_; //pointの数 +public: + void SetFreeLinesParam(LineParam lineparams[], int point_num); //任意の直線の軌道を設定 + int GetOrbit(OneLeg &leg, float phasetime_s); + float GetOneWalkTime(); //足一周の時間 + //Standupのparam設定 + void SetStandParam(float x_m, float y_m, float time_s); +}; +enum OrbitPattern +{ + TRIANGLE, + FREELINES, +}; //足の軌道を設定するクラスの皮。全ての軌道クラスを継承して一つにまとめる。patternで使い分ける -class Orbit : public TriangleOrbit +//関数は継承元のものも使えるので、継承元のクラスも見てください +class Orbit : public TriangleOrbit, public FreeLineOrbit { OrbitPattern pattern_; @@ -43,11 +71,11 @@ }; class Walk { - Orbit orbit_[4]; float offset_multi_[4]; public: Walk(); + Orbit orbit_[4]; static float calctime_s_; //計算周期 float phasetime_s_[4]; //参照渡しされたonelegそれぞれにorbit_::GetOrbit関数を代入 @@ -68,9 +96,15 @@ void SetOneLegStandParam(int legnum, float x_m, float y_m, float time_s); void SetAllLegStandParam(float x_m, float y_m, float time_s); // 4足一括で設定できる //triangle - void SetOneLegTriangleParam(int legnum, float start_x_m, float start_y_m, float stride_m, float height_m, float buffer_height_m, + void SetOneLegTriangleParam(int legnum, float offset_x_m, float offset_y_m, float stride_m, float height_m, float buffer_height_m, + float stridetime_s, float toptime_s, float buffer_time_s); + void SetAllLegTriangleParam(float offset_x_m, float offset_y_m, float stride_m, float height_m, float buffer_height_m, float stridetime_s, float toptime_s, float buffer_time_s); - void SetAllLegTriangleParam(float start_x_m, float start_y_m, float stride_m, float height_m, float buffer_height_m, - float stridetime_s, float toptime_s, float buffer_time_s); + void ChangeOneParam(int legnum, TriangleParams param, float val); + + //freeline + void SetOneLegFreeLinesParam(int legnum, LineParam lineparams[], int point_num); + void SetAllLegFreeLinesParam(LineParam lineparams[], int point_num); }; + #endif \ No newline at end of file