FDCL Controllers
integral_utils.hpp
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 2020 Flight Dynamics and Control Lab
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24  * SOFTWARE.
25  */
26 
27 #ifndef FDCL_INTEGRAL_UTILS_HPP
28 #define FDCL_INTEGRAL_UTILS_HPP
29 
30 // user headers
31 #include "common_types.hpp"
32 #include "fdcl/matrix_utils.hpp"
33 
34 
35 // external headers
36 #include "Eigen/Dense"
37 
38 
39 namespace fdcl
40 {
41 
45 {
46  Vector3 error;
47  Vector3 integrand;
48 
50  {
51  set_zero();
52  }
53 
54 
62  void integrate(const Vector3 current_integrand, const double dt)
63  {
64  error += (integrand + current_integrand) * dt / 2;
65  integrand = current_integrand;
66  }
67 
68 
72  void set_zero(void)
73  {
74  error.setZero();
75  integrand.setZero();
76  }
77 }; // end of integral_error3 struct
78 
79 
83 {
84  double error;
85  double integrand;
86 
87  integral_error(void)
88  {
89  set_zero();
90  }
91 
92 
100  void integrate(const double current_integrand, const double dt)
101  {
102  error += (integrand + current_integrand) * dt / 2;
103  integrand = current_integrand;
104  }
105 
106 
110  void set_zero(void)
111  {
112  error = 0.0;
113  integrand = 0.0;
114  }
115 }; // end of integral_error struct
116 
117 } // end of namespace fdcl
118 
119 #endif
Integral for error for Vector3.
Definition: integral_utils.hpp:44
void set_zero(void)
Definition: integral_utils.hpp:110
Miscellaneous math functions.
void integrate(const Vector3 current_integrand, const double dt)
Definition: integral_utils.hpp:62
Data types used throughout the code.
void set_zero(void)
Definition: integral_utils.hpp:72
Definition: common_types.hpp:44
void integrate(const double current_integrand, const double dt)
Definition: integral_utils.hpp:100
Integral for error for a double.
Definition: integral_utils.hpp:82