generated from cpp-best-practices/gui_starter_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmock_device.hpp
65 lines (53 loc) · 1.46 KB
/
mock_device.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include "gps.hpp"
#include "imu.hpp"
#include <cstdint>
#include <random>
#include <vector>
uint64_t get_ms();
struct lclock {
struct Time {
uint64_t ms;
auto asSeconds() -> float { return float(ms) / 1000.f; }
};
uint64_t start;
lclock();
auto getElapsedTime() -> Time;
void restart();
};
struct mock_imu {
lclock test_data_clock{};
imu last{};
size_t generated{0};
std::vector<imu> imu_samples{};
std::default_random_engine random_engine{std::random_device{}()};
std::uniform_int_distribution<int> random_acc{-2, 2};
std::uniform_int_distribution<int> random_ts{0, 1};
std::uniform_int_distribution<int> attractor_random{-5000, 5000};
std::pair<std::array<int16_t, 3>, std::array<int16_t, 3>> attractor{};
lclock attractor_clock{};
std::array<float, 3> imu_direction{};
void update();
};
constexpr auto office = DegPos{41.9134432f, 12.5010377f};
struct mock_gps {
std::default_random_engine random_engine{std::random_device{}()};
std::uniform_real_distribution<float> random_acc{-1 / 10'000.f,
1 / 10'000.f};
lclock test_data_clock{};
DegPos last = office;
size_t generated{0};
std::vector<DegPos> gps_samples{};
std::array<DegPos, 2> gps_boundingbox{office, office};
void update();
};
struct mock_device : mock_gps, mock_imu {
using mock_gps::gps_samples;
using mock_imu::imu_direction;
using mock_imu::imu_samples;
std::string label{"mock_data"};
void update() {
mock_gps::update();
mock_imu::update();
}
};