MAV'RIC
stabilisation_copter_default_config.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 stabilisation_copter_default_config.h
34  *
35  * \author MAV'RIC Team
36  *
37  * \brief Default values for cascade PID controller
38  *
39  ******************************************************************************/
40 
41 
42 #ifndef STABILISATION_COPTER_DEFAULT_CONFIG_H_
43 #define STABILISATION_COPTER_DEFAULT_CONFIG_H_
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include "stabilisation_copter.h"
50 
51 
52 stabilisation_copter_conf_t stabilisation_copter_default_config =
53 {
54  .thrust_hover_point = -0.3f,
55  .motor_layout = QUADCOPTER_MOTOR_LAYOUT_DIAG,
56  .stabiliser_stack =
57  {
58  // #############################################################################
59  // ###### RATE CONTROL #######################################################
60  // #############################################################################
61  .rate_stabiliser={
62  .rpy_controller={
63  // -----------------------------------------------------------------
64  // ------ ROLL PID -------------------------------------------------
65  // -----------------------------------------------------------------
66  {
67  .p_gain = 0.05f,
68  .clip_min = -0.9f,
69  .clip_max = 0.9f,
70  .integrator={
71  .pregain = 0.5f,
72  .postgain = 1.0f,
73  .accumulator = 0.0f,
74  .clip = 0.65f,
75  },
76  .differentiator={
77  .gain = 0.15f,
78  .previous = 0.0f,
79  .clip = 0.65f
80  },
81  .output = 0.0f,
82  .error = 0.0f,
83  .last_update = 0.0f,
84  .dt = 1,
85  .soft_zone_width = 0.0f
86  },
87  // -----------------------------------------------------------------
88  // ------ PITCH PID ------------------------------------------------
89  // -----------------------------------------------------------------
90  {
91  .p_gain = 0.05f,
92  .clip_min = -0.9f,
93  .clip_max = 0.9f,
94  .integrator={
95  .pregain = 0.5f,
96  .postgain = 1.0f,
97  .accumulator = 0.0f,
98  .clip = 0.65f,
99  },
100  .differentiator={
101  .gain = 0.15f,
102  .previous = 0.0f,
103  .clip = 0.65f
104  },
105  .output = 0.0f,
106  .error = 0.0f,
107  .last_update = 0.0f,
108  .dt = 1,
109  .soft_zone_width = 0.0f
110  },
111  // -----------------------------------------------------------------
112  // ------ YAW PID --------------------------------------------------
113  // -----------------------------------------------------------------
114  {
115  .p_gain = 0.3f,
116  .clip_min = -0.3f,
117  .clip_max = 0.3f,
118  .integrator={
119  .pregain = 0.5f,
120  .postgain = 0.5f,
121  .accumulator = 0.0f,
122  .clip = 0.3f,
123  },
124  .differentiator={
125  .gain = 0.0f,
126  .previous = 0.0f,
127  .clip = 0.5f
128  },
129  .output = 0.0f,
130  .error = 0.0f,
131  .last_update = 0.0f,
132  .dt = 1,
133  .soft_zone_width = 0.0f
134  }
135  },
136  // ---------------------------------------------------------------------
137  // ------ THRUST PID ---------------------------------------------------
138  // ---------------------------------------------------------------------
139  .thrust_controller={
140  .p_gain = 1.0f,
141  .clip_min = -1000,
142  .clip_max = 1000,
143  .integrator={
144  .pregain = 0.0f,
145  .postgain = 0.0f,
146  .accumulator = 0.0f,
147  .clip = 0.0f,
148  },
149  .differentiator={
150  .gain = 0.0f,
151  .previous = 0.0f,
152  .clip = 0.0f
153  },
154  .output = 0.0f,
155  .error = 0.0f,
156  .last_update = 0.0f,
157  .dt = 1,
158  .soft_zone_width = 0.0f
159  },
160  // ---------------------------------------------------------------------
161  // ------ OUTPUT -------------------------------------------------------
162  // ---------------------------------------------------------------------
163  .output = {
164  .rpy = {0.0f, 0.0f, 0.0f},
165  .thrust = 0.0f,
166  .tvel = {0.0f, 0.0f, 0.0f},
167  .theading = 0.0f,
168  .control_mode = RATE_COMMAND_MODE,
169  .yaw_mode = YAW_RELATIVE
170  //.yaw_mode = YAW_RELATIVE,
171  //.run_mode = MOTORS_OFF
172  },
173  },
174  // #############################################################################
175  // ###### ATTITUDE CONTROL ###################################################
176  // #############################################################################
177  .attitude_stabiliser={
178  .rpy_controller={
179  // -----------------------------------------------------------------
180  // ------ ROLL PID -------------------------------------------------
181  // -----------------------------------------------------------------
182  {
183  .p_gain = 4.0f,
184  .clip_min = -1.2f,
185  .clip_max = 1.2f,
186  .integrator={
187  .pregain = 0.0f,
188  .postgain = 0.0f,
189  .accumulator = 0.0f,
190  .clip = 0.0f,
191  },
192  .differentiator={
193  .gain = 0.0f,
194  .previous = 0.0f,
195  .clip = 0.1f
196  },
197  .output = 0.0f,
198  .error = 0.0f,
199  .last_update = 0.0f,
200  .dt = 1,
201  .soft_zone_width = 0.0f
202  },
203  // -----------------------------------------------------------------
204  // ------ PITCH PID ------------------------------------------------
205  // -----------------------------------------------------------------
206  {
207  .p_gain = 4.0f,
208  .clip_min = -1.2f,
209  .clip_max = 1.2f,
210  .integrator={
211  .pregain = 0.0f,
212  .postgain = 0.0f,
213  .accumulator = 0.0f,
214  .clip = 0.0f,
215  },
216  .differentiator={
217  .gain = 0.0f,
218  .previous = 0.0f,
219  .clip = 0.1f
220  },
221  .output = 0.0f,
222  .error = 0.0f,
223  .last_update = 0.0f,
224  .dt = 1,
225  .soft_zone_width = 0.0f
226  },
227  // -----------------------------------------------------------------
228  // ------ YAW PID --------------------------------------------------
229  // -----------------------------------------------------------------
230  {
231  .p_gain = 3.0f,
232  .clip_min = -1.5f,
233  .clip_max = 1.5f,
234  .integrator={
235  .pregain = 0.0f,
236  .postgain = 0.0f,
237  .accumulator = 0.0f,
238  .clip = 0.0f,
239  },
240  .differentiator={
241  .gain = 0.0f,
242  .previous = 0.0f,
243  .clip = 0.5f
244  },
245  .output = 0.0f,
246  .error = 0.0f,
247  .last_update = 0.0f,
248  .dt = 1,
249  .soft_zone_width = 0.0f
250  }
251  },
252  // ---------------------------------------------------------------------
253  // ------ THRUST PID ---------------------------------------------------
254  // ---------------------------------------------------------------------
255  .thrust_controller={
256  .p_gain = 1.0f,
257  .clip_min = -1,
258  .clip_max = 1,
259  .integrator={
260  .pregain = 0.0f,
261  .postgain = 0.0f,
262  .accumulator = 0.0f,
263  .clip = 0.0f,
264  },
265  .differentiator={
266  .gain = 0.0f,
267  .previous = 0.0f,
268  .clip = 0.0f
269  },
270  .output = 0.0f,
271  .error = 0.0f,
272  .last_update = 0.0f,
273  .dt = 1,
274  .soft_zone_width = 0.0f
275  },
276  // ---------------------------------------------------------------------
277  // ------ OUTPUT -------------------------------------------------------
278  // ---------------------------------------------------------------------
279  .output = {
280  .rpy = {0.0f, 0.0f, 0.0f},
281  .thrust = 0.0f,
282  .tvel = {0.0f, 0.0f, 0.0f},
283  .theading = 0.0f,
284  .control_mode = RATE_COMMAND_MODE,
285  .yaw_mode = YAW_RELATIVE
286  //.yaw_mode = YAW_RELATIVE,
287  //.run_mode = MOTORS_OFF
288  },
289  },
290  // #############################################################################
291  // ###### VELOCITY CONTROL ###################################################
292  // #############################################################################
293  .velocity_stabiliser={
294  .rpy_controller={
295  // -----------------------------------------------------------------
296  // ------ ROLL PID -------------------------------------------------
297  // -----------------------------------------------------------------
298  {
299  .p_gain = 0.2f,
300  .clip_min = -0.5f,
301  .clip_max = 0.5f,
302  .integrator={
303  .pregain = 1.0f,
304  .postgain = 0.5f,
305  .accumulator = 0.0f,
306  .clip = 0.5f,
307  },
308  .differentiator={
309  .gain = 0.0f,
310  .previous = 0.0f,
311  .clip = 0.5f
312  },
313  .output = 0.0f,
314  .error = 0.0f,
315  .last_update = 0.0f,
316  .dt = 1,
317  .soft_zone_width = 0.2f
318  },
319  // -----------------------------------------------------------------
320  // ------ PITCH PID ------------------------------------------------
321  // -----------------------------------------------------------------
322  {
323  .p_gain = 0.2f,
324  .clip_min = -0.5f,
325  .clip_max = 0.5f,
326  .integrator={
327  .pregain = 1.0f,
328  .postgain = 0.5f,
329  .accumulator = 0.0f,
330  .clip = 0.5f,
331  },
332  .differentiator={
333  .gain = 0.0f,
334  .previous = 0.0f,
335  .clip = 0.5f
336  },
337  .output = 0.0f,
338  .error = 0.0f,
339  .last_update = 0.0f,
340  .dt = 1,
341  .soft_zone_width = 0.2f
342  },
343  // -----------------------------------------------------------------
344  // ------ YAW PID --------------------------------------------------
345  // -----------------------------------------------------------------
346  {
347  .p_gain = 1.0f,
348  .clip_min = -1,
349  .clip_max = 1,
350  .integrator={
351  .pregain = 0.0f,
352  .postgain = 0.0f,
353  .accumulator = 0.0f,
354  .clip = 0.0f,
355  },
356  .differentiator={
357  .gain = 0.0f,
358  .previous = 0.0f,
359  .clip = 0.0f
360  },
361  .output = 0.0f,
362  .error = 0.0f,
363  .last_update = 0.0f,
364  .dt = 1,
365  .soft_zone_width = 0.0f
366  }
367  },
368  // ---------------------------------------------------------------------
369  // ------ THRUST PID ---------------------------------------------------
370  // ---------------------------------------------------------------------
371  .thrust_controller={
372  .p_gain = 0.20f,
373  .clip_min = -0.9f,
374  .clip_max = 0.65f,
375  .integrator={
376  .pregain = 1.0f,
377  .postgain = 0.0f,
378  .accumulator = 0.0f,
379  .clip = 1.0f,
380  },
381  .differentiator={
382  .gain = 0.2f,
383  .previous = 0.0f,
384  .clip = 0.2f
385  },
386  .output = 0.0f,
387  .error = 0.0f,
388  .last_update = 0.0f,
389  .dt = 1,
390  .soft_zone_width = 0.2f
391  },
392  // ---------------------------------------------------------------------
393  // ------ OUTPUT -------------------------------------------------------
394  // ---------------------------------------------------------------------
395  .output = {
396  .rpy = {0.0f, 0.0f, 0.0f},
397  .thrust = 0.0f,
398  .tvel = {0.0f, 0.0f, 0.0f},
399  .theading = 0.0f,
400  .control_mode = RATE_COMMAND_MODE,
401  .yaw_mode = YAW_RELATIVE
402  //.yaw_mode = YAW_RELATIVE,
403  //.run_mode = MOTORS_OFF
404  },
405  },
406  // #############################################################################
407  // ###### POSITION CONTROL ###################################################
408  // #############################################################################
409  .position_stabiliser={
410  .rpy_controller={
411  // -----------------------------------------------------------------
412  // ------ ROLL PID -------------------------------------------------
413  // -----------------------------------------------------------------
414  {
415  .p_gain = 0.1f,
416  .clip_min = -0.5f,
417  .clip_max = 0.5f,
418  .integrator={
419  .pregain = 0.0f,
420  .postgain = 0.0f,
421  .accumulator = 0.0f,
422  .clip = 0.0f,
423  },
424  .differentiator={
425  .gain = 0.05f,
426  .previous = 0.0f,
427  .clip = 0.5f
428  },
429  .output = 0.0f,
430  .error = 0.0f,
431  .last_update = 0.0f,
432  .dt = 1,
433  .soft_zone_width = 0.2f
434  },
435  // -----------------------------------------------------------------
436  // ------ PITCH PID ------------------------------------------------
437  // -----------------------------------------------------------------
438  {
439  .p_gain = 0.1f,
440  .clip_min = -0.5f,
441  .clip_max = 0.5f,
442  .integrator={
443  .pregain = 0.0f,
444  .postgain = 0.0f,
445  .accumulator = 0.0f,
446  .clip = 0.5f,
447  },
448  .differentiator={
449  .gain = 0.05f,
450  .previous = 0.0f,
451  .clip = 0.5f
452  },
453  .output = 0.0f,
454  .error = 0.0f,
455  .last_update = 0.0f,
456  .dt = 1,
457  .soft_zone_width = 0.2f
458  },
459  // -----------------------------------------------------------------
460  // ------ YAW PID --------------------------------------------------
461  // -----------------------------------------------------------------
462  {
463  .p_gain = 1.0f,
464  .clip_min = -1,
465  .clip_max = 1,
466  .integrator={
467  .pregain = 0.0f,
468  .postgain = 0.0f,
469  .accumulator = 0.0f,
470  .clip = 0.0f,
471  },
472  .differentiator={
473  .gain = 0.0f,
474  .previous = 0.0f,
475  .clip = 0.0f
476  },
477  .output = 0.0f,
478  .error = 0.0f,
479  .last_update = 0.0f,
480  .dt = 1,
481  .soft_zone_width = 0.0f
482  }
483  },
484  // ---------------------------------------------------------------------
485  // ------ THRUST PID ---------------------------------------------------
486  // ---------------------------------------------------------------------
487  .thrust_controller={
488  .p_gain = 0.05f,
489  .clip_min = -0.9f,
490  .clip_max = 0.65f,
491  .integrator={
492  .pregain = 0.001f,
493  .postgain = 1.0f,
494  .accumulator = 0.0f,
495  .clip = 0.5f,
496  },
497  .differentiator={
498  .gain = 0.1f,
499  .previous = 0.0f,
500  .clip = 0.2f
501  },
502  .output = 0.0f,
503  .error = 0.0f,
504  .last_update = 0.0f,
505  .dt = 1,
506  .soft_zone_width = 0.2f
507  },
508  // ---------------------------------------------------------------------
509  // ------ OUTPUT -------------------------------------------------------
510  // ---------------------------------------------------------------------
511  .output = {
512  .rpy = {0.0f, 0.0f, 0.0f},
513  .thrust = 0.0f,
514  .tvel = {0.0f, 0.0f, 0.0f},
515  .theading = 0.0f,
516  .control_mode = RATE_COMMAND_MODE,
517  .yaw_mode = YAW_RELATIVE
518  //.yaw_mode = YAW_RELATIVE,
519  //.run_mode = MOTORS_OFF
520  },
521  },
522  // #############################################################################
523  // ###### MISC ###############################################################
524  // #############################################################################
525  .yaw_coordination_velocity=1.5f
526  }
527 };
528 
529 #ifdef __cplusplus
530 }
531 #endif
532 
533 #endif /* STABILISATION_COPTER_DEFAULT_CONFIG_H_ */
Structure containing the configuration data.
Definition: stabilisation_copter.h:97
float thrust_hover_point
The hover point of the thrust.
Definition: stabilisation_copter.h:99