NHK2017 octopus robot
Dependencies: 2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel
Fork of KANI2017v2 by
Diff: bot/PIDcontroller/PID_controller.h
- Revision:
- 26:7258d5ad0bff
- Parent:
- 24:9a4ca5442717
diff -r d199d621ecca -r 7258d5ad0bff bot/PIDcontroller/PID_controller.h --- a/bot/PIDcontroller/PID_controller.h Sat Sep 30 17:59:10 2017 +0900 +++ b/bot/PIDcontroller/PID_controller.h Wed Oct 25 03:25:06 2017 +0900 @@ -1,6 +1,22 @@ /** * @file PID_controller.h * @brief コンパスセンサを使ったPIDコントローラ +* +* Example : +* @code +* #include "mbed.h" +* #include "PID_controller.h" +* +* PIDC pidc; +* +* int main() +* { +* while(1) { +* pidc.confirm(); +* pc.printf("Hi, %f\r\n", pid.getCo()); +* } +* } +* @endcode */ #ifndef PID_CONTROLLER_H #define PID_CONTROLLER_H @@ -9,22 +25,19 @@ #include "pin_config.h" #include "PID.h" -#include "jy901.h" - -// const double M_PI = 3.141592653589793; -const double KC = 5.2; +#include "HMC6352.h" +const double KC = 9.0; const double TI = 0.0; -const double TD = 0.00; +const double TD = 0.00008; const float INTERVAL = 0.01; -const float INPUT_LIMIT = 180.0; +const float INPUT_LIMIT = 360.0; const float OUTPUT_LIMIT = 0.4; const float BIAS = 0.0; -const int SENSED_THRESHOLD = 180; - +const int SENSED_THRESHOLD = 1800; /** * @brief コンパスセンサを使ったPIDコントローラ */ -class PIDC : public PID, JY901, Ticker +class PIDC : public PID, HMC6352, Ticker { public : /** @@ -51,12 +64,7 @@ /** * @brief 回転用座標系リセット */ - void resetAxisOffset(); - - /** - * 平行移動用座標系リセット - */ - void resetPlaneOffset(); + void resetOffset(); /** * @brief PIDの計算結果を取得 @@ -68,31 +76,33 @@ * 現在の角度を取得 * @return 現在の角度(degree) */ - float getCurrentDegree() const; + int getCurrentDegree() const; + + /** + * センサの生値を取得 + * @return コンパスセンサの生値 + */ + int getRawDegree(); + + void setPoint(float point); /** * @brief キャリブレーションする * @param mode ENTER OR EXIT */ - - void renewAngle(); - void calibration(int mode); private : void updateOutput(); - float axisOffSetDegree; - float planeOffSetDegree; + int offSetDegree; int turnOverNumber; - float beforeDegree; + int beforeDegree; protected : - float rawDegree; + int rawDegree; float calculationResult; - float axisCurrentDegree; - float planeCurrentDegree; - float angle; + int currentDegree; }; #endif//PID_CONTROLLER_H