libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
pid_ctl_parsing.h
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license in the file COPYING
10 * or http://www.opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file COPYING.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2018 Saso Kiselkov. All rights reserved.
24 */
25
26#ifndef _ACFUTILS_PID_CTL_PARSING_H_
27#define _ACFUTILS_PID_CTL_PARSING_H_
28
29#include "assert.h"
30#include "conf.h"
31#include "pid_ctl.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37static inline void
38pid_ctl_parse2(pid_ctl_t *pid, const conf_t *conf, const char *prefix,
39 bool noreset)
40{
41 double k_p = 0, k_i = 0, lim_i = 0, k_d = 0, r_d = 0;
42 bool_t integ_clamp;
43
44 ASSERT(pid != NULL);
45 ASSERT(conf != NULL);
46 ASSERT(prefix != NULL);
47
48 conf_get_d_v(conf, "%s/k_p", &k_p, prefix);
49 conf_get_d_v(conf, "%s/k_i", &k_i, prefix);
50 conf_get_d_v(conf, "%s/lim_i", &lim_i, prefix);
51 conf_get_d_v(conf, "%s/k_d", &k_d, prefix);
52 conf_get_d_v(conf, "%s/r_d", &r_d, prefix);
53 conf_get_b_v(conf, "%s/integ_clamp", &integ_clamp, prefix);
54
55 if (noreset)
56 pid_ctl_init_noreset(pid, k_p, k_i, lim_i, k_d, r_d);
57 else
58 pid_ctl_init(pid, k_p, k_i, lim_i, k_d, r_d);
59 pid_ctl_set_integ_clamp(pid, integ_clamp);
60}
61
62static inline void
63pid_ctl_parse(pid_ctl_t *pid, const conf_t *conf, const char *prefix)
64{
65 pid_ctl_parse2(pid, conf, prefix, false);
66}
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* _ACFUTILS_PID_CTL_PARSING_H_ */
#define ASSERT(x)
Definition assert.h:208
bool_t conf_get_d_v(const conf_t *conf, const char *fmt, double *value,...)
Definition conf.c:1229
bool_t conf_get_b_v(const conf_t *conf, const char *fmt, bool_t *value,...)
Definition conf.c:1268
Definition conf.c:41