Firmware Modules
Software
EDFs
Servos
Motor Controllers
Sensors
Power Sources

Accelerometer X: 0.5553765 Y: 0.0127444 Z: -0.568222

Gyroscope X: 0.5553765 Y: 0.0127444 Z: -0.568222

Barometric Pressure altitude: 233.7555 ft

Ultrasonic distance: 205.25552 mm

Magnetometer heading: 45.557

Flight Status: Stage: Startup System Health: Operational

Peripheral Status: Accelerometer: Operational Gyroscope: Operational Barometric Pressure: Operational Ultrasonic: Faulty Magnetometer: Disconnected

Motor Status: Motor 1: Operational Motor 2: Operational Motor 3: Operational Motor 4: Operational

Servo Status: Servo X: Operational Servo Y: Operational Servo L: Disconnected Servo R: Disconnected

Motor 1 Power: 10%

Motor 3 Power: 11%

Motor 2 Power: 12%

Motor 4 Power: 10%

Servo X Angle: 90

Servo Y Angle: 95

Servo L Angle: N/A

Servo R Angle: N/A

command injection:

Logs: ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Accelerometer Graph (X, Y, Z)

Altitude Graph

Acc / Gyro
Compass
Altitude
Ultrasonic

I2C Bus Initialization

Initialize

Accelorometer Get X

Gyroscope Get Z

Gyroscope Get X

Accelorometer Get Y

Accelorometer Get Z

Gyroscope Get Y

Set Altitude

Get Altitude

Altitude Activate

Altitude Deactivate

Get Heading (in degrees)

Get Distance (in mm)

Set Heading (in degrees)

Compass Activate

MPU6050 (accel / gyro)

Accelorometer Set X

BMP280 (Pressure)

Accelorometer Set Z

Gyroscope Set X

QMC5883L (compass)

HCSR04 (ultrasonic)

Accelorometer Set Y

Read sensor

Read sensor

Compass Deactivate

if(mpu is active)

Read sensor

if(bmp is active)

Read sensor

if(error) error_count++

if(error) error_count++

if(error) error_count++

if(error) error_count++

Accelorometer Activate

Accelorometer Deactivate

#define MAX_ERROR_COUNT

int error_count = 0

Ultrasonic Activate

Ultrasonic Deactivate

sensor manager task

Reboot Devices

if(qmc is active)

if(hcsr is active)

Gyroscope Set Z

Gyroscope Set Y

Gyroscope Deactivate

Gyroscope Activate

while(error_count < MAX_ERROR_COUNT)

while(true) // loop forever

NOTE The sensor manager task will make sure that the I2C bus is up and running and that all sensors are properly functioning.. It will then be used to constantly read from sensors (when told to)

Public Methods
Servos
update_edf_power
EDFs

while (True)

xSemaphoreTake(edf_lock)

while (edf_needs_updated())

if (edf1_power != edf1_target_power)

actuator_control_interface_set_tvc_x(double _x)

actuator_control_interface_set_tvc_y(double _y)

actuator_control_interface_calibrate_tvc_x_min(uint8_t _deg)

actuator_control_interface_calibrate_tvc_x_max(uint8_t _deg)

else

edf1_power -= edf1_rate

if(edf1_power > edf1_target_power)

edf1_power = edf1_target_power

if(edf1_power < edf1_target_power)

edf1_power += edf1_rate

if (edf2_power != edf2_target_power)

if (edf3_power != edf3_target_power)

if (edf4_power != edf4_target_power)

Note: this method will simply return if any of the edf power(s) don't equal their target value

This is being abstracted to a method for code readability

if(edf1_power < edf1_target_power)

edf1_power = edf1_target_power

set_pwm

actuator_control_interface_set_aileron_l(double _l)

actuator_control_interface_set_aileron_r(double _r)

actuator_control_interface_calibrate_tvc_y_min(uint8_t _deg)

actuator_control_interface_calibrate_tvc_y_max(uint8_t _deg)

