Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b598175
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Jshepherd06 Oct 1, 2025
8bb12a4
feat: add fastlaunchdetector header and update implimentation
Jshepherd06 Oct 15, 2025
46e26c9
feat: added FastLaunchDetector update checks: already_launched, acl_t…
Jshepherd06 Oct 15, 2025
5583974
feat: added FastLaunchDetector reset()
Jshepherd06 Oct 15, 2025
1357657
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Jshepherd06 Oct 15, 2025
89409f2
fix: default fail added to update
Jshepherd06 Oct 15, 2025
0474a35
feat: add soft ascent state in StateMachine with FLD checking and LD …
Jshepherd06 Oct 29, 2025
b034453
add confirmation window to fld constructor and soft ascent comments
Jshepherd06 Oct 29, 2025
f37acf2
fix: statemachine resets fldLaunchTime_ms after no launch confirmation
Jshepherd06 Oct 29, 2025
6a92f7d
add clearpostlaunchmode default implementation and reset fld in state…
Jshepherd06 Oct 29, 2025
b4ddaea
fix: change states order for better testing
Jshepherd06 Nov 5, 2025
e0bab9d
Merge Basesm
Jshepherd06 Nov 5, 2025
f212b3f
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Jshepherd06 Nov 19, 2025
8c47c07
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Jshepherd06 Nov 19, 2025
dc008da
it Merge branch 'main' of https://github.com/CURocketEngineering/Avio…
Jshepherd06 Dec 3, 2025
24208dc
make statemachine STATE update flow more natural
Jshepherd06 Dec 3, 2025
1bc8111
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Jshepherd06 Jan 27, 2026
2cbc954
Merge branch 'fastlaunchdetector' of https://github.com/CURocketEngin…
Jshepherd06 Jan 27, 2026
9060f2e
chore: add clang-tidy workflow
Elan456 Jan 28, 2026
ee2d6b1
ref: resolve clang-tidy warnings for GLE
Elan456 Jan 28, 2026
5717ce1
ref: address clang-tidy warnings for ApogeePredictor
Elan456 Jan 28, 2026
3a44b86
ref: address clang-tidy warnings for BurnoutStateMachine
Elan456 Jan 28, 2026
7e72c0a
feat: make alpha a construction parameter for GLE
Elan456 Jan 28, 2026
e791391
feat: remove magic numbers from telemetry and utilize arrays for leng…
Elan456 Jan 29, 2026
a6e727c
Merge branch 'main' of https://github.com/CURocketEngineering/Avionic…
Elan456 Jan 29, 2026
22e5978
feat: CircularArray must be declared with size template parameter
Elan456 Jan 29, 2026
0da1c8b
fix:change handshake hex value to avoidoverlap
Jshepherd06 Jan 29, 2026
d59ed42
merge commit
Jshepherd06 Jan 29, 2026
1878a63
Merge branch 'fastlaunchdetector' of https://github.com/CURocketEngin…
Jshepherd06 Jan 29, 2026
05ca668
revert sim changes and change logic in statemachine
Jshepherd06 Jan 29, 2026
51561d5
Update CSV file path for data collection
Jshepherd06 Jan 29, 2026
9866ac4
Merge pull request #48 from CURocketEngineering/fastlaunchdetector
Elan456 Jan 30, 2026
c864387
Merge branch 'chore/clang-tidy-workflow' of https://github.com/CURock…
Elan456 Jan 30, 2026
8dab501
Merge branch 'feat/static-circular-array' of https://github.com/CURoc…
Elan456 Jan 30, 2026
cf148ac
chore: clang-tidy minor adjustments to CircularArray and FLD
Elan456 Jan 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Clang-Tidy Check

on:
#triggers the workflow on pull requests
pull_request:
branches:
- '**'

#allows manual triggering of the workflow
workflow_dispatch:

jobs:
clang-tidy-check:
runs-on: ubuntu-latest

steps:
#gets the current repo
- name: Checkout Avionics repo
uses: actions/checkout@v4
with:
path: Avionics

#clones the native repo
- name: Clone Native repo
run: |
git clone https://github.com/CURocketEngineering/Native native

#replaces the linked Avionics repo with the current Avionics code
- name: Replace Native lib Avionics with checked-out Avionics code
run: |
rm -rf native/lib/Avionics
mkdir -p native/lib
mv Avionics native/lib/Avionics

#installed PlatformIO core
- name: Install PlatformIO Core
run: |
pip install -U platformio

#shows the file tree structure for debugging
- name: Show native directory structure
run: |
echo "===== native directory tree ====="
ls -R native

#runs clang-tidy check
- name: Run Clang-Tidy Check
working-directory: ./native
run: pio check --fail-on-defect=low --fail-on-defect=medium --fail-on-defect=high


22 changes: 9 additions & 13 deletions hal/ArduinoHAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@

#ifdef ARDUINO
#include "Arduino.h"
#include <SPI.h>
#include <Adafruit_Sensor.h>

#include <Adafruit_SPIFlash.h>
#include <Adafruit_Sensor.h>
#include <SdFat.h>
#include <SdFatConfig.h>
#include <SPI.h>

#else // Everything below will only be compiled if we are not on an Arduino

#include <string>
using String = std::string;

#include <iostream>
#include <cstring>

#include <chrono>

#include "spi_mock.h"

// Within here we must define the mock functions for the Arduino functions
#include <cstring>
#include <iostream>
#include <string>
#include <thread>

