![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
NHK2017 octopus robot
Dependencies: 2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel
Fork of KANI2017v2 by
bot/PIDcontroller/PID_controller.cpp
- Committer:
- UCHITAKE
- Date:
- 2017-08-24
- Revision:
- 6:590c9622ecf1
- Child:
- 19:41f7dd1a5ed1
File content as of revision 6:590c9622ecf1:
#include "PID_controller.h" void PIDC::updateOutput() { confirm(); } PIDC::PIDC() : PID(KC, TI, TD, INTERVAL), HMC6352(HMCsda, HMCscl) { setInputLimits(-180, 180); setOutputLimits(-1.0, 1.0); setBias(0.0); setMode(AUTO_MODE); setSetPoint(0.0); setOpMode(HMC6352_CONTINUOUS, 1, 20); rawDegree = sample(); beforeDegree = sample(); offSetDegree = sample(); initDegree = 0; turnOverNumber = 0; // this -> attach(this, &PIDC::updateOutput, INTERVAL); } void PIDC::confirm() { rawDegree = sample(); if(rawDegree - beforeDegree < -1800) turnOverNumber++; if(rawDegree - beforeDegree > 1800) turnOverNumber--; initDegree = rawDegree - offSetDegree + turnOverNumber * 3600; beforeDegree = sample(); setProcessValue(initDegree / 10.0); co = compute(); } float PIDC::getCo() { return co; }