Skip to content

Commit

Permalink
Merge branch 'main' into 432-new-mixing-system
Browse files Browse the repository at this point in the history
  • Loading branch information
JMoore5353 committed Dec 31, 2024
2 parents af4b8da + d16f4ac commit e0a9a7d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion boards/varmint_h7
Submodule varmint_h7 updated 81 files
+0 −168 common/AL94_USB_Composite/App/usb_device.c
+0 −105 common/AL94_USB_Composite/App/usb_device.h
+0 −541 common/AL94_USB_Composite/App/usbd_cdc_acm_if.c
+0 −131 common/AL94_USB_Composite/App/usbd_cdc_acm_if.h
+0 −415 common/AL94_USB_Composite/App/usbd_desc.c
+0 −146 common/AL94_USB_Composite/App/usbd_desc.h
+0 −180 common/AL94_USB_Composite/Class/CDC_ACM/Inc/usbd_cdc_acm.h
+0 −2,175 common/AL94_USB_Composite/Class/CDC_ACM/Src/usbd_cdc_acm.c
+0 −151 common/AL94_USB_Composite/Class/COMPOSITE/Inc/usbd_composite.h
+0 −1,133 common/AL94_USB_Composite/Class/COMPOSITE/Src/usbd_composite.c
+0 −149 common/AL94_USB_Composite/Core/Inc/usbd_core.h
+0 −99 common/AL94_USB_Composite/Core/Inc/usbd_ctlreq.h
+0 −429 common/AL94_USB_Composite/Core/Inc/usbd_def.h
+0 −107 common/AL94_USB_Composite/Core/Inc/usbd_ioreq.h
+0 −673 common/AL94_USB_Composite/Core/Src/usbd_core.c
+0 −928 common/AL94_USB_Composite/Core/Src/usbd_ctlreq.c
+0 −176 common/AL94_USB_Composite/Target/usbd_conf.h
+2 −7 common/CMakeLists.txt
+3 −18 common/CommonConfig.h
+3 −3 common/STM32H7LinkerScript.ld
+90 −90 common/USB_AL94/AL94.I-CUBE-USBD-COMPOSITE_conf.h-ignore
+20 −20 common/USB_AL94/LICENSE.txt
+58 −0 common/USB_AL94/usb_device.c
+41 −0 common/USB_AL94/usb_device.h
+2,052 −0 common/USB_AL94/usbd_cdc.c
+151 −0 common/USB_AL94/usbd_cdc.h
+238 −0 common/USB_AL94/usbd_cdc_if.c
+39 −0 common/USB_AL94/usbd_cdc_if.h
+366 −0 common/USB_AL94/usbd_composite.c
+58 −0 common/USB_AL94/usbd_composite.h
+796 −816 common/USB_AL94/usbd_conf.c
+106 −0 common/USB_AL94/usbd_conf.h
+517 −0 common/USB_AL94/usbd_core.c
+93 −0 common/USB_AL94/usbd_core.h
+801 −0 common/USB_AL94/usbd_ctlreq.c
+43 −0 common/USB_AL94/usbd_ctlreq.h
+385 −0 common/USB_AL94/usbd_def.h
+270 −0 common/USB_AL94/usbd_desc.c
+47 −0 common/USB_AL94/usbd_desc.h
+149 −214 common/USB_AL94/usbd_ioreq.c
+49 −0 common/USB_AL94/usbd_ioreq.h
+34 −8 common/Varmint.cpp
+13 −2 common/Varmint.h
+10 −4 common/drivers/Adc.cpp
+21 −10 common/drivers/Adis165xx.cpp
+330 −327 common/drivers/Auav.cpp
+99 −99 common/drivers/Auav.h
+5 −4 common/drivers/Bmi088.cpp
+17 −4 common/drivers/ByteFifo.h
+6 −5 common/drivers/DlhrL20G.cpp
+5 −4 common/drivers/Dps310.cpp
+9 −1 common/drivers/Driver.h
+5 −4 common/drivers/Iis2mdc.cpp
+31 −11 common/drivers/Ist8308.cpp
+8 −4 common/drivers/Mcp4017.h
+6 −6 common/drivers/Ms4525.cpp
+19 −9 common/drivers/PacketFifo.h
+28 −7 common/drivers/Pwm.cpp
+3 −1 common/drivers/Pwm.h
+19 −5 common/drivers/Sbus.cpp
+8 −3 common/drivers/Sd.cpp
+2 −2 common/drivers/Sd.h
+7 −4 common/drivers/Spi.h
+57 −0 common/drivers/Status.h
+19 −6 common/drivers/Telem.cpp
+1 −1 common/drivers/Telem.h
+35 −12 common/drivers/Time64.h
+37 −13 common/drivers/Ubx.cpp
+5 −2 common/drivers/Vcp.cpp
+1 −1 common/drivers/Vcp.h
+2 −6 common/drivers/misc.cpp
+5 −1 fix-format-varmint.sh
+10 −0 make_links.bat
+46 −13 pixracer_pro/.cproject
+0 −177 pixracer_pro/STM32H743IIKX_RAM.ld
+5 −4 pixracer_pro/specific/BoardConfig.h
+6 −2 pixracer_pro/specific/Varmint_Init.cpp
+109 −12 varmint_10X/.cproject
+0 −173 varmint_10X/STM32H753VIHX_RAM.ld
+4 −2 varmint_10X/specific/BoardConfig.h
+2 −2 varmint_10X/specific/Varmint_Init.cpp
12 changes: 8 additions & 4 deletions include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class Board
virtual void init_board() = 0;
virtual void board_reset(bool bootloader) = 0;

