Skip to content

Title #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 53 commits into
base: sids_branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
3e119a2
Added imu i2c code
asaridena Feb 10, 2023
631fe85
Delete imu_i2c.ino
asaridena Feb 10, 2023
f046ea1
Update README.md
dtowle17 Aug 9, 2023
5882bad
Reorganization and updated ReadMe
dtowle17 Sep 3, 2023
ba736d1
Added Logo To ReadMe
dtowle17 Sep 3, 2023
948fb08
Readme Update
dtowle17 Sep 3, 2023
0f782bb
ReadMe Update
dtowle17 Sep 3, 2023
43bf0bb
Readme Update
dtowle17 Sep 3, 2023
8274f81
Readme update
dtowle17 Sep 3, 2023
b073162
Updated Readme
dtowle17 Sep 3, 2023
8dda822
ReadMe Update
dtowle17 Sep 3, 2023
afa1cb7
Updated ReadMe
dtowle17 Sep 3, 2023
afd6dd7
Updated ReadMe
dtowle17 Sep 3, 2023
9830c83
Readme Update and Reorganization
dtowle17 Sep 3, 2023
2df87a3
Updated README
dtowle17 Sep 3, 2023
ab0852d
converted to platformio project
vpalmerio Oct 21, 2023
f930b94
updated gitignore to remove .pio
vpalmerio Oct 21, 2023
953ba83
Added file and header for all driver errors
vpalmerio Oct 24, 2023
7072a1c
Added error header for all driver errors
vpalmerio Oct 31, 2023
13d4f11
Created IMU driver header and cpp
vpalmerio Oct 31, 2023
7074310
Reorganized platformio project to exist within library folder
vpalmerio Oct 31, 2023
8b4efa6
Added include guards to LSM6DS_LIS3MDL header
vpalmerio Nov 2, 2023
6d75169
Created loadCalibration() to load predetermined calibration values, m…
vpalmerio Nov 4, 2023
b937cdc
Changed NO_CALIBRATION_FOUND error to FAILED_LOAD_CALIBRATION
vpalmerio Nov 4, 2023
0938b3b
Changed sensor to correct type and added docstring
vpalmerio Nov 4, 2023
66ef462
Added link to LSM6DS_LIS3MDL.h original source
vpalmerio Nov 4, 2023
55c6a0e
Added docstring to IMU.cpp and IMU.h
vpalmerio Nov 4, 2023
da00026
Removed unused variables in IMU.h
vpalmerio Nov 4, 2023
42414fa
Changed setupIMU to initalizeIMU to match naming scheme
vpalmerio Nov 4, 2023
5b00e1f
Fixed test to use initalizeIMU()
vpalmerio Nov 4, 2023
73a3ee5
calibration is no longer loaded into EEPROM every startup
vpalmerio Nov 7, 2023
9ef82ef
Removed unused files
vpalmerio Nov 7, 2023
1da7099
Restructured IMU library for proper organization
vpalmerio Nov 11, 2023
e8cb60f
Updated .DS_Store
vpalmerio Nov 11, 2023
6540530
Removed unnecessary files
vpalmerio Nov 11, 2023
36c3a98
loadPresetCalibration() returns an error
vpalmerio Nov 12, 2023
1daa6f9
Added .vscode to gitignore
vpalmerio Nov 12, 2023
64d4f13
Removed .vscode from git
vpalmerio Nov 12, 2023
166d666
Added IMU calibration values to IMU.cpp
vpalmerio Nov 20, 2023
003df51
Merge pull request #2 from activecontrols/vincent-imu-driver
vpalmerio Nov 20, 2023
db3e8fe
Fixed spelling of initializeIMU function
vpalmerio Nov 23, 2023
3035196
Added .DS_Store to git ignore
vpalmerio Nov 24, 2023
9f09f56
Fixed memory leak in IMU and Buffer integration
vpalmerio Nov 24, 2023
a6768f8
Created proper debugging println's for IMU's fusion and raw values
vpalmerio Nov 24, 2023
8bda1c0
Removed .DS_Store files
vpalmerio Nov 24, 2023
63945a2
IMU.h now has external filtered linear acceleration values
vpalmerio Nov 29, 2023
de8140e
Added linearAccelVector to IMU lib
vpalmerio Dec 2, 2023
20cb4f9
Added and updated docstrings for most files
vpalmerio Dec 3, 2023
407f4a4
Made changes to getValues in IMU.cpp
Squidolina Jan 11, 2024
3b5288b
Merge pull request #3 from activecontrols/hover_test
vpalmerio Jan 17, 2024
d1e678c
Merge branch 'sids_branch' into main
Squidolina Jan 17, 2024
5ee7eaa
Merge pull request #5 from activecontrols/Avionics
vpalmerio Jan 20, 2024
43b9835
Create README.md for IMU driver
vpalmerio Apr 13, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

.vscode/settings.json
.pio
.DS_Store
19 changes: 0 additions & 19 deletions .vscode/c_cpp_properties.json

This file was deleted.

5 changes: 5 additions & 0 deletions ASTRA/IMU/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# PLEASE READ