#include "Adafruit_SPIFlash_mock.h"
#include "serial_mock.h"
#include "spi_mock.h"

using String = std::string;

#define OUTPUT 1
#define INPUT 0
Expand Down Expand Up @@ -55,4 +51,4 @@ inline void delay(unsigned long ms) { // NOLINT


#endif // ARDUINO
#endif // ARDUINOHAL_H
#endif // ARDUINOHAL_H
68 changes: 36 additions & 32 deletions include/data_handling/CircularArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
#define CIRCULARARRAY_H

#include <algorithm>
#include <array>
#include <assert.h>
#include <cstdint>
#include <vector>

template<typename T>
int partition(std::vector<T>& array, int left, int right, int pivotIndex) {
constexpr std::size_t MAX_CIRCULAR_ARRAY_CAPACITY = 255;

template<typename T, std::size_t N>
int partition(std::array<T, N>& array, int left, int right, int pivotIndex) {
T pivotValue = array[pivotIndex];
std::swap(array[pivotIndex], array[right]); // Move pivot to end
int storeIndex = left;
Expand All @@ -26,8 +29,8 @@ int partition(std::vector<T>& array, int left, int right, int pivotIndex) {
// O(n) average time complexity
// O(n^2) worst case time complexity
// If we were to just use bubble sort, that would be O(n^2) time complexity
template<typename T>
T quickSelect(std::vector<T> &array, int left, int right, int k){
template<typename T, std::size_t N>
T quickSelect(std::array<T, N> &array, int left, int right, int k){
while (left < right){
int pivotIndex = (left + right) / 2;
int pivotNewIndex = partition(array, left, right, pivotIndex);
Expand All @@ -43,46 +46,48 @@ T quickSelect(std::vector<T> &array, int left, int right, int k){
}


template<typename T>
template<typename T, std::size_t Capacity>
/**
* @brief Fixed-size circular buffer with median helper and head tracking.
* @note When to use: maintain a rolling window of recent samples for filters
* or detectors without reallocations.
*/
class CircularArray {
protected:
std::vector<T> array;
uint8_t head; // 0 to 255
std::array<T, Capacity> array;
std::array<T, Capacity> scratchArray; // For median calculation
uint8_t maxSize; // 0 to 255
uint16_t pushCount; // 0 to 65535
uint8_t head; // 0 to 255
uint8_t currentSize; // 0 to 255

public:
CircularArray(uint8_t maxSize){
this->maxSize = maxSize;
CircularArray(uint8_t maxSize = Capacity) : maxSize(maxSize) {
static_assert(Capacity > 0, "CircularArray capacity must be greater than 0");
static_assert(Capacity <= MAX_CIRCULAR_ARRAY_CAPACITY, "CircularArray capacity must be less than or equal to 255 b/c of head being uint8_t");
assert(maxSize > 0 && maxSize <= Capacity);
this->head = 0;
this->pushCount = 0;
this->array = std::vector<T>(maxSize, T());
}

~CircularArray(){
array.clear();
this->currentSize = 0; // How full is the circular buffer?
}

void push(T data){
// After the first push, start moving the head
if (pushCount)
if (currentSize)
head = (head + 1) % maxSize;
array[head] = data;
pushCount++;

// Cap current size at maxSize
if (currentSize < maxSize){
currentSize++;
}
}

T pop(){
if (pushCount == 0){
if (currentSize == 0){
return T();
}
T data = array[head];
head = (head + maxSize - 1) % maxSize;
pushCount--;
currentSize--;
return data;
}

Expand All @@ -93,11 +98,11 @@ class CircularArray {

// Has the circular array been filled
bool isFull(){
return pushCount >= maxSize;
return currentSize >= maxSize;
}

bool isEmpty(){
return pushCount == 0;
return currentSize == 0;
}

uint8_t getHead(){
Expand All @@ -109,28 +114,27 @@ class CircularArray {
}

T getMedian(){
if (pushCount == 0) {
if (currentSize == 0) {
// Handle the case when the array is empty
return T();
}

size_t count = std::min(static_cast<size_t>(pushCount), static_cast<size_t>(maxSize));
std::vector<T> copyArray(count);
size_t count = std::min(static_cast<size_t>(currentSize), static_cast<size_t>(maxSize));

// Collect the valid elements from the circular array
// TODO: Optimize (or just copy everything and restrict this function to only running when the array is full)
for (size_t i = 0; i < count; ++i) {
copyArray[i] = array[(head + maxSize - i) % maxSize];
scratchArray[i] = array[(head + maxSize - i) % maxSize];
}

// Find the median
return quickSelect(copyArray, 0, count - 1, count / 2);
int n = static_cast<int>(count);
return quickSelect(scratchArray, 0, n - 1, n / 2);
}

void clear(){
head = 0;
pushCount = 0;
for (int i = 0; i < maxSize; i++){
currentSize = 0;
for (uint8_t i = 0; i < maxSize; i++){
array[i] = T();
}
}
Expand All @@ -139,4 +143,4 @@ class CircularArray {



#endif
#endif
5 changes: 5 additions & 0 deletions include/data_handling/DataSaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class IDataSaver {
// Default implementation does nothing
}

// default method that does nothing, can be overridden
virtual void clearPostLaunchMode(){
// default implementation does nothing
}

};


Expand Down
Loading