Doublet input for system identification.
The doublet is a multi step maneuver for system identification. Two modes are implemented, the 0,1,-1,0 maneuver (which correspond to one period of a squared sine wave oscillation, and the "so-called" 3-2-1-1 maneuver.
The module is used by including the module in the airframe file and adding the following line to the <command_laws> section:
<call fun="sys_id_doublet_add_values(autopilot_get_motors_on(),FALSE,values)">
You can pick the axes to apply doublets to by setting the DOUBLET_AXES variable with the COMMAND_XXX variables where XXX are the actuators defined in the <commands> section of your airframe.
Remeber to deactivate the control input when the system identification input is running using (can be checked using the sys_id_wave_running() function)
Then, the GCS exposes the settings for the doublet.
- 3-2-1-1 setting is to execute the 3-2-1-1 doublet maneuver when active. Otherwise, the normal 1-1 doublet maneuver will be executed.
- The Doublet axis settings is the index (0-based) of the axis to choose within the DOUBLET_AXES variable specified. In the default, this means i.e. 0 means roll doublet.
- Amplitude is the amplitude of the doublet
- Length_s is the length in seconds of the doublet. The lenght of each doublet step depends on the active mode and on the doublet lenght.
- Extra_waiting_time_s is the length in second of the waiting time with zero input after the doublet maneuver is over.
Start the doublet by checking the Active box in the "Activate doublet". Stop the doublet by checking the Inactive box in the same input setting.
Add the message "DOUBLET" to your telemetry to see doublet progress, and to your logger to obtain information about the provided input.
Add the following message structure to the messages.xml file on a free ID
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="sys_id_doublet">
b'<define name="DOUBLET_AXES" value="{COMMAND_ROLL,COMMAND_PITCH,COMMAND_YAW}" />\n '
b'<define name="DOUBLET_ENABLED" value="TRUE|FALSE" />\n '
b'<define name="DOUBLET_MOD3211" value="TRUE|FALSE" />\n '
</module>
Module configuration options
Define Options
- name:
DOUBLET_AXES
value: {COMMAND_ROLL,COMMAND_PITCH,COMMAND_YAW}
Description: Which axes the doublet is applied to (specify as array with {})
- name:
DOUBLET_ENABLED
value: TRUE|FALSE
Description: If false, the doublet does not run and values are not added
- name:
DOUBLET_MOD3211
value: TRUE|FALSE
Description: If true, the 3-2-1-1 doublet will be executed instead of the normal doublet
Module functions
Init Functions
These initialization functions are called once on startup.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- sys_id_doublet_run()
- Frequency in Hz: 60
- Autorun: TRUE
Periodic function automatically starts after init.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw sys_id_doublet.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="sys_id_doublet" dir="system_identification">
<doc>
<description>Doublet input for system identification.
The doublet is a multi step maneuver for system identification. Two modes are implemented, the 0,1,-1,0 maneuver (which correspond to
one period of a squared sine wave oscillation, and the "so-called" 3-2-1-1 maneuver.
The module is used by including the module in the airframe file and adding the following line to the <command_laws> section:
<call fun="sys_id_doublet_add_values(autopilot_get_motors_on(),FALSE,values)"/>
You can pick the axes to apply doublets to by setting the DOUBLET_AXES variable with the COMMAND_XXX variables where XXX are the actuators defined in
the <commands> section of your airframe.
Remeber to deactivate the control input when the system identification input is running using (can be checked using the sys_id_wave_running() function)
Then, the GCS exposes the settings for the doublet.
- 3-2-1-1 setting is to execute the 3-2-1-1 doublet maneuver when active. Otherwise, the normal 1-1 doublet maneuver will be executed.
- The Doublet axis settings is the index (0-based) of the axis to choose within the DOUBLET_AXES variable specified. In the default, this means i.e. 0 means roll doublet.
- Amplitude is the amplitude of the doublet
- Length_s is the length in seconds of the doublet. The lenght of each doublet step depends on the active mode and on the doublet lenght.
- Extra_waiting_time_s is the length in second of the waiting time with zero input after the doublet maneuver is over.
Start the doublet by checking the Active box in the "Activate doublet". Stop the doublet by checking the Inactive box in the same input setting.
Add the message "DOUBLET" to your telemetry to see doublet progress, and to your logger to obtain information about the provided input.
Add the following message structure to the messages.xml file on a free ID
</description>
<define name="DOUBLET_AXES" value="{COMMAND_ROLL,COMMAND_PITCH,COMMAND_YAW}" description="Which axes the doublet is applied to (specify as array with {})"/>
<define name="DOUBLET_ENABLED" value="TRUE|FALSE" description="If false, the doublet does not run and values are not added"/>
<define name="DOUBLET_MOD3211" value="TRUE|FALSE" description="If true, the 3-2-1-1 doublet will be executed instead of the normal doublet"/>
</doc>
<settings>
<dl_settings name="System identification">
<dl_settings name="Doublet input">
<dl_setting min="0" max="1" step="1" values="Inactive|Active" shortname="Doublet" var="doublet_active" type="uint8_t" module="system_identification/sys_id_doublet" handler="activate_handler"/>
<dl_setting min="0" max="1" step="1" values="Inactive|Active" shortname="3-2-1-1 mode" var="doublet_mode_3211" type="uint8_t" module="system_identification/sys_id_doublet" handler="mod3211_handler"/>
<dl_setting min="0" max="9600" step="100" shortname="Amplitude" var="doublet_amplitude" type="int32_t" module="system_identification/sys_id_doublet"/>
<dl_setting min="0" max="5" step="1" shortname="Doublet axis" var="doublet_axis" type="uint8_t" module="system_identification/sys_id_doublet" handler="axis_handler"/>
<dl_setting min="0" max="100" step="0.5" shortname="Length_s" var="doublet_length_s" type="float" module="system_identification/sys_id_doublet"/>
<dl_setting min="0" max="100" step="0.5" shortname="Extra_waiting_s" var="doublet_extra_waiting_time_s" type="float" module="system_identification/sys_id_doublet"/>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="sys_id_doublet.h"/>
</header>
<init fun="sys_id_doublet_init()"/>
<periodic fun="sys_id_doublet_run()" freq="60" autorun="TRUE"/>
<makefile>
<file name="pprz_doublet.c"/>
<file name="sys_id_doublet.c"/>
</makefile>
</module>