Begin path recording trials

This commit is contained in:
2022-01-03 18:18:00 +01:00
parent 107ae2d6c9
commit 3ec41a1a19
10 changed files with 235 additions and 11 deletions
+40
View File
@@ -0,0 +1,40 @@
#include <cstdint>
#include <cstring>
#include <vector>
/*
* Length in bytes: 20
*
* UINT16 | UINT16 | DOUBLE | DOUBLE |
* ---------+-------------+----------+-----------+
* ALTITUDE | GROUNDSPEED | LATITUDE | LONGITUDE |
*/
class PathSegment
{
private:
std::uint16_t altitude;
std::uint16_t groundSpeed;
double latitude;
double longitude;
std::vector<std::uint8_t> file;
public:
PathSegment(std::uint16_t altitude,
std::uint16_t groundSpeed,
double latitude,
double longitude)
{
this->altitude = altitude;
file = std::vector<std::uint8_t>(20, 0);
std::uint8_t *bufPtr = file.data();
memcpy(bufPtr, &this->altitude, sizeof(this->altitude));
bufPtr += sizeof(this->altitude);
memcpy(bufPtr, &this->groundSpeed, sizeof(this->groundSpeed));
bufPtr += sizeof(this->groundSpeed);
memcpy(bufPtr, &this->latitude, sizeof(this->latitude));
bufPtr += sizeof(this->latitude);
memcpy(bufPtr, &this->longitude, sizeof(this->longitude));
}
};
+13
View File
@@ -0,0 +1,13 @@
#include <cstdint>
#include <vector>
#include "pathSegment.hpp"
class Path
{
private:
std::vector<PathSegment> segments;
public:
void addSegment(PathSegment segment) { segments.push_back(segment); }
};