Skip to content
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

Verbose RC Override #371

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
4a25193
Basic setup for device management
BillThePlatypus Nov 26, 2019
10ce42d
Rename DeviceManager to ConfigManager
BillThePlatypus Dec 2, 2019
4cf3023
Define config struct
BillThePlatypus Dec 2, 2019
d79af1d
Basic memory manager functionality
BillThePlatypus Dec 3, 2019
1f6e21f
Add memory manager
BillThePlatypus Dec 4, 2019
4f30231
Config manager working for serial and airspeed
BillThePlatypus Dec 4, 2019
ffefe1a
Basic functionality working for config_manager
BillThePlatypus Dec 7, 2019
fba096c
Add support for more devices in config_manager
BillThePlatypus Dec 9, 2019
52cb102
Finish battery monitor initialization via config manager
BillThePlatypus Dec 11, 2019
3833594
Add enums for baro and mag
BillThePlatypus Dec 13, 2019
bea06d9
Add BoardConfigManager and AirbourneBoardConfigManager classes
BillThePlatypus Dec 13, 2019
d4b22ea
Transmitting device and config names on request
BillThePlatypus Dec 18, 2019
465e2f6
Add error messages to AirbourneBoardConfigManager
BillThePlatypus Dec 19, 2019
525334b
Add error messages to AirbourneBoardConfigManager
BillThePlatypus Dec 19, 2019
95a69db
Working responses to setting configs
BillThePlatypus Jan 7, 2020
22c8ca8
Add namespace for device enum. Fix some configuration checking
BillThePlatypus Jan 8, 2020
d31b3d3
Code cleanup
BillThePlatypus Jan 8, 2020
f8bda6b
Start documentation for configurations
BillThePlatypus Jan 9, 2020
97ffe78
add documentation for configurations
BillThePlatypus Jan 9, 2020
b5f82bb
Add implementations for breezy board and test board to pass tests
BillThePlatypus Jan 9, 2020
f7bde6f
Add test for config manager
BillThePlatypus Jan 9, 2020
0f76e4c
Update astylerc
BillThePlatypus Jan 9, 2020
9baf8e1
Add support for no mag or baro
BillThePlatypus Jan 10, 2020
0ff9180
Simplify BoardConfigurationManager interface
BillThePlatypus Jan 10, 2020
8f4d481
Change to chars for strings until needed for transmission
BillThePlatypus Jan 10, 2020
3771453
Clean up AirbourneBoardConfigManager
BillThePlatypus Jan 10, 2020
d3a9805
Add consts to functions in board relating to BoardConfigManagers
BillThePlatypus Jan 10, 2020
c4f5201
Style changes
BillThePlatypus Jan 10, 2020
6b8ee43
Style changes
BillThePlatypus Jan 10, 2020
7055089
Disallow config change while armed
BillThePlatypus Jan 10, 2020
0a12d69
Add command specifically for requesting configuration and deivce info…
BillThePlatypus Jan 13, 2020
9cd54a3
Clean up sending configuration info
BillThePlatypus Jan 13, 2020
3d9f3d7
Replace magic numbers for configurations with enums
BillThePlatypus Jan 13, 2020
d76dd7d
Add delay to prevent cold boot issues with sensors
BillThePlatypus Jan 13, 2020
ff3540e
Remove now unneeded methods and params
BillThePlatypus Jan 14, 2020
0b989f9
Get breezy building with changes
BillThePlatypus Jan 14, 2020
02407e3
Update test and test board to work with changes
BillThePlatypus Jan 14, 2020
d87e2f8
Fix behavior of using VCP when connected, even when UART is enabled
BillThePlatypus Jan 14, 2020
573e118
Small Documentation fixes
BillThePlatypus Jan 15, 2020
d71be80
Update documentation after reading through all of it
BillThePlatypus Jan 16, 2020
ce21fce
Add note on memory manager simplicity
BillThePlatypus Jan 16, 2020
29b42c5
Doxygen style comments
BillThePlatypus Jan 16, 2020
14e48f6
More doxygen comments
BillThePlatypus Jan 16, 2020
478139c
More doxygen comments
BillThePlatypus Jan 16, 2020
77e8527
Add FIRST_DEVICE constant
BillThePlatypus Jan 16, 2020
71cd17f
Fix simple typo
BillThePlatypus Jan 16, 2020
b5362ac
Comment clean up
BillThePlatypus Jan 17, 2020
243d34b
fix checksum for ConfigManager
BillThePlatypus Jan 24, 2020
648d12f
Add checks to not update disabled sensors
BillThePlatypus Jan 24, 2020
93b9dd9
Add rebased airbourne
BillThePlatypus Mar 16, 2020
7fb1809
Fix switch fallthrough
BillThePlatypus Mar 16, 2020
5a519c4
prevent disabled sensors from appearing
BillThePlatypus Mar 18, 2020
69340fe
Explicitly initialize some fields
BillThePlatypus Mar 24, 2020
2b8bd6e
Fix buffer overflow, add documentation to prevent, abbreviate baro an…
BillThePlatypus Mar 24, 2020
57892ee
Fix indentation
BillThePlatypus Mar 24, 2020
aa60907
Update airbourne to avoid sending baro/mag before initialization
BillThePlatypus Mar 24, 2020
4e097aa
Cleanup, as requested in review
BillThePlatypus Mar 24, 2020
5ae179b
Merge branch 'master' into device_manager
BillThePlatypus Mar 24, 2020
1e07c86
Send number of devices
BillThePlatypus Mar 25, 2020
2ed27e0
Update to latest mavlink
BillThePlatypus Mar 26, 2020
e8095f4
Merge branch 'device_manager' of github.com:rosflight/firmware into d…
BillThePlatypus Mar 26, 2020
8da5300
Add documentation on config_list
BillThePlatypus Apr 1, 2020
d8543e4
basic setup, but tests fail
BillThePlatypus Jan 21, 2020
0ad0f43
Passing most tests, which now check RC value
BillThePlatypus Jan 21, 2020
cd3306a
Update tests to check the verbose rc override indicators
BillThePlatypus Jan 21, 2020
1a59504
Update mavlink to send uint16's for rc_override
BillThePlatypus Jan 21, 2020
757cfcb
Prevent CommandManager from sending a status update every cycle
BillThePlatypus Jan 22, 2020
0db8a3e
Add tests for behavior with override switches flipped
BillThePlatypus Jan 23, 2020
ad240fe
Update documentation
BillThePlatypus Jan 23, 2020
56f0d75
Update to right version of mavlink
BillThePlatypus Apr 2, 2020
1a38535
Additional checks for invalid configurations
BillThePlatypus Apr 2, 2020
7cccbd4
Merge branch 'device_manager' into verbose_rc_override
BillThePlatypus Apr 2, 2020
75929be
better rc override status when rc is disconnected
BillThePlatypus Apr 2, 2020
b162016
Run clang-format
BillThePlatypus Apr 3, 2020
99bd20b
More clang-foramt
BillThePlatypus Apr 3, 2020
c5c2219
Merge branch 'master' into device_manager
BillThePlatypus Apr 3, 2020
7e35fca
Fix merge error
BillThePlatypus Apr 3, 2020
6229327
Fix merge breaking F1 build
BillThePlatypus Apr 3, 2020
0f31dda
Fix formatting
BillThePlatypus Apr 3, 2020
3639b7c
Fix style with fancy new clang-format
BillThePlatypus Apr 3, 2020
0001a12
Merge branch 'device_manager' into verbose_rc_override
BillThePlatypus Apr 3, 2020
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
1 change: 1 addition & 0 deletions boards/airbourne/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ AIRBOURNE_SRCS = led.cpp \
# board-specific source files
VPATH := $(VPATH):$(BOARD_DIR)
BOARD_CXX_SRC = airbourne_board.cpp \
airbourne_board_config_manager.cpp \
main.cpp

