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 17da4a5dd1SPatrick Venture #include "ec/pid.hpp" 18da4a5dd1SPatrick Venture 19d8012181SPatrick Venture #include <cstring> 20d8012181SPatrick Venture #include <iostream> 21d8012181SPatrick Venture 227af157b1SPatrick Venture void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial) 23d8012181SPatrick Venture { 24d8012181SPatrick Venture std::memset(info, 0x00, sizeof(ec::pid_info_t)); 25d8012181SPatrick Venture 26f77d5a57SPatrick Venture info->ts = initial.ts; 27f77d5a57SPatrick Venture info->p_c = initial.p_c; 28f77d5a57SPatrick Venture info->i_c = initial.i_c; 29f77d5a57SPatrick Venture info->ff_off = initial.ff_off; 30f77d5a57SPatrick Venture info->ff_gain = initial.ff_gain; 31f77d5a57SPatrick Venture info->i_lim.min = initial.i_lim.min; 32f77d5a57SPatrick Venture info->i_lim.max = initial.i_lim.max; 33f77d5a57SPatrick Venture info->out_lim.min = initial.out_lim.min; 34f77d5a57SPatrick Venture info->out_lim.max = initial.out_lim.max; 35f77d5a57SPatrick Venture info->slew_neg = initial.slew_neg; 36f77d5a57SPatrick Venture info->slew_pos = initial.slew_pos; 37*572c43daSJames Feist info->negativeHysteresis = initial.negativeHysteresis; 38*572c43daSJames Feist info->positiveHysteresis = initial.positiveHysteresis; 39d8012181SPatrick Venture } 40d8012181SPatrick Venture 417af157b1SPatrick Venture void dumpPIDStruct(ec::pid_info_t* info) 42d8012181SPatrick Venture { 43da4a5dd1SPatrick Venture std::cerr << " ts: " << info->ts << " p_c: " << info->p_c 44da4a5dd1SPatrick Venture << " i_c: " << info->i_c << " ff_off: " << info->ff_off 45d8012181SPatrick Venture << " ff_gain: " << info->ff_gain 46d8012181SPatrick Venture << " i_lim.min: " << info->i_lim.min 47d8012181SPatrick Venture << " i_lim.max: " << info->i_lim.max 48d8012181SPatrick Venture << " out_lim.min: " << info->out_lim.min 49d8012181SPatrick Venture << " out_lim.max: " << info->out_lim.max 50d8012181SPatrick Venture << " slew_neg: " << info->slew_neg 51d8012181SPatrick Venture << " slew_pos: " << info->slew_pos 52d8012181SPatrick Venture << " last_output: " << info->last_output 53da4a5dd1SPatrick Venture << " integral: " << info->integral << std::endl; 54d8012181SPatrick Venture 55d8012181SPatrick Venture return; 56d8012181SPatrick Venture } 57