virtual void sensors_init(void) = 0;
virtual uint16_t sensors_errors_count() = 0;

virtual uint16_t sensors_init_message_count() = 0;
virtual bool sensors_init_message_good(uint16_t i) = 0;
virtual uint16_t sensors_init_message(char *message, uint16_t size, uint16_t i) = 0;

// clock
virtual uint32_t clock_millis() = 0;
virtual uint64_t clock_micros() = 0;
Expand All @@ -67,11 +74,8 @@ class Board
virtual uint8_t serial_read() = 0;
virtual void serial_flush() = 0;

// sensors
virtual void sensors_init() = 0;
virtual uint16_t num_sensor_errors() = 0;

// IMU
virtual bool imu_present() = 0;
virtual bool imu_has_new_data() = 0;
virtual bool imu_read(float accel[3], float * temperature, float gyro[3], uint64_t * time) = 0;
virtual void imu_not_responding_error() = 0;
Expand Down
3 changes: 1 addition & 2 deletions include/comm_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ class CommManager : public CommLinkInterface::ListenerInterface, public ParamLis

// Debugging Utils
void send_named_value_int(const char * const name, int32_t value);
// void send_named_command_struct(const char *const name, control_t command_struct);

void send_next_param(void);

Expand All @@ -180,8 +179,8 @@ class CommManager : public CommLinkInterface::ListenerInterface, public ParamLis
void send_param_value(uint16_t param_id);
void update_status();
void log(CommLinkInterface::LogSeverity severity, const char * fmt, ...);
void log_message(CommLinkInterface::LogSeverity severity, char * text);

void send_parameter_list();
void send_named_value_float(const char * const name, float value);

void send_backup_data(const StateManager::BackupData & backup_data);
Expand Down
1 change: 0 additions & 1 deletion include/interface/comm_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#ifndef ROSFLIGHT_FIRMWARE_COMM_LINK_H
#define ROSFLIGHT_FIRMWARE_COMM_LINK_H

#include "board.h"
#include "param.h"
#include "sensors.h"
#include "state_manager.h"
Expand Down
3 changes: 1 addition & 2 deletions include/sensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Sensors : public ParamListenerInterface
float imu_temperature = 0;
uint64_t imu_time = 0;

float diff_pressure_velocity = 0;
float diff_pressure_ias = 0;
float diff_pressure = 0;
float diff_pressure_temp = 0;

Expand Down Expand Up @@ -271,7 +271,6 @@ class Sensors : public ParamListenerInterface

// Baro Calibration
bool baro_calibrated_ = false;
float ground_pressure_ = 0.0f;
uint16_t baro_calibration_count_ = 0;
uint32_t last_baro_cal_iter_ms_ = 0;
float baro_calibration_mean_ = 0.0f;
Expand Down
15 changes: 9 additions & 6 deletions src/comm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ void CommManager::param_request_list_callback(uint8_t target_system)
if (target_system == sysid_) { send_params_index_ = 0; }
}

void CommManager::send_parameter_list() { send_params_index_ = 0; }

