| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Copyright 2023 Google LLC | ||
| 2 | // | ||
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | // you may not use this file except in compliance with the License. | ||
| 5 | // You may obtain a copy of the License at | ||
| 6 | // | ||
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | // | ||
| 9 | // Unless required by applicable law or agreed to in writing, software | ||
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | // See the License for the specific language governing permissions and | ||
| 13 | // limitations under the License. | ||
| 14 | |||
| 15 | #pragma once | ||
| 16 | |||
| 17 | #include <libhal/functional.hpp> | ||
| 18 | #include <libhal/serial.hpp> | ||
| 19 | |||
| 20 | #include <libhal/timeout.hpp> | ||
| 21 | #include <libhal/units.hpp> | ||
| 22 | |||
| 23 | #include <libhal-icm/icm20948.hpp> | ||
| 24 | #include <libhal-mpl/mpl3115a2.hpp> | ||
| 25 | #include <libhal-neo/neo-m9n.hpp> | ||
| 26 | |||
| 27 | namespace hal::telemetry_recorder { | ||
| 28 | class telemetry_recorder | ||
| 29 | { | ||
| 30 | |||
| 31 | public: | ||
| 32 | struct telemetry_data | ||
| 33 | { | ||
| 34 | float accel_x; | ||
| 35 | float accel_y; | ||
| 36 | float accel_z; | ||
| 37 | float gyro_x; | ||
| 38 | float gyro_y; | ||
| 39 | float gyro_z; | ||
| 40 | float imu_temp; | ||
| 41 | float mag_x; | ||
| 42 | float mag_y; | ||
| 43 | float mag_z; | ||
| 44 | bool gps_locked; | ||
| 45 | float gps_time; | ||
| 46 | float gps_lat; | ||
| 47 | float gps_long; | ||
| 48 | int gps_sats; | ||
| 49 | float gps_alt; | ||
| 50 | float baro_temp; | ||
| 51 | float baro_pressure; | ||
| 52 | float baro_altitude; | ||
| 53 | }; | ||
| 54 | |||
| 55 | [[nodiscard]] static result<telemetry_recorder> create( | ||
| 56 | hal::icm::icm20948& p_imu, | ||
| 57 | hal::neo::neo_m9n& p_gps, | ||
| 58 | hal::mpl::mpl3115a2& p_baro); | ||
| 59 | |||
| 60 | hal::result<telemetry_data> record(); | ||
| 61 | hal::result<float> gps_baro_altitude_offset(); | ||
| 62 | hal::result<std::span<hal::byte>> recieve(); | ||
| 63 | hal::status transmit(std::string_view message); | ||
| 64 | hal::status transmit(const char* formatted_data); | ||
| 65 | hal::status store(std::string_view message); | ||
| 66 | |||
| 67 | private: | ||
| 68 | hal::icm::icm20948* m_icm; | ||
| 69 | hal::neo::neo_m9n* m_gps; | ||
| 70 | hal::mpl::mpl3115a2* m_mpl; | ||
| 71 | |||
| 72 | ✗ | explicit telemetry_recorder(hal::icm::icm20948& p_imu, | |
| 73 | hal::neo::neo_m9n& p_gps, | ||
| 74 | hal::mpl::mpl3115a2& p_baro) | ||
| 75 | ✗ | : m_icm(&p_imu) | |
| 76 | ✗ | , m_gps(&p_gps) | |
| 77 | ✗ | , m_mpl(&p_baro) | |
| 78 | { | ||
| 79 | } | ||
| 80 | |||
| 81 | telemetry_data m_data; | ||
| 82 | }; | ||
| 83 | } // namespace hal::telemetry_recorder | ||
| 84 |