This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2024 David Such | |
# | |
# This software is released under the MIT License. | |
# https://opensource.org/licenses/MIT | |
import numpy as np | |
import pandas as pd | |
from sklearn.gaussian_process import GaussianProcessRegressor | |
from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C | |
from sklearn.model_selection import GridSearchCV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2024 David Such | |
# | |
# This software is released under the MIT License. | |
# https://opensource.org/licenses/MIT | |
import os | |
import requests | |
import zipfile | |
import scipy.io | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ForceLookup { | |
uint16_t voltage; // millivolts (mV) | |
uint16_t force; // grams (g) | |
}; | |
ForceLookup table[FLT_SIZE] = { {0, 0}, {900, 20}, {1400, 50}, {1750, 100}, {2250, 200}, {2500, 310}, | |
{2800, 450}, {3000, 580}, {3200, 710}, {3400, 900}, {3450, 1000} }; | |
float interpolate(uint16_t adc_mV) { | |
// Based on ADC voltage (mV), lookup the force (g) and interpolate between adjacent values if required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void sendResponse(char *key, char *value) { | |
Serial.print("{\""); | |
Serial.print(key); | |
Serial.print("\":\""); | |
Serial.print(value); | |
Serial.print("\"}\r\n"); | |
} | |
void sendResponse(char *key, int value) { | |
Serial.print("{\""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void parseCommand() { | |
char *cmdPtr = rx.getCommand(); | |
switch(rx.hash(cmdPtr) % HASH_SIZE) { | |
case xIMU3_ping: | |
rx.sendPing(pingPacket); | |
break; | |
case xIMU3_deviceName: | |
rx.sendResponse("deviceName", "Arduino"); | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BAD_ID -1 | |
typedef struct { | |
char *key; | |
int val; | |
} msp_commands_t; | |
static msp_commands_t lookupTable[] = { | |
{ "MSP_API_VERSION", MSP_API_VERSION }, { "MSP_FC_VARIANT", MSP_FC_VARIANT }, { "MSP_FC_VERSION", MSP_FC_VERSION }, { "MSP_BOARD_INFO", MSP_BOARD_INFO }, | |
{ "MSP_BUILD_INFO", MSP_BUILD_INFO }, { "MSP_NAME", MSP_NAME }, { "MSP_SET_NAME", MSP_SET_NAME }, { "MSP_IDENT", MSP_IDENT }, { "MSP_STATUS", MSP_STATUS }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned long hash(unsigned char *str) { | |
unsigned long hash = 5381; | |
int c; | |
while (c = *str++) | |
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ | |
return hash; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void checkForCommand() { | |
char buffer[BUFFER_SIZE]; | |
// Check for xIMU3 Command Messages | |
if (Serial.available() > 0) { | |
// read the incoming bytes: | |
int blen = Serial.readBytesUntil(STOP_BYTE, buffer, BUFFER_SIZE); | |
bool cmdFound = false; | |
// Command character count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MagTestResults ReefwingLSM9DS1::selfTestMag() { | |
MagTestResults results; | |
BiasOffsets mag_noST, mag_ST; | |
// Write 0x1C = 0b0001 1100 to CTRL_REG1_M | |
// ODR = 80 Hz, OM = Low Performance, FAST_ODR disabled, Self Test disabled | |
writeByte(LSM9DS1M_ADDRESS, LSM9DS1M_CTRL_REG1_M, 0x1C); | |
// Write 0x40 = 0b0100 0000 to CTRL_REG2_M | |
// FS = ± 12 gauss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ScaledData ReefwingLSM9DS1::readGyro() { | |
RawData gyr; | |
ScaledData result; | |
// Read the signed 16-bit RAW values | |
gyr = readGyroRaw(); | |
// Subtract the bias offsets | |
gyr.rx -= _config.gyro.bias.x; | |
gyr.ry -= _config.gyro.bias.y; |
NewerOlder