[modules] minor ctrl_module_demo cosmetics

This commit is contained in:
Felix Ruess
2015-03-07 13:53:27 +01:00
parent 9d0992220a
commit 0b245c04db
3 changed files with 30 additions and 24 deletions
+10 -9
View File
@@ -3,19 +3,20 @@
<module name="ctrl_module_demo" dir="ctrl"> <module name="ctrl_module_demo" dir="ctrl">
<doc> <doc>
<description> <description>
Demo Control Module Demo Control Module.
Only for rotorcraft firmware.
Rate-controller as module sample Simple rate controler as example on how to integrate write and call your own controller in a module.
</description> </description>
</doc> </doc>
<settings> <settings>
<dl_settings> <dl_settings>
<dl_settings NAME="CtrlModDemo"> <dl_settings NAME="CtrlModDemo">
<dl_setting var="ctrl_module_demo_pr_ff_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="pr_ff"/> <dl_setting var="ctrl_module_demo_pr_ff_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="pr_ff"/>
<dl_setting var="ctrl_module_demo_pr_d_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="pr_d"/> <dl_setting var="ctrl_module_demo_pr_d_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="pr_d"/>
<dl_setting var="ctrl_module_demo_y_ff_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="y_ff"/> <dl_setting var="ctrl_module_demo_y_ff_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="y_ff"/>
<dl_setting var="ctrl_module_demo_y_d_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="y_d"/> <dl_setting var="ctrl_module_demo_y_d_gain" min="0" step="0.01" max="1" module="ctrl/ctrl_module_demo" shortname="y_d"/>
</dl_settings> </dl_settings> </dl_settings>
</dl_settings>
</settings> </settings>
<header> <header>
+17 -12
View File
@@ -53,7 +53,7 @@ void ctrl_module_init(void)
ctrl_module_demo.rc_t = 0; ctrl_module_demo.rc_t = 0;
} }
// Old-fashened rate control without reference model nor attitude // simple rate control without reference model nor attitude
void ctrl_module_run(bool_t in_flight) void ctrl_module_run(bool_t in_flight)
{ {
if (!in_flight) { if (!in_flight) {
@@ -63,18 +63,17 @@ void ctrl_module_run(bool_t in_flight)
stabilization_cmd[COMMAND_YAW] = 0; stabilization_cmd[COMMAND_YAW] = 0;
stabilization_cmd[COMMAND_THRUST] = 0; stabilization_cmd[COMMAND_THRUST] = 0;
} else { } else {
stabilization_cmd[COMMAND_ROLL] = ctrl_module_demo.rc_x * ctrl_module_demo_pr_ff_gain - stateGetBodyRates_i()->p * stabilization_cmd[COMMAND_ROLL] = ctrl_module_demo.rc_x * ctrl_module_demo_pr_ff_gain -
ctrl_module_demo_pr_d_gain; stateGetBodyRates_i()->p * ctrl_module_demo_pr_d_gain;
stabilization_cmd[COMMAND_PITCH] = ctrl_module_demo.rc_y * ctrl_module_demo_pr_ff_gain - stateGetBodyRates_i()->q * stabilization_cmd[COMMAND_PITCH] = ctrl_module_demo.rc_y * ctrl_module_demo_pr_ff_gain -
ctrl_module_demo_pr_d_gain; stateGetBodyRates_i()->q * ctrl_module_demo_pr_d_gain;
stabilization_cmd[COMMAND_YAW] = ctrl_module_demo.rc_z * ctrl_module_demo_y_ff_gain - stateGetBodyRates_i()->r * stabilization_cmd[COMMAND_YAW] = ctrl_module_demo.rc_z * ctrl_module_demo_y_ff_gain -
ctrl_module_demo_y_d_gain; stateGetBodyRates_i()->r * ctrl_module_demo_y_d_gain;
stabilization_cmd[COMMAND_THRUST] = ctrl_module_demo.rc_t; stabilization_cmd[COMMAND_THRUST] = ctrl_module_demo.rc_t;
} }
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Call our controller // Call our controller
// Implement own Horizontal loops // Implement own Horizontal loops
@@ -82,6 +81,7 @@ void guidance_h_module_enter(void)
{ {
ctrl_module_init(); ctrl_module_init();
} }
void guidance_h_module_read_rc(void) void guidance_h_module_read_rc(void)
{ {
// -MAX_PPRZ to MAX_PPRZ // -MAX_PPRZ to MAX_PPRZ
@@ -97,8 +97,13 @@ void guidance_h_module_run(bool_t in_flight)
ctrl_module_run(in_flight); ctrl_module_run(in_flight);
} }
// Implement own Horizontal loops // Implement own Vertical loops
inline void guidance_v_module_enter(void) {} void guidance_v_module_enter(void)
inline void guidance_v_module_run(UNUSED bool_t in_flight) {} {
// your code that should be executed when entering this vertical mode goes here
}
void guidance_v_module_run(UNUSED bool_t in_flight)
{
// your vertical controller goes here
}
+3 -3
View File
@@ -22,6 +22,7 @@
* @file modules/ctrl/ctrl_module_demo.c * @file modules/ctrl/ctrl_module_demo.c
* @brief example empty controller * @brief example empty controller
* *
* Implements an example simple rate controller in a module.
*/ */
#ifndef CTRL_MODULE_DEMO_H_ #ifndef CTRL_MODULE_DEMO_H_
@@ -47,9 +48,8 @@ extern void guidance_h_module_enter(void);
extern void guidance_h_module_read_rc(void); extern void guidance_h_module_read_rc(void);
extern void guidance_h_module_run(bool_t in_flight); extern void guidance_h_module_run(bool_t in_flight);
// Implement own Horizontal loops // Implement own Vertical loops
extern void guidance_v_module_enter(void); extern void guidance_v_module_enter(void);
extern void guidance_v_module_run(bool_t in_flight); extern void guidance_v_module_run(bool_t in_flight);
#endif /* CTRL_MODULE_DEMO_H_ */
#endif /* HOVER_STABILIZATION_H_ */