-
Couldn't load subscription status.
- Fork 9
Data Structures
Below is a list of the data structures that you will encounter in the code and an explanation of the fields within each of the structures.
The high data struct by default contains 16 float fields. This struct is designed to be data that is populated from the high priority thread and is sent to the low priority thread, allowing for communication from high to low. It can be access from both aa241x_high_control_law.cpp and aa241x_low_control_law.cpp files by calling the high_data variable.
src/modules/aa241x_high/high_data_struct.h
struct aa241x_high_data_s {
float HIGH_FIELD1;
float HIGH_FIELD2;
float HIGH_FIELD3;
float HIGH_FIELD4;
float HIGH_FIELD5;
float HIGH_FIELD6;
float HIGH_FIELD7;
float HIGH_FIELD8;
float HIGH_FIELD9;
float HIGH_FIELD10;
float HIGH_FIELD11;
float HIGH_FIELD12;
float HIGH_FIELD13;
float HIGH_FIELD14;
float HIGH_FIELD15;
float HIGH_FIELD16;
};
In the file where this struct is defined, there are a series of #defines to allow you to customize the variable names of each of the fields. Below is an example of custom defined variable name:
#define HIGH_FIELD1 my_custom_var_name1;
To then set the data to this struct with the custom variable name, the following code can be used in the aa241x_high_control_law.cpp file:
high_data.my_custom_var_name1 = my_float_variable1;
The data type of each of the fields can be set to a limited number of data types:
- float
- bool
- int
If you choose to change the data type of the fields, the logging function will convert the types to float for logging purposes (meaning a bool value will change to 1.0f or 0.0f, etc).
To make your lives easier in reading the logs the file that defines the struct contains the following line:
#define HIGH_DATA_LABELS "f01,f02,f03,f04,f05,f06,f07,f08,f09,f10,f11,f12,f13,f14,f15,f16"
This is a string of the labels that will be seen in the log file for the high data entries. You can change the labels if you would like but there are 2 important things to note:
- the string has a max char length of 64 characters, you can not exceed that limit
- you must have 16 different labels (each label is separated by a ','
If you violate either of these conditions NO DATA FOR ANYTHING will be logged (that includes all other logged data, such as attitude, position, etc).
The low data struct servers much the same purpose as the high data struct, just in the opposite direction. This strut contains data that you populate in the low priority thread to be sent to the high priority thread. It can be access from both aa241x_high_control_law.cpp and aa241x_low_control_law.cpp files by calling the low_data variable.
src/modules/aa241x_high/low_data_struct.h
struct aa241x_low_data_s {
float LOW_FIELD1;
float LOW_FIELD2;
float LOW_FIELD3;
float LOW_FIELD4;
float LOW_FIELD5;
float LOW_FIELD6;
float LOW_FIELD7;
float LOW_FIELD8;
float LOW_FIELD9;
float LOW_FIELD10;
float LOW_FIELD11;
float LOW_FIELD12;
float LOW_FIELD13;
float LOW_FIELD14;
float LOW_FIELD15;
float LOW_FIELD16;
};
This struct has all the same features as the high data struct.
Struct of your custom parameters for the high priority loop. These parameters are only be accessible in the high priority module.
src/modules/aa241x_high/aa241x_high_params.h
struct aah_params {
float example_high_param;
// TODO: add custom parameter variable names here......
};
These parameters can be accessed by any file in the high priority module with the following include:
#include "aa241x_high_aux.h"
Struct of your custom parameters for the low priority loop. These parameters are only be accessible in the low priority module.
src/modules/aa241x_low/aa241x_low_params.h
struct aal_params {
float example_low_param;
// TODO: add custom parameter variable names here......
};
These parameters can be accessed by any file in the low priority module with the following include:
#include "aa241x_low_aux.h"