matlab_helpers.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2012-2016, Institute of Flight Systems and Automatic Control,
3 // Technische Universität Darmstadt.
4 // All rights reserved.
5 
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of hector_quadrotor nor the names of its contributors
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 #ifndef HECTOR_QUADROTOR_MODEL_MATLAB_HELPERS_H
30 #define HECTOR_QUADROTOR_MODEL_MATLAB_HELPERS_H
31 
32 #include <limits>
33 #include <cmath>
34 
35 typedef double real_T;
36 typedef uint32_t int32_T;
37 typedef bool boolean_T;
38 
39 static const real_T rtInf = std::numeric_limits<real_T>::infinity();
40 static inline boolean_T rtIsInf(real_T value)
41 {
42  return std::isinf(value);
43 }
44 
45 static const real_T rtNaN = std::numeric_limits<real_T>::quiet_NaN();
46 static inline boolean_T rtIsNaN(real_T value)
47 {
48  return std::isnan(value);
49 }
50 
52 {
53  real_T y;
54  real_T d0;
55  real_T d1;
56  if (rtIsNaN(u0) || rtIsNaN(u1)) {
57  y = rtNaN;
58  } else {
59  d0 = fabs(u0);
60  d1 = fabs(u1);
61  if (rtIsInf(u1)) {
62  if (d0 == 1.0) {
63  y = rtNaN;
64  } else if (d0 > 1.0) {
65  if (u1 > 0.0) {
66  y = rtInf;
67  } else {
68  y = 0.0;
69  }
70  } else if (u1 > 0.0) {
71  y = 0.0;
72  } else {
73  y = rtInf;
74  }
75  } else if (d1 == 0.0) {
76  y = 1.0;
77  } else if (d1 == 1.0) {
78  if (u1 > 0.0) {
79  y = u0;
80  } else {
81  y = 1.0 / u0;
82  }
83  } else if (u1 == 2.0) {
84  y = u0 * u0;
85  } else if ((u1 == 0.5) && (u0 >= 0.0)) {
86  y = sqrt(u0);
87  } else if ((u0 < 0.0) && (u1 > floor(u1))) {
88  y = rtNaN;
89  } else {
90  y = pow(u0, u1);
91  }
92  }
93 
94  return y;
95 }
96 
97 #endif // HECTOR_QUADROTOR_MODEL_MATLAB_HELPERS_H
static const real_T rtInf
int isnan(const T &value)
Definition: helpers.h:38
static const real_T rtNaN
static boolean_T rtIsNaN(real_T value)
uint32_t int32_T
double real_T
static real_T rt_powd_snf(real_T u0, real_T u1)
static boolean_T rtIsInf(real_T value)
bool boolean_T
int isinf(const T &value)
Definition: helpers.h:54


hector_quadrotor_model
Author(s): Johannes Meyer , Alexander Sendobry
autogenerated on Mon Jun 10 2019 13:36:56