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:
- 22:682cc376da6f
- Parent:
- 20:477c5d039e93
- Child:
- 23:37bb9afe9fdc
--- a/bot/PIDcontroller/PID_controller.h Tue Sep 05 14:07:18 2017 +0900 +++ b/bot/PIDcontroller/PID_controller.h Thu Sep 07 06:26:53 2017 +0000 @@ -11,14 +11,15 @@ #include "PID.h" #include "jy901.h" -#define M_PI 3.141592653589793 -#define KC 1.0 -#define TI 0.0 -#define TD 0.0 -#define INTERVAL 0.05 -#define INPUT_LIMIT 180 -#define OUTPUT_LIMIT 1.0 -#define BIAS 0.0 +// const double M_PI = 3.141592653589793; +const double KC = 5.2; +const double TI = 0.0; +const double TD = 0.00; +const float INTERVAL = 0.01; +const float INPUT_LIMIT = 180.0; +const float OUTPUT_LIMIT = 0.4; +const float BIAS = 0.0; +const int SENSED_THRESHOLD = 180; /** * @brief コンパスセンサを使ったPIDコントローラ @@ -42,21 +43,52 @@ */ PIDC(PinName sda, PinName scl, float kc, float ti, float td, float interval); + /** + * @brief センサの値とPIDの値をアップデート + */ void confirm(); - float getCo(); + + /** + * @brief 回転用座標系リセット + */ + void resetAxisOffset(); + + /** + * 平行移動用座標系リセット + */ + void resetPlaneOffset(); + + /** + * @brief PIDの計算結果を取得 + * @return PIDの計算結果 + */ + float getCalculationResult() const; + + /** + * 現在の角度を取得 + * @return 現在の角度(degree) + */ + float getCurrentDegree() const; + + /** + * @brief キャリブレーションする + * @param mode ENTER OR EXIT + */ + void calibration(int mode); private : void updateOutput(); - int rawDegree; - int offSetDegree; + float axisOffSetDegree; + float planeOffSetDegree; int turnOverNumber; - int beforeDegree; + float beforeDegree; protected : - float co; - float processValue; - int initDegree; + float rawDegree; + float calculationResult; + float axisCurrentDegree; + float planeCurrentDegree; }; #endif//PID_CONTROLLER_H