actuator_control_interface_calibrate_aileron_l_min(uint8_t _deg)

actuator_control_interface_calibrate_aileron_l_max(uint8_t _deg)

actuator_control_interface_calibrate_aileron_r_min(uint8_t _deg)

actuator_control_interface_calibrate_aileron_r_max(uint8_t _deg)

actuator_control_interface_soft_set_edf_1(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_2(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_3(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_4(uint8_t power, uint8_t rate)

actuator_control_interface_set_edf_1(uint8_t power)

actuator_control_interface_set_edf_2(uint8_t power)

actuator_control_interface_set_edf_3(uint8_t power)

actuator_control_interface_set_edf_4(uint8_t power)

Core Switch Logic
Mission Queue
Always Ran

send sensor data every 100 ms

send actuator data every 100 ms

create vTask

mission_control_initiate(task_priority)

_task(void *params)

mission_control_handle_command(cJSON *json)

Should be startup function

Things that need to always happen continuously

UAV State

STATE_IDLE STATE_MODULE_STARTUP STATE_MODULE_CORE STATE_MODULE_TEARDOWN

switch(UAV STATE)

STATE_IDLE

check if there's something in the mission queue

run current_mission->startup_fun

pop mission from queue

set current_mission

set UAV STATE -> STATE_MODULE_STARTUP

run current_mission->teardown_fun

set UAV_STATE -> STATE_MODULE_IDLE

STATE_MODULE_TEARDOWN

calibrate sensors

turn on all sensors

while (true)

STATE_MODULE_STARTUP

set UAV_STATE -> STATE_MODULE_TEARDOWN

set UAV STATE -> STATE_MODULE_CORE

STATE_MODULE_CORE

run current_mission->core_fun

if (current_mission->completed)

sleep(10)

mission queue

mission struct ![[Mission Control#mission_t]]

...

...

Static Variables ![[Mission Control#Static Variables]]

Functional Requirements

  • Flight Data
    • Flight stage
    • Full system health status
      • Operational
      • Minor error
      • Fatal error
  • Network Status
    • View Network Connection Status
      • Connected
      • Not Connected
    • View time since last network packet was received
      • Example 20ms
  • Peripheral Data
    • Note:
      • Health status will be broken down into:
        • Operational
        • Disconnected
        • Faulty
    • View Accelorometer Data
      • Health status
      • Activation state
      • x,y,z
    • View Gyroscope Data
      • Health status
      • Activation state
      • x,y,z
    • View Barometric Pressure Data
      • Health status
      • Activation state
      • altitude
    • View Magnetometer Data
      • Health status
      • Activation state
      • heading
    • View Ultrasonic Sensor Data
      • Health status
      • Activation state
      • distance in mm
  • Actuator Data
    • View Motor data x4
      • Health status
      • Power percentage
    • View servo data x4
      • Health status
      • Angle
  • System Data
    • System needs to be capable of uniquely identifying connection
    • System needs to be capable of verifying firmware version

Transferred Data

This contains information pertaining to what data is actually transmitted and received to and from the UAV over the wireless connection.


Estimated Total Unique Messages: 46

Received Data (from the UAV)

logging

  • debug
  • info
  • error
  • fatal

peripheral

managed by AACS > Sensor Control Interface

  • accelorometer:
    • x
    • y
    • z
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • gyroscope:
    • x
    • y
    • z
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • altimeter
    • altitude
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • magnetometer
    • heading
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • ultrasonic
    • distance
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated

actuator

managed by AACS > Actuator Control Interface

  • motor 1
    • status : operational, faulty, disconnected
    • power percent
  • motor 2
    • status : operational, faulty, disconnected
    • power percent
  • motor 3
    • status : operational, faulty, disconnected
    • power percent
  • motor 4
    • status : operational, faulty, disconnected
    • power percent
  • servo 1
    • status : operational, faulty, disconnected
    • angle
  • servo 2
    • status : operational, faulty, disconnected
    • angle
  • servo 3
    • status : operational, faulty, disconnected
    • angle
  • servo 4
    • status : operational, faulty, disconnected
    • angle

flight data

managed by AACS > Master Control Interface

  • flight stage
  • overall system health
  • ready to enter launch stage
  • ready to enter target acquisition stage
  • ready to enter stealth surveillance stage
  • ready to enter vehicle extraction stage
  • ready to enter landing stage

Transmitted Data (to the UAV)

UI Design

Transclude of c2-user-interface-design.canvas

System Architecture

Transclude of c2-system-architecture.canvas

C2 Proxy
C2 Web Interface

TCP Socket Handler

Needed

  • Starts a new thread for each connection
  • Every connection is treated like the same device
    • This is to handle situations where the UAV disconnects and reconnects
    • There should only ever be one UAV
  • Command Callback function
  • Send Command function
  • One static socket
    • This is overridden when a new connection is received
      • This way the application is always working with the current connection

Methods

  • socket_handler_init(receive_message_callback_function)
    • Starts up a new thread
  • socket_handler_send(String)

Variables

  • static : socket

WebSocket Handler

Command Manager

WebSocket Client

Command Handler

Control Panel

UAV TCP Client

Mission Planner

MPU6050

Aileron R

TVC X

TVC Y

Aileron L

BMP280

HMC5883L

SSD1306

EEPROM

Advanced Avionics Control System

Processor : RP2040 (Raspberry Pi Pico W)
OS : FreeRTOS


Sensor Control Interface

Transclude of sensor-control-interface.canvas

Variables

There are going to be a set of static variables that contain all of the sensor data. These variables are going to be protected using mutexes since they will be continuously updated via the internal sensor reading task and continuously read through the various “public” methods.

I need to do some research on what formats would be good for using the numbers in (i.e. should accelerator data be a double between 1 and -1 or is it better represented as an unsigned or signed int?)

C2 Communication

Documentation for what all the C2 server needs can be found here


UML

classDiagram
	class sensor_control_interface{
		- double accelorometer_x;
		- double accelorometer_y;
		- double accelorometer_z;
		- double gyroscope_x;
		- double gyroscop_y;
		- double gyroscop_z;
		- double altitude;
		- double heading;
		- double us_distance;

		- SemaphoreHandle_t mpu_mutex;
		- SemaphoreHandle_t bmp_mutex;
		- SemaphoreHandle_t qmc_mutex;
		- SemaphoreHandle_t hcsr_mutex;

		- int sensor_error_count;
		+ sensor_control_interface_init(UBaseType_t sensor_task_priority): int
		+ sensor_control_interface_get_accelorometer_x(): double
		+ sensor_control_interface_get_accelorometer_y(): double
		+ sensor_control_interface_get_accelorometer_z(): double
		+ sensor_control_interface_set_accelorometer_x(double _x): void
		+ sensor_control_interface_set_accelorometer_y(double _x): void
		+ sensor_control_interface_set_accelorometer_z(double _z): void
		+ sensor_control_interface_accelerometer_activate(): int
		+ sensor_control_interface_accelerometer_deactivate(): int
		+ sensor_control_interface_get_gyroscope_x(): double
		+ sensor_control_interface_get_gyroscope_y(): double
		+ sensor_control_interface_get_gyroscope_z(): double
		+ sensor_control_interface_set_gyroscope_x(double _x): void
		+ sensor_control_interface_set_gyroscope_y(double _x): void
		+ sensor_control_interface_set_gyroscope_z(double _z): void
		+ sensor_control_interface_gyroscope_activate(): int
		+ sensor_control_interface_gyroscope_deactivate(): int
		+ sensor_control_interface_get_altimeter_altitude(): double
		+ sensor_control_interface_set_altimeter_altitude(double _altitude): int
		+ sensor_control_interface_altimeter_activate(): int
		+ sensor_control_interface_altimeter_deactivate(): int
		+ sensor_control_interface_get_compass_heading(): double
		+ sensor_control_interface_set_compass_heading(double _heading): int
		+ sensor_control_interface_compass_activate(): int
		+ sensor_control_interface_compass_deactivate(): int
		+ sensor_control_interface_get_ultrasonic_distance(): double
		+ sensor_control_interface_set_ultrasonic_distance(double _distance): int
		+ sensor_control_interface_ultrasonic_activate(): int
		+ sensor_control_interface_ultrasonic_deactivate(): int
		+ sensor_control_interface_reset_mpu_6050(): int
		+ sensor_control_interface_reset_bmp_280(): int
		+ sensor_control_interface_reset_qmc _5883l(): int
		+ sensor_control_interface_reset_hc_sr04(): int
		+ sensor_control_interface_task(): int
	}

Public Methods

General

sensor_control_interface_init

Accelerometer

Getters:
sensor_control_interface_get_accelerometer_x
sensor_control_interface_get_accelerometer_y
sensor_control_interface_get_accelerometer_z
Setters:
sensor_control_interface_set_accelerometer_x
sensor_control_interface_set_accelerometer_y
sensor_control_interface_set_accelerometer_z
Activators:
sensor_control_interface_accelerometer_activate
sensor_control_interface_accelerometer_deactivate

Gyroscope

Getters:
sensor_control_interface_get_gyroscope_x
sensor_control_interface_get_gyroscope_y
sensor_control_interface_get_gyroscope_z
Setters:
sensor_control_interface_set_gyroscope_x
sensor_control_interface_set_gyroscope_y
sensor_control_interface_set_gyroscope_z
Activators:
sensor_control_interface_gyroscope_activate
sensor_control_interface_gyroscope_deactivate

Altimeter

Getters:
sensor_control_interface_get_altimeter_altitude
Setters:
sensor_control_interface_set_altimeter_altitude
Activators:
sensor_control_interface_altimeter_activate
sensor_control_interface_altimeter_deactivate

Compass

Getters:
sensor_control_interface_get_compass_heading
Setters:
sensor_control_interface_set_compass_heading
Activators:
sensor_control_interface_compass_activate
sensor_control_interface_compass_deactivate

Ultrasonic

Getters:
sensor_control_interface_get_ultrasonic_distance
Setters:
sensor_control_interface_set_ultrasonic_distance
Activators:
sensor_control_interface_ultrasonic_activate
sensor_control_interface_ultrasonic_deactivate

Internal Methods

Threading

sensor_control_interface_task

Error Handling

sensor_control_interface_reset_mpu_6050
sensor_control_interface_reset_bmp_280
sensor_control_interface_reset_qmc _5883l
sensor_control_interface_reset_hc_sr04

Actuator Control Interface

Transclude of actuator-control-interface.canvas

Diagrams

int calculatePowerChange(int currentPower, int targetPower, int rateOfChange) {
    // Ensure rateOfChange is within the valid range (1-100)
    rateOfChange = max(1, min(100, rateOfChange));
 
    // Calculate the remaining difference between currentPower and targetPower
    int remainingDifference = targetPower - currentPower;
 
    // Calculate the adder/subtractor for the given rate of change
    int change = (remainingDifference * rateOfChange) / 100;
 
    // Ensure a minimum change to prevent very slow transitions
    change = max(change, MIN_CHANGE);  // Adjust MIN_CHANGE as needed
 
    return change;
}
 

C2 Communication

Documentation for what all the C2 server needs can be found here

Master Control Interface

The master_control_interface is responsible for high level control over the UAV.

C2 Communication

Documentation for what all the C2 server needs can be found here

EDF 1

EDF 2

EDF 3

ARM-M0+

EDF 4

37v

7.4v

3.3v linear regulator

ESC

ESC

ESC

ESC

Wireless ConnectionI2CI2CI2C