void CommManager::param_request_read_callback(uint8_t target_system, const char * const param_name,
int16_t param_index)
{
Expand Down Expand Up @@ -339,10 +337,15 @@ void CommManager::log(CommLinkInterface::LogSeverity severity, const char * fmt,
// Convert the format string to a raw char array
va_list args;
va_start(args, fmt);
char text[LOG_MSG_SIZE];
vsnprintf(text, LOG_MSG_SIZE, fmt, args);
char message[LOG_MSG_SIZE];
vsnprintf(message, LOG_MSG_SIZE, fmt, args);
va_end(args);

log_message(severity, message);
}

void CommManager::log_message(CommLinkInterface::LogSeverity severity, char * text)
{
if (initialized_ && connected_) {
comm_link_.send_log_message(sysid_, severity, text);
} else {
Expand Down Expand Up @@ -372,7 +375,7 @@ void CommManager::send_status(void)
comm_link_.send_status(
sysid_, RF_.state_manager_.state().armed, RF_.state_manager_.state().failsafe,
RF_.command_manager_.rc_override_active(), RF_.command_manager_.offboard_control_active(),
RF_.state_manager_.state().error_codes, control_mode, RF_.board_.num_sensor_errors(),
RF_.state_manager_.state().error_codes, control_mode, RF_.board_.sensors_errors_count(),
RF_.get_loop_time_us());
}

Expand Down Expand Up @@ -412,7 +415,7 @@ void CommManager::send_rc_raw(void)

void CommManager::send_diff_pressure(void)
{
comm_link_.send_diff_pressure(sysid_, RF_.sensors_.data().diff_pressure_velocity,
comm_link_.send_diff_pressure(sysid_, RF_.sensors_.data().diff_pressure_ias,
RF_.sensors_.data().diff_pressure,
RF_.sensors_.data().diff_pressure_temp);
}
Expand Down
22 changes: 9 additions & 13 deletions src/sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ void Sensors::init()

next_sensor_to_update_ = BAROMETER;

float alt = rf_.params_.get_param_float(PARAM_GROUND_LEVEL);
ground_pressure_ = 101325.0f * static_cast<float>(pow((1 - 2.25694e-5 * alt), 5.2553));

int_start_us_ = rf_.board_.clock_micros();

this->update_battery_monitor_multipliers();
Expand Down Expand Up @@ -464,17 +461,19 @@ void Sensors::calibrate_baro()
// else reset cal variables and start over
if (baro_calibration_var_ < BARO_MAX_CALIBRATION_VARIANCE) {
rf_.params_.set_param_float(PARAM_BARO_BIAS, baro_calibration_mean_);
// set ground altitude to be pressure altitude at PARAM_BARO_BIAS
rf_.params_.set_param_float(PARAM_GROUND_LEVEL,turbomath::alt(rf_.params_.get_param_float(PARAM_BARO_BIAS)));
baro_calibrated_ = true;
rf_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_INFO, "Baro Cal successful!");
rf_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_INFO, "Baro ground pressure cal successful!");
} else {
rf_.comm_manager_.log(CommLinkInterface::LogSeverity::LOG_ERROR,
"Too much movement for barometer cal");
"Too much movement for barometer ground pressure cal");
}
baro_calibration_mean_ = 0.0f;
baro_calibration_var_ = 0.0f;
baro_calibration_count_ = 0;
} else if (baro_calibration_count_ > SENSOR_CAL_DELAY_CYCLES) {
float measurement = data_.baro_pressure - ground_pressure_;
float measurement = data_.baro_pressure;
float delta = measurement - baro_calibration_mean_;
baro_calibration_mean_ += delta / (baro_calibration_count_ - SENSOR_CAL_DELAY_CYCLES);
float delta2 = measurement - baro_calibration_mean_;
Expand Down Expand Up @@ -553,20 +552,17 @@ void Sensors::correct_mag(void)
void Sensors::correct_baro(void)
{
if (!baro_calibrated_) { calibrate_baro(); }
data_.baro_pressure -= rf_.params_.get_param_float(PARAM_BARO_BIAS);
data_.baro_altitude =
turbomath::alt(data_.baro_pressure) - rf_.params_.get_param_float(PARAM_GROUND_LEVEL);
data_.baro_altitude = turbomath::alt(data_.baro_pressure);
}

void Sensors::correct_diff_pressure()
{
if (!diff_pressure_calibrated_) { calibrate_diff_pressure(); }
data_.diff_pressure -= rf_.params_.get_param_float(PARAM_DIFF_PRESS_BIAS);

float atm = 101325.0f;
if (data_.baro_present) { atm = data_.baro_pressure; }
data_.diff_pressure_velocity = turbomath::fsign(data_.diff_pressure) * 24.574f
/ turbomath::inv_sqrt((turbomath::fabs(data_.diff_pressure) * data_.diff_pressure_temp / atm));
// compute indicated air speed
data_.diff_pressure_ias = turbomath::fsign(data_.diff_pressure)
* sqrt((fabs(data_.diff_pressure)/(0.5*1.225)));
}

void Sensors::update_battery_monitor_multipliers()
Expand Down
9 changes: 7 additions & 2 deletions test/test_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ uint8_t testBoard::serial_read() { return 0; }
void testBoard::serial_flush() {}

// sensors
void testBoard::sensors_init() {}
uint16_t testBoard::num_sensor_errors() { return 0; }
void testBoard::sensors_init() {};
uint16_t testBoard::sensors_errors_count() {return 0;}
uint16_t testBoard::sensors_init_message_count() {return 0;}
uint16_t testBoard::sensors_init_message(char * message, uint16_t size, uint16_t i) {return 0;}
bool testBoard::sensors_init_message_good(uint16_t i) {return false;}

bool testBoard::imu_present() {return false;}

bool testBoard::imu_has_new_data()
{
Expand Down
6 changes: 5 additions & 1 deletion test/test_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ class testBoard : public Board

// sensors
void sensors_init() override;
uint16_t num_sensor_errors() override;
uint16_t sensors_errors_count() override;
uint16_t sensors_init_message_count() override;
uint16_t sensors_init_message(char * message, uint16_t size, uint16_t i) override;
bool sensors_init_message_good(uint16_t i) override;

bool imu_present() override;
bool imu_has_new_data() override;
bool imu_read(float accel[3], float * temperature, float gyro[3], uint64_t * time) override;
void imu_not_responding_error() override;
Expand Down

0 comments on commit e0a9a7d

Please sign in to comment.