Skip to content
adrnp edited this page Mar 25, 2015 · 2 revisions

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.

Picture Result

This struct contains the information returned by the virtual camera onboard.

src/modules/uORB/topics/aa241x_picture_result.h

struct picture_result_s {
	bool pic_taken;			/**< if true, a picture was successfully taken */
	uint64_t time_us;		/**< unix timestamp in microseconds at which the picture was taken */
	float center_n;			/**< North coordinate (North distance from center in [m]) of the center of the picture */
	float center_e;			/**< East coordinate (East distance from center in [m]) of the center of the picture */
	float center_d;			/**< Down coordinate (negative vertical distance from bottom) of the center of the picture */
	float pic_d;			/**< diameter in [m] of the picture taken */
	int num_cells;			/**< number of grid cells in view (length of vectors i, j, and state) */

	int i[9];		/**< array containing the i coordinate of grid cells in view */
	int j[9];		/**< array containing the j coordinate of the grid cells in view */
	int state[9];	/**< the state of the grid cell in view */
};

Note: while the i, j, and state arrays are 9 element long, only the first num_cells elements will contain valid data.

High Data

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

Logging of High Data

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).

Low Data

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.

Mission Parameters

Struct of all the mission definition parameters.

src/modules/aa241x_high/aa241x_high_aux.h
src/modules/aa241x_low/aa241x_low_aux.h

struct mis_params {
	float min_alt;			/**< minimum allowed flight altitude during mission [m] */
	float max_alt;			/**< maximum allowed flight altitude during mission [m] */
	float auto_alt;			/**< altitude by which auto must be enabled for a mission start [m] */
	float cell_width;		/**< height and width of each grid cell [m] */
	float duration;			/**< duration of time the fire will keep propagating [min] */
	float max_radius;		/**< the maximum allowed radial distance from the center of lake lag [m] */
	float timestep;			/**< timestep of fire propagation [sec] */
	float std;				/**< std used for fire propgation direction */
	float t_pic;			/**< minimum time between successive pictures [sec] */
	float min_fov;			/**< minimum field of view of the camera [m] */
	float max_fov;			/**< maximum field of view of the camera [m] */
	int index;				/**< the mission index you are currently running */
	float water_weight;		/**< the amount of water weight you are currently carrying [g] */
	float weight_per_drop;	/**< the amount of weight needed for each drop of water [g/drop] */
	float ctr_lat;			/**< gps lat of the center of lake lag */
	float ctr_lon;			/**< gps lon of the center of lake lag */
	float ctr_alt;			/**< gps altitude of the bottom of lake lag */
};

struct mis_params mission_parameters;			/**< local copies of mission parameters */

If you want to access any of the parameters within your code, you can simple access that parameter in the following manner with the following include:

#include "aa241x_high_aux.h" 	// for files in the aa241x_high/ folder
#include "aa241x_low_aux.h"		// for files in the aa241x_low/ folder

float min_alt = mission_parameters.min_alt;

AAH Parameters

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"

AAL Parameters

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"
Clone this wiki locally