MAV'RIC
attitude_controller_p2.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_controller_p2.h
34  *
35  * \author MAV'RIC Team
36  * \author Julien Lecoeur
37  *
38  * \brief A simple quaternion based proportionnal squared controller for
39  * attitude control.
40  *
41  * \details It takes as input the desired attitude, the estimated attitude and
42  * the gyro rates.
43  * The control scheme is the following:
44  * - first the controller computes local roll pitch and yaw angular errors
45  * ( \f$ qerror \f$ ) using quaternion formulation
46  * - angular errors are multiplied by a proportional gain \f$ P_{q} \f$
47  * - feedback from the gyro is added to the output with gain \f$ P_{g} \f$
48  *
49  * in short:
50  * \f$
51  * output = (P_{q} . qerror) - (P_{g} . gyro)
52  * \f$
53  *
54  ******************************************************************************/
55 
56 
57 #ifndef ATTITUDE_CONTROLLER_P2_H_
58 #define ATTITUDE_CONTROLLER_P2_H_
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 #include "attitude_error_estimator.h"
65 #include "control_command.h"
66 #include "ahrs.h"
67 
68 
72 typedef struct
73 {
74  const ahrs_t* ahrs;
78  float p_gain_angle[3];
79  float p_gain_rate[3];
81 
82 
86 typedef struct
87 {
88  float p_gain_angle[3];
89  float p_gain_rate[3];
91 
92 
101 void attitude_controller_p2_init(attitude_controller_p2_t* controller, const attitude_controller_p2_conf_t* config, const attitude_command_t* attitude_command, torque_command_t* torque_command, const ahrs_t* ahrs);
102 
103 
109 void attitude_controller_p2_update(attitude_controller_p2_t* controller);
110 
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* ATTITUDE_CONTROLLER_P2_H_ */
P^2 Attitude controller configuration.
Definition: attitude_controller_p2.h:86
Structure containing the Attitude and Heading Reference System.
Definition: ahrs.h:58
const ahrs_t * ahrs
Pointer to attitude estimation (input)
Definition: attitude_controller_p2.h:74
Torque command structure.
Definition: control_command.h:142
torque_command_t * torque_command
Pointer to torque command (output)
Definition: attitude_controller_p2.h:76
const attitude_command_t * attitude_command
Pointer to attitude command (input)
Definition: attitude_controller_p2.h:75
Attitude command structure.
Definition: control_command.h:122
P^2 Attitude controller structure.
Definition: attitude_controller_p2.h:72
Quaternion attitude error estimator data structure.
Definition: attitude_error_estimator.h:68
attitude_error_estimator_t attitude_error_estimator
Attitude error estimator.
Definition: attitude_controller_p2.h:77