# Make a list of source files and includes
Expand Down
157 changes: 117 additions & 40 deletions boards/airbourne/airbourne_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,46 +76,39 @@ void AirbourneBoard::clock_delay(uint32_t milliseconds)
}

// serial
void AirbourneBoard::serial_init(uint32_t baud_rate, uint32_t dev)
void AirbourneBoard::serial_init(uint32_t baud_rate, hardware_config_t configuration)
{
vcp_.init();
switch (dev)
vcp_.init(); // VCP is always initialized, so that if UART is mistakenly enabled, it can still be used
switch (configuration)
{
case SERIAL_DEVICE_UART3:
uart3_.init(&uart_config[UART3], baud_rate);
current_serial_ = &uart3_;
secondary_serial_device_ = SERIAL_DEVICE_UART3;
break;
default:
case AirbourneConfiguration::SERIAL_VCP:
current_serial_ = &vcp_;
secondary_serial_device_ = SERIAL_DEVICE_VCP;
break;
case AirbourneConfiguration::SERIAL_UART1:
current_serial_ = &uart1_;
uart1_.init(&uart_config[UART1], baud_rate);
break;
case AirbourneConfiguration::SERIAL_UART2:
current_serial_ = &uart2_;
uart2_.init(&uart_config[UART2], baud_rate);
break;
case AirbourneConfiguration::SERIAL_UART3:
current_serial_ = &uart3_;
uart3_.init(&uart_config[UART3], baud_rate);
break;
}
}

