Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 17 | #include "ec/pid.hpp" |
| 18 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 19 | #include <cstring> |
| 20 | #include <iostream> |
| 21 | |
Patrick Venture | 7af157b | 2018-10-30 11:24:40 -0700 | [diff] [blame] | 22 | void initializePIDStruct(ec::pid_info_t* info, const ec::pidinfo& initial) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 23 | { |
| 24 | std::memset(info, 0x00, sizeof(ec::pid_info_t)); |
| 25 | |
Patrick Venture | f77d5a5 | 2018-10-23 09:32:52 -0700 | [diff] [blame] | 26 | info->ts = initial.ts; |
| 27 | info->p_c = initial.p_c; |
| 28 | info->i_c = initial.i_c; |
| 29 | info->ff_off = initial.ff_off; |
| 30 | info->ff_gain = initial.ff_gain; |
| 31 | info->i_lim.min = initial.i_lim.min; |
| 32 | info->i_lim.max = initial.i_lim.max; |
| 33 | info->out_lim.min = initial.out_lim.min; |
| 34 | info->out_lim.max = initial.out_lim.max; |
| 35 | info->slew_neg = initial.slew_neg; |
| 36 | info->slew_pos = initial.slew_pos; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 37 | } |
| 38 | |
Patrick Venture | 7af157b | 2018-10-30 11:24:40 -0700 | [diff] [blame] | 39 | void dumpPIDStruct(ec::pid_info_t* info) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 40 | { |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 41 | std::cerr << " ts: " << info->ts << " p_c: " << info->p_c |
| 42 | << " i_c: " << info->i_c << " ff_off: " << info->ff_off |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 43 | << " ff_gain: " << info->ff_gain |
| 44 | << " i_lim.min: " << info->i_lim.min |
| 45 | << " i_lim.max: " << info->i_lim.max |
| 46 | << " out_lim.min: " << info->out_lim.min |
| 47 | << " out_lim.max: " << info->out_lim.max |
| 48 | << " slew_neg: " << info->slew_neg |
| 49 | << " slew_pos: " << info->slew_pos |
| 50 | << " last_output: " << info->last_output |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 51 | << " integral: " << info->integral << std::endl; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 52 | |
| 53 | return; |
| 54 | } |