1d8012181SPatrick Venture /** 2d8012181SPatrick Venture * Copyright 2017 Google Inc. 3d8012181SPatrick Venture * 4d8012181SPatrick Venture * Licensed under the Apache License, Version 2.0 (the "License"); 5d8012181SPatrick Venture * you may not use this file except in compliance with the License. 6d8012181SPatrick Venture * You may obtain a copy of the License at 7d8012181SPatrick Venture * 8d8012181SPatrick Venture * http://www.apache.org/licenses/LICENSE-2.0 9d8012181SPatrick Venture * 10d8012181SPatrick Venture * Unless required by applicable law or agreed to in writing, software 11d8012181SPatrick Venture * distributed under the License is distributed on an "AS IS" BASIS, 12d8012181SPatrick Venture * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d8012181SPatrick Venture * See the License for the specific language governing permissions and 14d8012181SPatrick Venture * limitations under the License. 15d8012181SPatrick Venture */ 16d8012181SPatrick Venture 170c8223b5SJames Feist #include "util.hpp" 180c8223b5SJames Feist 19da4a5dd1SPatrick Venture #include "ec/pid.hpp" 20da4a5dd1SPatrick Venture 21d8012181SPatrick Venture #include <cstring> 22d8012181SPatrick Venture #include <iostream> 23d8012181SPatrick Venture 24a076487aSPatrick Venture namespace pid_control 25a076487aSPatrick Venture { 26a076487aSPatrick Venture initializePIDStruct(ec::pid_info_t * info,const ec::pidinfo & initial)277af157b1SPatrick Venturevoid initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial) 28d8012181SPatrick Venture { 29*9788963cSDelphine CC Chiu info->checkHysterWithSetpt = initial.checkHysterWithSetpt; 30f77d5a57SPatrick Venture info->ts = initial.ts; 317442c37aSPatrick Venture info->proportionalCoeff = initial.proportionalCoeff; 327442c37aSPatrick Venture info->integralCoeff = initial.integralCoeff; 330e8fc398SBonnie Lo info->derivativeCoeff = initial.derivativeCoeff; 347442c37aSPatrick Venture info->feedFwdOffset = initial.feedFwdOffset; 357442c37aSPatrick Venture info->feedFwdGain = initial.feedFwdGain; 367442c37aSPatrick Venture info->integralLimit.min = initial.integralLimit.min; 377442c37aSPatrick Venture info->integralLimit.max = initial.integralLimit.max; 387442c37aSPatrick Venture info->outLim.min = initial.outLim.min; 397442c37aSPatrick Venture info->outLim.max = initial.outLim.max; 407442c37aSPatrick Venture info->slewNeg = initial.slewNeg; 417442c37aSPatrick Venture info->slewPos = initial.slewPos; 42572c43daSJames Feist info->negativeHysteresis = initial.negativeHysteresis; 43572c43daSJames Feist info->positiveHysteresis = initial.positiveHysteresis; 44d8012181SPatrick Venture } 45d8012181SPatrick Venture dumpPIDStruct(ec::pid_info_t * info)467af157b1SPatrick Venturevoid dumpPIDStruct(ec::pid_info_t* info) 47d8012181SPatrick Venture { 487442c37aSPatrick Venture std::cerr << " ts: " << info->ts 497442c37aSPatrick Venture << " proportionalCoeff: " << info->proportionalCoeff 507442c37aSPatrick Venture << " integralCoeff: " << info->integralCoeff 510e8fc398SBonnie Lo << " derivativeCoeff: " << info->derivativeCoeff 527442c37aSPatrick Venture << " feedFwdOffset: " << info->feedFwdOffset 537442c37aSPatrick Venture << " feedFwdGain: " << info->feedFwdGain 547442c37aSPatrick Venture << " integralLimit.min: " << info->integralLimit.min 557442c37aSPatrick Venture << " integralLimit.max: " << info->integralLimit.max 567442c37aSPatrick Venture << " outLim.min: " << info->outLim.min 577442c37aSPatrick Venture << " outLim.max: " << info->outLim.max 587442c37aSPatrick Venture << " slewNeg: " << info->slewNeg << " slewPos: " << info->slewPos 594b0df320SPatrick Venture << " last_output: " << info->lastOutput 600e8fc398SBonnie Lo << " last_error: " << info->lastError 61da4a5dd1SPatrick Venture << " integral: " << info->integral << std::endl; 62d8012181SPatrick Venture 63d8012181SPatrick Venture return; 64d8012181SPatrick Venture } 65a076487aSPatrick Venture 66a076487aSPatrick Venture } // namespace pid_control 67