madgwickahrs.hh
Go to the documentation of this file.
1 //========================================================================
2 //
3 // Implementation of Madgwick's IMU and AHRS algorithms.
4 // See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms
5 //
6 // Date Author Notes
7 // 29/09/2011 SOH Madgwick Initial release
8 // 02/10/2011 SOH Madgwick Optimised for reduced CPU load
9 // 11/05/2017 T Flayols Make it a dynamic graph entity
10 // 26/03/2019 G Buondonno Converted to double
11 //
12 //========================================================================
13 
14 /*
15  * Copyright 2017, Thomas Flayols, LAAS-CNRS
16  *
17  * This file is part of sot-torque-control.
18  * sot-torque-control is free software: you can redistribute it and/or
19  * modify it under the terms of the GNU Lesser General Public License
20  * as published by the Free Software Foundation, either version 3 of
21  * the License, or (at your option) any later version.
22  * sot-torque-control is distributed in the hope that it will be
23  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
24  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU Lesser General Public License for more details. You should
26  * have received a copy of the GNU Lesser General Public License along
27  * with sot-torque-control. If not, see <http://www.gnu.org/licenses/>.
28  */
29 
30 #ifndef __sot_torque_control_madgwickahrs_H__
31 #define __sot_torque_control_madgwickahrs_H__
32 
33 /* --------------------------------------------------------------------- */
34 /* --- API ------------------------------------------------------------- */
35 /* --------------------------------------------------------------------- */
36 
37 #if defined(WIN32)
38 #if defined(madgwickahrs_EXPORTS)
39 #define SOTMADGWICKAHRS_EXPORT __declspec(dllexport)
40 #else
41 #define SOTMADGWICKAHRS_EXPORT __declspec(dllimport)
42 #endif
43 #else
44 #define SOTMADGWICKAHRS_EXPORT
45 #endif
46 
47 /* --------------------------------------------------------------------- */
48 /* --- INCLUDE --------------------------------------------------------- */
49 /* --------------------------------------------------------------------- */
50 
52 
53 #include <map>
55 
56 #include "boost/assign.hpp"
57 
58 #define betaDef 0.01 // 2 * proportional g
59 
60 namespace dynamicgraph {
61 namespace sot {
88 
89  public:
90  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
91 
92  /* --- CONSTRUCTOR ---- */
93  MadgwickAHRS(const std::string &name);
94 
95  void init(const double &dt);
96  void set_beta(const double &beta);
97 
99  void set_imu_quat(const dynamicgraph::Vector &imu_quat);
100 
101  /* --- SIGNALS --- */
103  DECLARE_SIGNAL_IN(accelerometer, dynamicgraph::Vector);
108 
109  protected:
110  /* --- COMMANDS --- */
111  /* --- ENTITY INHERITANCE --- */
112  virtual void display(std::ostream &os) const;
113 
114  /* --- METHODS --- */
115  double invSqrt(double x);
116  void madgwickAHRSupdateIMU(double gx, double gy, double gz, double ax,
117  double ay, double az);
118 
119  protected:
123  double m_beta;
125  double m_q0, m_q1, m_q2, m_q3;
127  double m_sampleFreq;
128 
129 }; // class MadgwickAHRS
130 } // namespace sot
131 } // namespace dynamicgraph
132 
133 #endif // #ifndef __sot_torque_control_madgwickahrs_H__
Eigen::VectorXd Vector
bool m_initSucceeded
true if the entity has been successfully initialized
#define DECLARE_SIGNAL_IN(name, type)
#define SOTMADGWICKAHRS_EXPORT
Definition: madgwickahrs.hh:44
#define DYNAMIC_GRAPH_ENTITY_DECL()
double m_sampleFreq
sample frequency in Hz
#define DECLARE_SIGNAL_OUT(name, type)
void init(bool compute_local_aabb=true)
double m_beta
2 * proportional gain (Kp)


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26