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

Below is a brief outline of the different elements you will encounter in the source code as you develop your control system.

Notation

Just a quick note on some notation that has been used throughout the code.

Coordinate Frames

NED Frame - North, East, Down

These are referred to as N, E, and D positions, these are local distance in [m] from the center of lake lag. Note: D is a downward position, therefore you altitude above lake lag is -D.

The following variables that you can access are defined in the NED Frame:

// velocities in the NED frame [m/s]
float vel_N
float vel_E
float vel_D

// local position in NED frame [m] from center of lake lag
float position_N
float position_E
float position_D_gps 		// note: this is down, so altitude above ground is a negative value
float position_D_baro 		// note: this is down, so altitude above ground is a negative value

IJ - i, j

These are the grid coordinates within the grid that represents the lake for fire purposes. i is the row, and j is the column. The grid is aligned with the cardinal directions, meaning that the row number (i) increases as you travel South and the column number (j) increases as you travel East.

Body Frame - x,y,z and u,v,w

These are the body frame coordinates. This applies to the body acceleration and body velocity variables. This is a frame attached to the vehicle body, meaning it rolls, yaws and pitches with the vehicle.

The following variables that you can access are defined in the Body Frame:

// body velocities [m/s]
float speed_body_u
float speed_body_v
float speed_body_w

// body accelerations [m/s^2]
float accel_body_x
float accel_body_y
float accel_body_z

Euler Angles

The roll, pitch and yaw angles are defined using the Tait-Bryan convention (3-2-1 rotation) which is typical for aircraft dynamics. The Euler angles are defined in radians, and the rates are defined in radians/sec.

The following variables that you can access contain the Euler angle and rate information:

// Tait-Bryan Euler angles in radian
float roll		// -pi .. pi
float pitch		// -pi/2 .. pi/2
float yaw		// -pi .. pi

// angular rates, Tait-Bryan NED [rad/s]
float roll_rate
float pitch_rate
float yaw_rate

File Structure

The PX4 firmware is built on a linux based real-time operating system known as NuttX. On top of this system runs a collection of applications known as 'modules' that contain all the code needed to run the autopilot. All the modules are located in firmware/src/modules including the 2 modules that have been created for you to write your control system.

The 2 modules of interest to you are aa241x_high and aa241x_low. The naming convention stems from the fact that each application runs with a different priority in NuttX, therefore we have provided you with one high priority module and one low priority module.

High Priority Module

The following files are helper files that should not be edited:

  • aa241x_high_aux.h
    • This file contains the declaration of all the variables you have access to in your code.
    • Descriptions of the variables can also be found in this file, so if you are unsure as to the bounds, meaning, etc of a variable please check this file.
  • aa241x_high_aux.cpp
    • Contains the initial defintion of all common varibles you have access to.
  • aa241x_high_main.cpp
    • This file is a wrapper around your control law to make sure that it correctly runs.
    • Handles the setting of common variables and communication with the low priority thread.

The following files are for your control law code and can be edited:

  • aa241x_control_law.cpp
    • This is where you will write your control law (specifically in the void flight_control() {} function).
  • aa241x_high_struct.h
    • Contains the definition of the aa241x_high_data_s struct.
  • aa241x_high_params.c
    • Contains definition of parameters and functions required to initialize and update parameters.
  • aa241x_high_params.h
    • Contains the defintion of structs required to hold the parameter information.
  • module.mk
    • makefile for the module, must contain all the source files to be compiled for the module.

Low Priority Module

The low priority modules has the exact same structure as the high priority module. The main difference is that is runs with a lower priority than the high priority module.

Clone this wiki locally