From 9c11fdace85bdd62ab350b6b94de05a11d94c791 Mon Sep 17 00:00:00 2001 From: Aaditya Voruganti <113856958+Aadityavoru@users.noreply.github.com> Date: Thu, 25 Apr 2024 19:28:47 -0500 Subject: [PATCH] Telem fixes (#48) * Make gps positions a little more accurate * removed comments * added newline --------- Co-authored-by: Zyun Lam Co-authored-by: Aidan Costello --- MIDAS/src/hardware/Barometer.cpp | 2 +- MIDAS/src/hardware/GPSSensor.cpp | 1 + MIDAS/src/telemetry.cpp | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MIDAS/src/hardware/Barometer.cpp b/MIDAS/src/hardware/Barometer.cpp index 7cc6642a..b012811f 100644 --- a/MIDAS/src/hardware/Barometer.cpp +++ b/MIDAS/src/hardware/Barometer.cpp @@ -25,6 +25,6 @@ Barometer BarometerSensor::read() { float pressure = static_cast(MS.getPressure() * 0.01 + 26.03); float temperature = static_cast(MS.getTemperature() * 0.01); float altitude = static_cast(-log(pressure * 0.000987) * (temperature + 273.15) * 29.254); - + return Barometer(temperature, pressure, altitude); } diff --git a/MIDAS/src/hardware/GPSSensor.cpp b/MIDAS/src/hardware/GPSSensor.cpp index 66b81fa5..ef8dcc92 100644 --- a/MIDAS/src/hardware/GPSSensor.cpp +++ b/MIDAS/src/hardware/GPSSensor.cpp @@ -17,6 +17,7 @@ ErrorCode GPSSensor::init() { return ErrorCode::NoError; } +// GPS Coordinates are ddmm.mmmm, so please convert with some code GPS GPSSensor::read() { teseo.update(); GPGGA_Info_t gpgga_message = teseo.getGPGGAData(); diff --git a/MIDAS/src/telemetry.cpp b/MIDAS/src/telemetry.cpp index 7ffe8a78..952f45d0 100644 --- a/MIDAS/src/telemetry.cpp +++ b/MIDAS/src/telemetry.cpp @@ -56,8 +56,9 @@ TelemetryPacket Telemetry::makePacket(RocketData& data) { packet.lat = gps.latitude; packet.lon = gps.longitude; - packet.alt = uint16_t(gps.altitude); - packet.baro_alt = uint16_t(barometer.altitude); + packet.alt = (int16_t) gps.altitude; + // Convert range of value so that we can also account for negative altitudes + packet.baro_alt = inv_convert_range(barometer.altitude, 1 << 17); auto [ax,ay,az] = pack_highg_tilt(highg, 33); packet.highg_ax = ax; packet.highg_ay = ay;