MAV'RIC
attitude_error_estimator.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file attitude_error_estimator.h
34  *
35  * \author MAV'RIC Team
36  * \author Julien Lecoeur
37  *
38  * \brief A quaternion-based attitude-error estimator, takes a reference
39  * quaternion as input and provides angular errors for roll, pitch and yaw in
40  * the local frame.
41  *
42  * \details WARNING: For optimisation purpose, the computed errors are not in
43  * radians:
44  * With \f$ e_{roll} , e_{pitch}, e_{yaw} \f$ the true errors in radians around
45  * the local roll, pitch and yaw axes,
46  * this estimator returns
47  * \f$ 2.sin( e_{roll} / 2 ), 2.sin( e_{pitch} / 2 ), 2.sin( e_{yaw} / 2 ) \f$
48  *
49  * For small angular errors, this approximation is sensible.
50  *
51  ******************************************************************************/
52 
53 
54 #ifndef ATTITUDE_ERROR_ESTIMATOR_H_
55 #define ATTITUDE_ERROR_ESTIMATOR_H_
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #include "quaternions.h"
62 #include "coord_conventions.h"
63 #include "ahrs.h"
64 
68 typedef struct
69 {
71  float rpy_errors[3];
72  const ahrs_t* ahrs;
74 
75 
82 void attitude_error_estimator_init(attitude_error_estimator_t* estimator, const ahrs_t* ahrs);
83 
84 
91 void attitude_error_estimator_set_quat_ref(attitude_error_estimator_t* estimator, const quat_t quat_ref);
92 
93 
100 void attitude_error_estimator_set_quat_ref_from_aero(attitude_error_estimator_t* estimator, const aero_attitude_t aero);
101 
102 
109 void attitude_error_estimator_set_quat_ref_from_rpy(attitude_error_estimator_t* estimator, const float rpy[3]);
110 
111 
117 void attitude_error_estimator_update(attitude_error_estimator_t* estimator);
118 
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* ATTITUDE_ERROR_ESTIMATOR_H_ */
Structure containing the Attitude and Heading Reference System.
Definition: ahrs.h:58
quat_t quat_ref
Reference attitude, the errors in roll pitch and yaw will be computed relative to this reference...
Definition: attitude_error_estimator.h:70
const ahrs_t * ahrs
Pointer to AHRS (current attitude), must be updated externally.
Definition: attitude_error_estimator.h:72
Unit quaternion.
Definition: quaternions.h:62
Quaternion attitude error estimator data structure.
Definition: attitude_error_estimator.h:68
Definition: coord_conventions.h:91