1use chrono::{DateTime, Utc};
5use serde::de::Error;
6use serde::{Deserialize, Serialize};
7use crate::util::{ByteArraySerializeDeserialize, JsonSerializeDeserialize};
9use glue_derive::{ByteArrayToFromZMQ, JsonToFromZMQ};
11
12#[derive(Serialize, Deserialize, Debug, ByteArrayToFromZMQ)]
14pub enum GlueMsg {
15 Form(Form),
16 Image(Image),
17 ImageTagged(ImageTagged),
18 GPS(Gps),
19 Target(Target),
20 Offboard(Offboard),
21 Heartbeat(Heartbeat),
22 GlueError(String),
23 SauronProphecy(SauronProphecy),
24 SauronResult(SauronResult),
25}
26
27#[derive(Serialize, Deserialize, Debug, JsonToFromZMQ)]
29pub struct Form {
30 pub state: String,
31}
32
33#[derive(Serialize, Deserialize, Debug, ByteArrayToFromZMQ)]
35pub struct Image {
36 pub image: String,
37 pub time: DateTime<Utc>,
38}
39
40#[derive(Serialize, Deserialize, Debug, ByteArrayToFromZMQ)]
42pub struct ImageTagged {
43 pub image: String,
44 pub long: f64,
45 pub lat: f64,
46 pub time: DateTime<Utc>,
47}
48
49#[derive(Serialize, Deserialize, Debug, Clone, JsonToFromZMQ)]
50pub struct SauronProphecy {
51 pub image_path: String,
52 pub in_bounds: bool,
53 pub gps: Gps,
54}
55
56#[derive(Serialize, Deserialize, Debug, Clone, JsonToFromZMQ)]
57pub struct SauronResult {
58 pub image_path: String,
59 pub detections: Detections,
60 pub target_gps: Target,
61}
62
63#[derive(Serialize, Deserialize, Debug, Clone, JsonToFromZMQ)]
64pub struct ImagePathGPS {
65 pub image_path: String, pub image_gps_data: Gps, pub heading: f64, }
69
70#[derive(Serialize, Deserialize, Debug, Clone, JsonToFromZMQ)]
71pub struct DetectToLocalData {
72 pub image_path: String,
73 pub image_gps_data: Gps, pub heading: f64, pub detections: Detections, }
77
78#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
79pub struct BoxDetection {
80 pub x1: f32, pub y1: f32, pub x2: f32, pub y2: f32, pub class_index: usize, pub conf: f32, }
87pub type Detections = Vec<BoxDetection>;
88
89#[derive(Serialize, Deserialize, Debug, ByteArrayToFromZMQ, Clone, Copy)]
91pub struct Gps {
92 pub lat: f64,
93 pub long: f64,
94 pub alt: f64,
95 pub heading: f64,
96
97 #[serde(with = "chrono::serde::ts_milliseconds")]
98 pub time: DateTime<Utc>,
99}
100
101#[derive(Serialize, Deserialize, Debug, ByteArrayToFromZMQ, Clone, Copy)]
103pub struct Target {
104 pub lat: f64,
105 pub long: f64,
106}
107
108#[derive(Serialize, Deserialize, Debug, JsonToFromZMQ)]
110pub struct Offboard {
111 pub latitude: f64,
112 pub longitude: f64,
113 pub altitude: f64,
114 pub is_servo: bool,
115 pub id: u32,
116}
117
118#[derive(Serialize, Deserialize, Debug, JsonToFromZMQ)]
120pub struct Heartbeat {
121 pub time: DateTime<Utc>,
122}