NASA Astrobee Robot Software  Astrobee Version:
Flight software for the Astrobee robots operating inside the International Space Station.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
butterO7.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef IMU_INTEGRATION_BUTTERO7_H_
20 #define IMU_INTEGRATION_BUTTERO7_H_
21 
22 #include <imu_integration/filter.h>
23 
25 
26 #include <array>
27 
28 namespace imu_integration {
29 template <class Params>
30 class ButterO7 : public Filter {
31  public:
32  ButterO7() : initialized_(false) {}
33  // Returns filtered value and timestamp
34  double AddValue(const double value) final {
35  if (!initialized_) Initialize(value, Params::kGain);
36 
37  const int last_index = xv_.size() - 1;
38  // Shift input and output vals
39  for (int i = 0; i < last_index; ++i) {
40  xv_[i] = xv_[i + 1];
41  yv_[i] = yv_[i + 1];
42  }
43  // Add new values
44  xv_[last_index] = value / Params::kGain;
45  // Generate new output
46  yv_[last_index] = (xv_[0] + xv_[9]) + Params::kX18 * (xv_[1] + xv_[8]) + Params::kX27 * (xv_[2] + xv_[7]) +
47  Params::kX36 * (xv_[3] + xv_[6]) + Params::kX45 * (xv_[4] + xv_[5]) + (Params::kY2 * yv_[2]) +
48  (Params::kY3 * yv_[3]) + (Params::kY4 * yv_[4]) + (Params::kY5 * yv_[5]) +
49  (Params::kY6 * yv_[6]) + (Params::kY7 * yv_[7]) + (Params::kY8 * yv_[8]);
50 
51  // Return most recent output
52  return yv_[last_index];
53  }
54 
55  private:
56  void Initialize(const double first_value, const double gain) {
57  for (auto& val : xv_) {
58  val = first_value / gain;
59  }
60  for (auto& val : yv_) {
61  val = first_value;
62  }
63 
64  initialized_ = true;
65  }
66 
67  // Notation taken from mkfilter site
68  // /www/usr/fisher/helpers/mkfilter
69  std::array<double, 10> xv_;
70  std::array<double, 10> yv_;
71  bool initialized_;
72 };
73 
75  static constexpr double kGain = 3.168744781e+06;
76  static constexpr double kX18 = 7.9994195281;
77  static constexpr double kX27 = 28.9959366960;
78  static constexpr double kX36 = 62.9878100890;
79  static constexpr double kX45 = 90.9796834820;
80  static constexpr double kY2 = 0.2561484929;
81  static constexpr double kY3 = -2.1400274434;
82  static constexpr double kY4 = 7.7016541929;
83  static constexpr double kY5 = -15.4832538240;
84  static constexpr double kY6 = 18.7878862180;
85  static constexpr double kY7 = -13.7678927060;
86  static constexpr double kY8 = 5.6453639087;
87 };
89 } // namespace imu_integration
90 
91 #endif // IMU_INTEGRATION_BUTTERO7_H_
imu_integration::ButterO7::AddValue
double AddValue(const double value) final
Definition: butterO7.h:34
filter.h
imu_integration::Filter
Definition: filter.h:23
logger.h
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY4
static constexpr double kY4
Definition: butterO7.h:82
imu_integration::ParamsButterO7S62_5Lp3N20_83::kX45
static constexpr double kX45
Definition: butterO7.h:79
imu_integration
Definition: butterO1.h:26
imu_integration::ParamsButterO7S62_5Lp3N20_83::kX36
static constexpr double kX36
Definition: butterO7.h:78
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY7
static constexpr double kY7
Definition: butterO7.h:85
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY3
static constexpr double kY3
Definition: butterO7.h:81
imu_integration::ParamsButterO7S62_5Lp3N20_83::kX27
static constexpr double kX27
Definition: butterO7.h:77
imu_integration::ParamsButterO7S62_5Lp3N20_83
Definition: butterO7.h:74
imu_integration::ParamsButterO7S62_5Lp3N20_83::kX18
static constexpr double kX18
Definition: butterO7.h:76
imu_integration::ParamsButterO7S62_5Lp3N20_83::kGain
static constexpr double kGain
Definition: butterO7.h:75
imu_integration::ButterO7::ButterO7
ButterO7()
Definition: butterO7.h:32
imu_integration::ButterO7
Definition: butterO7.h:30
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY8
static constexpr double kY8
Definition: butterO7.h:86
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY2
static constexpr double kY2
Definition: butterO7.h:80
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY5
static constexpr double kY5
Definition: butterO7.h:83
imu_integration::ParamsButterO7S62_5Lp3N20_83::kY6
static constexpr double kY6
Definition: butterO7.h:84