melvin_ob/console_communication/
melvin_messages.rs

1use crate::imaging::map_image::EncodedImageExtract;
2
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Upstream {
5    #[prost(oneof = "UpstreamContent", tags = "1, 2, 3, 4, 5, 6, 7")]
6    pub content: Option<UpstreamContent>,
7}
8
9#[derive(Clone, PartialEq, ::prost::Message)]
10pub struct Ping {
11    #[prost(string, optional, tag = "1")]
12    pub echo: Option<String>,
13}
14#[derive(Clone, PartialEq, ::prost::Message)]
15pub struct Downstream {
16    #[prost(oneof = "DownstreamContent", tags = "1, 2, 3, 4, 5")]
17    pub content: Option<DownstreamContent>,
18}
19#[derive(Clone, PartialEq, ::prost::Message)]
20pub struct Pong {
21    #[prost(string, optional, tag = "1")]
22    pub echo: Option<String>,
23}
24#[derive(Clone, PartialEq, ::prost::Message)]
25pub struct Image {
26    #[prost(uint32, tag = "1")]
27    pub width: u32,
28    #[prost(uint32, tag = "2")]
29    pub height: u32,
30    #[prost(uint32, tag = "3")]
31    pub offset_x: u32,
32    #[prost(uint32, tag = "4")]
33    pub offset_y: u32,
34    #[prost(bytes = "vec", tag = "5")]
35    pub data: Vec<u8>,
36}
37
38impl Image {
39    pub(crate) fn from_encoded_image_extract(encoded_image: EncodedImageExtract) -> Self {
40        Self {
41            height: encoded_image.size.y(),
42            width: encoded_image.size.x(),
43            offset_x: encoded_image.offset.x(),
44            offset_y: encoded_image.offset.y(),
45            data: encoded_image.data,
46        }
47    }
48}
49
50#[derive(Clone, PartialEq, ::prost::Message)]
51pub struct Telemetry {
52    #[prost(int64, tag = "1")]
53    pub timestamp: i64,
54    #[prost(enumeration = "SatelliteState", tag = "2")]
55    pub state: i32,
56    #[prost(int32, tag = "3")]
57    pub position_x: i32,
58    #[prost(int32, tag = "4")]
59    pub position_y: i32,
60    #[prost(float, tag = "5")]
61    pub velocity_x: f32,
62    #[prost(float, tag = "6")]
63    pub velocity_y: f32,
64    #[prost(float, tag = "7")]
65    pub battery: f32,
66    #[prost(float, tag = "8")]
67    pub fuel: f32,
68    #[prost(uint32, tag = "9")]
69    pub data_sent: u32,
70    #[prost(uint32, tag = "10")]
71    pub data_received: u32,
72    #[prost(float, tag = "11")]
73    pub distance_covered: f32,
74}
75
76#[derive(Clone, PartialEq, prost::Message)]
77pub struct SubmitResponse {
78    #[prost(bool, tag = "1")]
79    pub success: bool,
80    #[prost(uint32, optional, tag = "2")]
81    pub objective_id: Option<u32>,
82}
83
84#[derive(Clone, PartialEq, prost::Oneof)]
85pub enum DownstreamContent {
86    #[prost(message, tag = "1")]
87    Pong(Pong),
88    #[prost(message, tag = "2")]
89    Image(Image),
90    #[prost(message, tag = "3")]
91    Telemetry(Telemetry),
92    #[prost(message, tag = "4")]
93    SubmitResponse(SubmitResponse),
94    #[prost(message, tag = "6")]
95    TaskList(TaskList),
96}
97
98#[derive(Clone, PartialEq, prost::Oneof)]
99pub enum UpstreamContent {
100    #[prost(message, tag = "1")]
101    Ping(Ping),
102    #[prost(message, tag = "2")]
103    GetFullImage(GetFullImage),
104    #[prost(message, tag = "3")]
105    GetSnapshotDiffImage(GetSnapshotDiffImage),
106    #[prost(message, tag = "4")]
107    CreateSnapshotImage(CreateSnapshotImage),
108    #[prost(message, tag = "5")]
109    SubmitObjective(ObjectiveArea),
110    #[prost(message, tag = "6")]
111    SubmitDailyMap(SubmitDailyMap),
112    #[prost(message, tag = "7")]
113    ScheduleSecretObjective(ObjectiveArea),
114}
115#[derive(Clone, Copy, PartialEq, prost::Message)]
116pub struct GetFullImage {}
117
118#[derive(Clone, PartialEq, prost::Message)]
119pub struct ObjectiveArea {
120    #[prost(uint32, tag = "1")]
121    pub objective_id: u32,
122    #[prost(uint32, tag = "2")]
123    pub width: u32,
124    #[prost(uint32, tag = "3")]
125    pub height: u32,
126    #[prost(uint32, tag = "4")]
127    pub offset_x: u32,
128    #[prost(uint32, tag = "5")]
129    pub offset_y: u32,
130}
131
132#[derive(Clone, PartialEq, prost::Message)]
133pub struct SubmitDailyMap {}
134
135#[derive(Clone, PartialEq, prost::Message)]
136pub struct GetSnapshotDiffImage {}
137
138#[derive(Clone, PartialEq, prost::Message)]
139pub struct CreateSnapshotImage {}
140
141#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration)]
142#[repr(i32)]
143pub enum SatelliteState {
144    None = 0,
145    Deployment = 1,
146    Safe = 2,
147    Communication = 3,
148    Charge = 4,
149    Acquisition = 5,
150    Transition = 6,
151}
152impl SatelliteState {
153    /// String value of the enum field names used in the `ProtoBuf` definition.
154    ///
155    /// The values are not transformed in any way and thus are considered stable
156    /// (if the `ProtoBuf` definition does not change) and safe for programmatic use.
157    pub fn as_str_name(self) -> &'static str {
158        match self {
159            Self::None => "none",
160            Self::Deployment => "deployment",
161            Self::Safe => "safe",
162            Self::Communication => "communication",
163            Self::Charge => "charge",
164            Self::Acquisition => "acquisition",
165            Self::Transition => "transition",
166        }
167    }
168    /// Creates an enum from field names used in the `ProtoBuf` definition.
169    pub fn from_str_name(value: &str) -> Option<Self> {
170        match value {
171            "none" => Some(Self::None),
172            "deployment" => Some(Self::Deployment),
173            "safe" => Some(Self::Safe),
174            "communication" => Some(Self::Communication),
175            "charge" => Some(Self::Charge),
176            "acquisition" => Some(Self::Acquisition),
177            "transition" => Some(Self::Transition),
178            _ => None,
179        }
180    }
181}
182
183#[derive(Clone, PartialEq, prost::Message)]
184pub struct TaskList {
185    #[prost(message, repeated, tag = "1")]
186    pub tasks: Vec<Task>,
187}
188
189#[derive(Clone, PartialEq, prost::Message)]
190pub struct Task {
191    #[prost(int64, tag = "1")]
192    pub scheduled_on: i64,
193    #[prost(oneof = "TaskType", tags = "2,3,4")]
194    pub task: Option<TaskType>,
195}
196
197#[derive(Clone, PartialEq, prost::Oneof)]
198pub enum TaskType {
199    #[prost(message, tag = "2")]
200    TakeImage(TakeImage),
201    #[prost(enumeration = "SatelliteState", tag = "3")]
202    SwitchState(i32),
203    #[prost(message, tag = "4")]
204    VelocityChange(BurnSequence),
205}
206#[derive(Clone, PartialEq, prost::Message)]
207pub struct TakeImage {
208    #[prost(uint32, optional, tag = "1")]
209    pub actual_position_x: Option<u32>,
210    #[prost(uint32, optional, tag = "2")]
211    pub actual_position_y: Option<u32>,
212    #[prost(uint32, tag = "3")]
213    pub planned_position_x: u32,
214    #[prost(uint32, tag = "4")]
215    pub planned_position_y: u32,
216}
217
218#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration)]
219#[repr(i32)]
220pub enum VelocityChangeTaskRationale {
221    Correctional = 0,
222    OrbitEscape = 1,
223    OrbitEnter = 2,
224}
225
226#[derive(Clone, PartialEq, prost::Message)]
227pub struct BurnSequence {
228    #[prost(enumeration="VelocityChangeTaskRationale", tag = "1")]
229    pub rational: i32,
230    #[prost(uint32, tag = "2")]
231    pub target_x: u32,
232    #[prost(uint32, tag = "3")]
233    pub target_y: u32,
234    #[prost(uint32, optional, tag = "4")]
235    pub add_target_x: Option<u32>,
236    #[prost(uint32, optional, tag = "5")]
237    pub add_target_y: Option<u32>,
238    #[prost(uint32, repeated, tag = "6")]
239    pub position_x: Vec<u32>,
240    #[prost(uint32, repeated, tag = "7")]
241    pub position_y: Vec<u32>,
242    #[prost(float, repeated, tag = "8")]
243    pub velocity_x: Vec<f32>,
244    #[prost(float, repeated, tag = "9")]
245    pub velocity_y: Vec<f32>,
246    #[prost(uint32, tag = "10")]
247    pub acc_dt: u32,
248    #[prost(uint32, tag = "11")]
249    pub detumble_dt: u32,
250    #[prost(float, tag = "12")]
251    pub rem_angle_dev: f32,
252    #[prost(float, tag = "13")]
253    pub min_charge: f32,
254    #[prost(float, tag = "14")]
255    pub min_fuel: f32,
256}