-
Notifications
You must be signed in to change notification settings - Fork 9
Parameters
Parameters are values that can be set from QGroundControl and can be used in your control loops. Feel free to create as many custom parameters as you need to define you models, or just as tuneable parameters, as parameters can be changed in flight.
Safety note: it is not recommended to change any gain style parameters while flying in AUTO mode, it is best to do so in MANUAL mode, switch to AUTO and be prepared to switch back to MANUAL if the values are way off.
There are 2 sets of parameters that you will be interested in:
- AAH
- AAL
These are your custom parameters that you have created for use in the high priority module.
These are your custom parameters that you have created for use in the low priority module.
Custom parameters can be created for use in both the high priority module and the low priority module. These instructions will use the high priority module files, but the exact same instructions apply for the low module files.
The 2 files of interest for parameter creation are
aa241x_high/aa241x_high_params.haa241x_high/aa241x_high_params.c
-
Define a new parameter in the
aa241x_high_params.cfile, such as the following parameter:/** * This is an example parameter. The name of the parameter in QGroundControl * will be AAH_EXAMPLE and will be in the AAH dropdown. Make sure to always * start your parameters with AA to have them all in one place. * * The default value of this float parameter will be 10.0. * * @unit meter (the unit attribute (not required, just helps for sanity)) * @min 0 (optional minimum value for displaying in the ground station) * @max 100 (optional max) * @group AA241x High Params (always include this) */ PARAM_DEFINE_FLOAT(AAH_EXAMPLE, 10.0f);This code defines a new parameter called
AAH_EXAMPLEthat is defined as a float. In QGroundControl this parameter will be able to be found in the AAH folder, with the display name ofAAH_EXAMPLE.You may also use
PARAM_DEFINE_INT32(AAH_INT, 10);to define a parameter as an INT instead of as a float.NOTE: for high priority module parameters, all names should begin with
AAH_to have all of those parameters under the same folder. All low priority module parameters should begin withAAL_.NOTE: there is a 15 character character limit for parameter names, so make sure that all the parameters names you create are <= 15 characters long.
-
Define a variable for your new parameter in
aah_paramsstruct andaah_param_handlesstruct in theaa241x_high_params.hfile. For simplicity feel free to make the variable the same between the two structs. See the following example (which can be also found in the code).struct aah_params { float example_high_param; int example_high_int_param; /**< if you used PARAM_DEFINE_INT32, declare the variable as an int */ // TODO: add custom parameter variable names here...... }; struct aah_param_handles { param_t example_high_param; param_t example_high_int_param; /**< same data type event for an int param for the handles struct */ // TODO: add custom parameter variable names here....... }; -
Add initialization for newly defined parameter in
aa241x_high_params.cin theint aah_parameters_init(struct aah_param_handles *h){}function. Here is an example initialization for a custom parameter:int aah_parameters_init(struct aah_param_handles *h) { h->example_high_param = param_find("AAH_EXAMPLE"); // TODO: add the above line for each of your custom parameters........ return OK; }Note: When adding your custom parameters, the input into the
param_find()function will be a string of the name passed toPARAM_DEFINE_FLOAT()function. -
Add update handling for newly define parameter in
aa241x_high_params.cin theint aah_parameters_update(const struct aah_param_handles *h, struct aah_params *p){}function. Here is an example addition for updating a custom parameter:int aah_parameters_update(const struct aah_param_handles *h, struct aah_params *p) { param_get(h->example_high_param, &(p->example_high_param)); // TODO: add the above line for each of your custom parameters..... return OK;}