This code is for the driver of the IMU. The structure used to be that this github repository was a submodule of the ASTRAFlightSoftware Repository.
However, this caused confusion among new developers on how to actually update the IMU driver. We no longer use this submodule structure, and thus, the code
for the IMU in this repository is unused and out of date. It is kept here only for old branches in ASTRAFlightSoftware. Do not use this code for any other reason.
3 changes: 3 additions & 0 deletions ASTRA/IMU/include/LSM6DS_LIS3MDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
LSM6DS_LIS3MDL.h
Description: Header file for sensor-setup function definitions
Author: Vincent Palmerio, (Original: https://github.com/adafruit/Adafruit_AHRS/blob/master/examples/calibrated_orientation/calibrated_orientation.ino)


Last updated: 11/4/2023

*/

#ifndef LSM6DS_LIS3MDL
Expand Down
45 changes: 34 additions & 11 deletions ASTRA/IMU/src/IMU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@
IMU.cpp
Description: Function definititions for declarations in IMU.h
Author: Vincent Palmerio
Last updated: 11/4/2023

*/

float roll, pitch, heading = 0;

Eigen::VectorXd linearAccelVector(3);
float linearAccelX, linearAccelY, linearAccelZ = 0;
float roll, pitch, yaw = 0;
float gx, gy, gz = 0; //degrees per second on gyro
float qw, qx, qy, qz = 0; //quaternarion

float* getValues() {
float* values = (float*)malloc(3 * sizeof(float));
values[0] = roll;
values[1] = pitch;
values[2] = yaw;
return values;
}


//loads a predetermined calibration into the EEPROM
int loadPresetCalibration() {
//Magnetic Hard Offset
Expand Down Expand Up @@ -44,10 +56,16 @@ int loadPresetCalibration() {
}


int initalizeIMU() {

int initializeIMU() {
Serial.begin(115200);
while (!Serial) yield();

for (int i = 0; i < linearAccelVector.size(); i++) {
linearAccelVector(i) = 0;
}


if (!cal.begin()) {
//Failed to initialize calibration helper
#if defined(ASTRA_FULL_DEBUG) or defined(ASTRA_IMU_DEBUG)
Expand Down Expand Up @@ -101,9 +119,10 @@ int updateIMU() {

// Gyroscope needs to be converted from Rad/s to Degree/s
// the rest are not unit-important
gx = gyro.gyro.x * SENSORS_RADS_TO_DPS;
gy = gyro.gyro.y * SENSORS_RADS_TO_DPS;
gz = gyro.gyro.z * SENSORS_RADS_TO_DPS;

gx = gyro.gyro.x; //* SENSORS_RADS_TO_DPS; //omega x
gy = gyro.gyro.y; //* SENSORS_RADS_TO_DPS; //omega y
gz = gyro.gyro.z; //* SENSORS_RADS_TO_DPS; //omega z

// Update the SensorFusion filter
filter.update(gx, gy, gz,
Expand All @@ -113,19 +132,22 @@ int updateIMU() {
// print the heading, pitch and roll
roll = filter.getRoll();
pitch = filter.getPitch();
heading = filter.getYaw();
yaw = filter.getYaw();


//float qw, qx, qy, qz;
filter.getQuaternion(&qw, &qx, &qy, &qz);


#if defined(ASTRA_FULL_DEBUG) or defined(ASTRA_IMU_DEBUG)
filter.getLinearAcceleration(&linearAccelX, &linearAccelY, &linearAccelZ); //"a" - linear acceleration

Serial.print("I2C took "); Serial.print(millis()-timestamp); Serial.println(" ms");
linearAccelVector << linearAccelX, linearAccelY, linearAccelZ;

Serial.print("Update took "); Serial.print(millis()-timestamp); Serial.println(" ms");
#if defined(ASTRA_FULL_DEBUG) or defined(ASTRA_IMU_DEBUG)

//Serial.print("I2C took "); Serial.print(millis()-timestamp); Serial.println(" ms");

//Serial.print("Update took "); Serial.print(millis()-timestamp); Serial.println(" ms");
Serial.print("Raw: ");
Serial.print(accel.acceleration.x, 4); Serial.print(", ");
Serial.print(accel.acceleration.y, 4); Serial.print(", ");
Expand All @@ -152,7 +174,8 @@ int updateIMU() {
Serial.print(qy, 4);
Serial.print(", ");
Serial.println(qz, 4);
Serial.print("Took "); Serial.print(millis()-timestamp); Serial.println(" ms");
//Serial.print("Took "); Serial.print(millis()-timestamp); Serial.println(" ms");

#endif


Expand Down
16 changes: 14 additions & 2 deletions ASTRA/IMU/src/IMU.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
IMU.h - Header file for the IMU Driver
Description: Contains all functions and variables to interact with the IMU
Author: Vincent Palmerio

Last updated: 11/4/2023

*/

#ifndef IMU_H
Expand All @@ -16,6 +18,9 @@ Last updated: 11/4/2023
#include <Adafruit_Sensor_Calibration.h>
#include <Adafruit_AHRS.h>


#include <ArduinoEigenDense.h>

//uncomment to print data to console for just IMU
//#define ASTRA_IMU_DEBUG

Expand Down Expand Up @@ -43,16 +48,23 @@ Last updated: 11/4/2023
//#define AHRS_DEBUG_OUTPUT


extern float roll, pitch, heading;
extern float* values;
extern float roll, pitch, yaw;
extern Eigen::VectorXd linearAccelVector;
extern float linearAccelX, linearAccelY, linearAccelZ;

extern float gx, gy, gz; //degrees per second on gyro
extern float qw, qx, qy, qz; //quaternarion

// slower == better quality output
static Adafruit_NXPSensorFusion filter; // slowest

extern int initalizeIMU();

extern int initializeIMU();
extern int updateIMU();
extern int loadPresetCalibration();
extern float* getValues();


#endif

Expand Down
2 changes: 2 additions & 0 deletions ASTRA/error/DriverError.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
DriverError.h - Error Header/Constants File for Drivers
Description: Error Constants for all Driver Errors that occur
Author: Vincent Palmerio

Created: 10/2/2023
Last updated: 10/2/2023

*/

#ifndef DRIVER_ERROR_H
Expand Down
2 changes: 2 additions & 0 deletions ASTRA/testing/IMU_Debug/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ board = teensy41
framework = arduino
lib_extra_dirs = ../../IMU
lib_deps =

hideakitai/ArduinoEigen@^0.3.0
adafruit/Adafruit LSM6DS@^4.7.0
adafruit/Adafruit LIS3MDL@^1.2.1
adafruit/Adafruit AHRS@^2.3.3
Expand Down
60 changes: 57 additions & 3 deletions ASTRA/testing/IMU_Debug/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,65 @@
#include "../../../IMU/src/IMU.h"


/*
main.cpp
Description: Main file for running testing code for the IMU driver
Author: Vincent Palmerio
*/

Adafruit_LSM6DSOX sox;

void setup() {
initalizeIMU();
initializeIMU();

if (!sox.begin_I2C()) {
// if (!sox.begin_SPI(LSM_CS)) {
// if (!sox.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) {
// Serial.println("Failed to find LSM6DSOX chip");
while (1) {
delay(10);
}
}
}

void loop() {

updateIMU();
Serial.print("test");
Serial.print(heading);
Serial.print("Fusion values: ");
Serial.print(yaw);
Serial.print(" ");
Serial.print(roll);
Serial.print(" ");
Serial.print(pitch);
Serial.println();


sensors_event_t accel;
sensors_event_t gyro;
sensors_event_t temp;
sox.getEvent(&accel, &gyro, &temp);

Serial.print(millis(),7);
Serial.print(",");

Serial.print(temp.temperature,7);
Serial.print(",");

/* Display the results (acceleration is measured in m/s^2) */
Serial.print(accel.acceleration.x,7);
Serial.print(",");
Serial.print(accel.acceleration.y,7);
Serial.print(",");
Serial.print(accel.acceleration.z,7);
Serial.print(",");

/* Display the results (rotation is measured in rad/s) */
Serial.print(gyro.gyro.x,7);
Serial.print(",");
Serial.print(gyro.gyro.y,7);
Serial.print(",");
Serial.print(gyro.gyro.z,7);
Serial.println();


}
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
# Avionics
![Logo](https://purdueseds.space/wp-content/uploads/2022/02/PSP-ActiveControls-1Color-White.svg)

# Active Controls Avionics Repository

Welcome to the AC Avionics Repository!

This Repo is organized into the following project folders:
ASTRA, DAQ, Ground_Station, and Lander

Most folders in this repository will have two subfolders: /lib and /src
### /lib
This folder is used for libraries and dependencies associated with the code in /src.
### /src
This folder is used for storing c++ files.

## ASTRA
This folder holds all low-level code associated with the ASTRA project.

### /IMU
This folder is dedicated to IMU drivers
### /Barometer
This folder is dedicated to Barometer drivers
### /ESC
This folder is dedicated to ESC drivers
### /BMS
This folder is dedicated to BMS drivers
### /error
This folder is associated with the error codes that can occur on any drivers. It is meant to be an easy look up for all driver error codes.

## DAQ
This folder holds all code associated with test stands and setups that require data aquisition.

### /Loadcell
This folder is dedicated to the -Insert Model Here- Loadcell
### /Thrust_Stand
This folder is dedicated to the Thrust Stand
### /Torque_Stand
This folder is dedicated to the Torque Stand
### /Mag_Encoders
This folder is dedicated to magnetic encoders

## Ground_Station
This folder holds all code associated with the Ground Base Station.

## Lander
This folder holds all low-level code associated with the Lander project.
20 changes: 0 additions & 20 deletions lib/HX711-master/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions lib/HX711-master/.travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions lib/HX711-master/CMakeLists.txt

This file was deleted.

20 changes: 0 additions & 20 deletions lib/HX711-master/CONTRIBUTORS.md

This file was deleted.

Loading