void AirbourneBoard::serial_write(const uint8_t *src, size_t len)
{
if (vcp_.connected())
current_serial_ = &vcp_;
current_serial_->write(src, len);
}

uint16_t AirbourneBoard::serial_bytes_available()
{
if (vcp_.connected() || secondary_serial_device_ == SERIAL_DEVICE_VCP)
{
current_serial_ = &vcp_;
}
else
{
switch (secondary_serial_device_)
{
case SERIAL_DEVICE_UART3:
current_serial_ = &uart3_;
break;
default:
// no secondary serial device
break;
}
}

return current_serial_->rx_bytes_waiting();
}

Expand All @@ -129,21 +122,100 @@ void AirbourneBoard::serial_flush()
current_serial_->flush();
}

// Resources
bool AirbourneBoard::enable_device(device_t device, hardware_config_t configuration, const Params &params)
{
switch (device)
{
case Configuration::SERIAL:
{
uint32_t baud_rate = params.get_param_int(PARAM_BAUD_RATE);
serial_init(baud_rate, configuration);
return true; // TODO serial_init success check
break;
}
case Configuration::RC:
switch (configuration)
{
case AirbourneConfiguration::RC_PPM:
rc_init(RC_TYPE_PPM);
break;
case AirbourneConfiguration::RC_SBUS:
rc_init(RC_TYPE_SBUS);
break;
default:
return false;
}
return true;
case Configuration::AIRSPEED:
if (configuration == AirbourneConfiguration::AIRSPEED_I2C2)
{
if (!ext_i2c_.is_initialized())
ext_i2c_.init(&i2c_config[EXTERNAL_I2C]);
airspeed_.init(&ext_i2c_);
}
break;
case Configuration::GNSS:
// GNSS is currently disabled
break;
case Configuration::SONAR:
if (configuration == AirbourneConfiguration::SONAR_I2C2)
{
if (!ext_i2c_.is_initialized())
ext_i2c_.init(&i2c_config[EXTERNAL_I2C]);
sonar_.init(&ext_i2c_);
}
break;
case Configuration::BATTERY_MONITOR:
if (configuration == AirbourneConfiguration::BATTERY_MONITOR_ADC3)
{
float voltage_multiplier = params.get_param_float(PARAM_BATTERY_VOLTAGE_MULTIPLIER);
float current_multiplier = params.get_param_float(PARAM_BATTERY_CURRENT_MULTIPLIER);
battery_adc_.init(battery_monitor_config.adc);
battery_monitor_.init(battery_monitor_config, &battery_adc_, voltage_multiplier, current_multiplier);
}
break;
case Configuration::BAROMETER:
if (configuration == AirbourneConfiguration::BAROMETER_ONBOARD)
{
while (millis() < 50)
{
} // wait for sensors to boot up
if (!int_i2c_.is_initialized())
int_i2c_.init(&i2c_config[BARO_I2C]);
baro_.init(&int_i2c_);
}
break;
case Configuration::MAGNETOMETER:
if (configuration == AirbourneConfiguration::MAGNETOMETER_ONBOARD)
{
while (millis() < 50)
{
} // wait for sensors to boot up
if (!int_i2c_.is_initialized())
int_i2c_.init(&i2c_config[BARO_I2C]);
mag_.init(&int_i2c_);
}
break;
default:
return false;
}
return false;
}

AirbourneBoardConfigManager const &AirbourneBoard::get_board_config_manager() const
{
return board_config_manager_;
}

// sensors
void AirbourneBoard::sensors_init()
{
while (millis() < 50)
{
} // wait for sensors to boot up
imu_.init(&spi1_);

baro_.init(&int_i2c_);
mag_.init(&int_i2c_);
sonar_.init(&ext_i2c_);
airspeed_.init(&ext_i2c_);
// gnss_.init(&uart1_);
battery_adc_.init(battery_monitor_config.adc);
battery_monitor_.init(battery_monitor_config, &battery_adc_, 0, 0);
// Most sensors are set up through the configuration manager
}

uint16_t AirbourneBoard::num_sensor_errors()
Expand Down Expand Up @@ -185,23 +257,25 @@ bool AirbourneBoard::mag_present()

void AirbourneBoard::mag_update()
{
mag_.update();
if (mag_.is_initialized())
mag_.update();
}

void AirbourneBoard::mag_read(float mag[3])
{
mag_.update();
mag_update();
mag_.read(mag);
}
bool AirbourneBoard::baro_present()
{
baro_.update();
baro_update();
return baro_.present();
}

void AirbourneBoard::baro_update()
{
baro_.update();
if (baro_.is_initialized())
baro_.update();
}

void AirbourneBoard::baro_read(float *pressure, float *temperature)
Expand All @@ -212,7 +286,9 @@ void AirbourneBoard::baro_read(float *pressure, float *temperature)

bool AirbourneBoard::diff_pressure_present()
{
return airspeed_.present();
if (airspeed_.is_initialized())
return airspeed_.present();
return false;
}

void AirbourneBoard::diff_pressure_update()
Expand All @@ -235,7 +311,8 @@ bool AirbourneBoard::sonar_present()

void AirbourneBoard::sonar_update()
{
sonar_.update();
if (sonar_.is_initialized())
sonar_.update();
}

float AirbourneBoard::sonar_read()
Expand Down
12 changes: 10 additions & 2 deletions boards/airbourne/airbourne_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@
#include <cstdint>
// #include "ublox.h"

#include "airbourne_board_config_manager.h"
#include "board.h"

namespace rosflight_firmware
{
class AirbourneBoard : public Board
{
private:
AirbourneBoardConfigManager board_config_manager_;

VCP vcp_;
UART uart1_;
UART uart2_;
UART uart3_;
Serial *current_serial_; // A pointer to the serial stream currently in use.
I2C int_i2c_;
Expand Down Expand Up @@ -132,12 +136,16 @@ class AirbourneBoard : public Board
void clock_delay(uint32_t milliseconds) override;

// serial
void serial_init(uint32_t baud_rate, uint32_t dev) override;
void serial_init(uint32_t baud_rate, hardware_config_t configuration);
void serial_write(const uint8_t *src, size_t len) override;
uint16_t serial_bytes_available() override;
uint8_t serial_read() override;
void serial_flush() override;

// hardware config
bool enable_device(device_t device, hardware_config_t configuration, const Params &params) override;
AirbourneBoardConfigManager const &get_board_config_manager() const override;

// sensors
void sensors_init() override;
uint16_t num_sensor_errors() override;
Expand Down Expand Up @@ -178,7 +186,7 @@ class AirbourneBoard : public Board
bool gnss_has_new_data() override;
GNSSRaw gnss_raw_read() override;
// RC
void rc_init(rc_type_t rc_type) override;
void rc_init(rc_type_t rc_type);
bool rc_lost() override;
float rc_read(uint8_t channel) override;

Expand Down
Loading