Skip to content

Commit 3e9bd43

Browse files
Have a very cruddy position plot showing.
1 parent 5adbe9a commit 3e9bd43

File tree

9 files changed

+489
-63
lines changed

9 files changed

+489
-63
lines changed

console_backend/src/constants.rs

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,47 @@ pub const SHOW_LEGEND: &str = "Show Legend";
3737
pub const PLOT_HISTORY_MAX: usize = 1000;
3838
pub const DILUTION_OF_PRECISION_UNITS: f64 = 0.01;
3939
pub const NUM_GNSS_MODES: usize = 6;
40-
pub const SPP: &str = "spp";
41-
pub const DGNSS: &str = "dgnss";
42-
pub const FLOAT: &str = "float";
43-
pub const FIXED: &str = "fixed";
44-
pub const DR: &str = "dr";
45-
pub const SBAS: &str = "sbas";
46-
47-
pub const LAT_SPP: &str = "lat_spp";
48-
pub const LNG_SPP: &str = "lng_spp";
49-
pub const ALT_SPP: &str = "alt_spp";
50-
pub const LAT_DGNSS: &str = "lat_dgnss";
51-
pub const LNG_DGNSS: &str = "lng_dgnss";
52-
pub const ALT_DGNSS: &str = "alt_dgnss";
53-
pub const LAT_FLOAT: &str = "lat_float";
54-
pub const LNG_FLOAT: &str = "lng_float";
55-
pub const ALT_FLOAT: &str = "alt_float";
56-
pub const LAT_FIXED: &str = "lat_fixed";
57-
pub const LNG_FIXED: &str = "lng_fixed";
58-
pub const ALT_FIXED: &str = "alt_fixed";
59-
pub const LAT_DR: &str = "lat_dr";
60-
pub const LNG_DR: &str = "lng_dr";
61-
pub const ALT_DR: &str = "alt_dr";
62-
pub const LAT_SBAS: &str = "lat_sbas";
63-
pub const LNG_SBAS: &str = "lng_sbas";
64-
pub const ALT_SBAS: &str = "alt_sbas";
40+
pub const NO_FIX_LABEL: &str = "No Fix";
41+
pub const SPP_LABEL: &str = "SPP";
42+
pub const DGNSS_LABEL: &str = "DGPS";
43+
pub const FLOAT_LABEL: &str = "RTK float";
44+
pub const FIXED_LABEL: &str = "RTK fixed";
45+
pub const DR_LABEL: &str = "DR";
46+
pub const SBAS_LABEL: &str = "SBAS";
47+
48+
pub const NO_FIX: &str = "No Fix";
49+
pub const SPP: &str = "SPP";
50+
pub const DGNSS: &str = "DGPS";
51+
pub const FLOAT: &str = "Float RTK";
52+
pub const FIXED: &str = "Fixed RTK";
53+
pub const DR: &str = "Dead Reckoning";
54+
pub const SBAS: &str = "SBAS";
55+
pub const NO_FIX_COLOR: &str = "#FFFFFF";
56+
pub const SPP_COLOR: &str = "#0000FF";
57+
pub const DGNSS_COLOR: &str = "#00B3FF";
58+
pub const FLOAT_COLOR: &str = "#BF00BF";
59+
pub const FIXED_COLOR: &str = "#FFA500";
60+
pub const DR_COLOR: &str = "#000000";
61+
pub const SBAS_COLOR: &str = "#00FF00";
62+
63+
pub const LAT_SPP: &str = "lat_SPP";
64+
pub const LNG_SPP: &str = "lng_SPP";
65+
pub const ALT_SPP: &str = "alt_SPP";
66+
pub const LAT_DGNSS: &str = "lat_DGPS";
67+
pub const LNG_DGNSS: &str = "lng_DGPS";
68+
pub const ALT_DGNSS: &str = "alt_DGPS";
69+
pub const LAT_FLOAT: &str = "lat_Float RTK";
70+
pub const LNG_FLOAT: &str = "lng_Float RTK";
71+
pub const ALT_FLOAT: &str = "alt_Float RTK";
72+
pub const LAT_FIXED: &str = "lat_Fixed RTK";
73+
pub const LNG_FIXED: &str = "lng_Fixed RTK";
74+
pub const ALT_FIXED: &str = "alt_Fixed RTK";
75+
pub const LAT_DR: &str = "lat_Dead Reckoning";
76+
pub const LNG_DR: &str = "lng_Dead Reckoning";
77+
pub const ALT_DR: &str = "alt_Dead Reckoning";
78+
pub const LAT_SBAS: &str = "lat_SBAS";
79+
pub const LNG_SBAS: &str = "lng_SBAS";
80+
pub const ALT_SBAS: &str = "alt_SBAS";
6581
pub const SOLUTIONS_KEYS: &[&str] = &[
6682
LAT_SPP, LNG_SPP, ALT_SPP, LAT_DGNSS, LNG_DGNSS, ALT_DGNSS, LAT_FLOAT, LNG_FLOAT, ALT_FLOAT,
6783
LAT_FIXED, LNG_FIXED, ALT_FIXED, LAT_DR, LNG_DR, ALT_DR, LAT_SBAS, LNG_SBAS, ALT_SBAS,
@@ -145,6 +161,7 @@ pub const MPS2KPH: f64 = 3.600000;
145161
#[repr(u8)]
146162
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]
147163
pub enum GnssModes {
164+
NoFix = 0,
148165
Spp = 1,
149166
Dgnss = 2,
150167
Float = 3,
@@ -155,6 +172,7 @@ pub enum GnssModes {
155172
impl From<u8> for GnssModes {
156173
fn from(s: u8) -> Self {
157174
match s {
175+
0 => GnssModes::NoFix,
158176
1 => GnssModes::Spp,
159177
2 => GnssModes::Dgnss,
160178
3 => GnssModes::Float,
@@ -173,6 +191,7 @@ impl ToString for GnssModes {
173191
/// - `key`: The code, which is signal code, and satellite constellation-specific satellite identifier.
174192
fn to_string(&self) -> String {
175193
let gnss_mode_str = match self {
194+
GnssModes::NoFix => NO_FIX,
176195
GnssModes::Spp => SPP,
177196
GnssModes::Dgnss => DGNSS,
178197
GnssModes::Float => FLOAT,
@@ -183,6 +202,32 @@ impl ToString for GnssModes {
183202
String::from(gnss_mode_str)
184203
}
185204
}
205+
impl GnssModes {
206+
pub fn get_label(&self) -> String {
207+
let gnss_mode_label = match self {
208+
GnssModes::NoFix => NO_FIX_LABEL,
209+
GnssModes::Spp => SPP_LABEL,
210+
GnssModes::Dgnss => DGNSS_LABEL,
211+
GnssModes::Float => FLOAT_LABEL,
212+
GnssModes::Fixed => FIXED_LABEL,
213+
GnssModes::Dr => DR_LABEL,
214+
GnssModes::Sbas => SBAS_LABEL,
215+
};
216+
String::from(gnss_mode_label)
217+
}
218+
pub fn get_color(&self) -> String {
219+
let gnss_mode_color = match self {
220+
GnssModes::NoFix => NO_FIX_COLOR,
221+
GnssModes::Spp => SPP_COLOR,
222+
GnssModes::Dgnss => DGNSS_COLOR,
223+
GnssModes::Float => FLOAT_COLOR,
224+
GnssModes::Fixed => FIXED_COLOR,
225+
GnssModes::Dr => DR_COLOR,
226+
GnssModes::Sbas => SBAS_COLOR,
227+
};
228+
String::from(gnss_mode_color)
229+
}
230+
}
186231

187232
#[repr(u8)]
188233
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq)]

console_backend/src/solution_tab.rs

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,21 @@ const POS_LLH_TIME_STR_FILEPATH: &str = "position_log_%Y%m%d-%H%M%S.csv";
3636
pub struct SolutionTab {
3737
pub age_corrections: Option<f64>,
3838
pub alts: Deque<f64>,
39+
pub colors: Vec<String>,
3940
pub directory_name: Option<String>,
4041
pub ins_status_flags: u32,
4142
pub ins_used: bool,
43+
pub labels: Vec<String>,
4244
pub lats: Deque<f64>,
4345
pub lngs: Deque<f64>,
4446
pub last_ins_status_receipt_time: Instant,
4547
pub last_pos_mode: u8,
4648
pub last_odo_update_time: Instant,
4749
pub logging: bool,
48-
pub max: f64,
49-
pub min: f64,
50+
pub lat_max: f64,
51+
pub lat_min: f64,
52+
pub lon_max: f64,
53+
pub lon_min: f64,
5054
pub mode_strings: Vec<String>,
5155
pub modes: Deque<u8>,
5256
pub nsec: Option<i32>,
@@ -69,17 +73,39 @@ impl SolutionTab {
6973
SolutionTab {
7074
age_corrections: None,
7175
alts: Deque::with_size_limit(PLOT_HISTORY_MAX),
76+
colors: {
77+
vec![
78+
GnssModes::Spp.get_color(),
79+
GnssModes::Dgnss.get_color(),
80+
GnssModes::Float.get_color(),
81+
GnssModes::Fixed.get_color(),
82+
GnssModes::Dr.get_color(),
83+
GnssModes::Sbas.get_color(),
84+
]
85+
},
7286
directory_name: None,
7387
ins_status_flags: 0,
7488
ins_used: false,
89+
labels: {
90+
vec![
91+
GnssModes::Spp.get_label(),
92+
GnssModes::Dgnss.get_label(),
93+
GnssModes::Float.get_label(),
94+
GnssModes::Fixed.get_label(),
95+
GnssModes::Dr.get_label(),
96+
GnssModes::Sbas.get_label(),
97+
]
98+
},
7599
lats: Deque::with_size_limit(PLOT_HISTORY_MAX),
76100
lngs: Deque::with_size_limit(PLOT_HISTORY_MAX),
77101
last_ins_status_receipt_time: Instant::now(),
78102
last_pos_mode: 0,
79103
last_odo_update_time: Instant::now(),
80104
logging: false,
81-
max: 0_f64,
82-
min: 0_f64,
105+
lat_max: 38_f64,
106+
lat_min: 36_f64,
107+
lon_max: -121_f64,
108+
lon_min: -123_f64,
83109
modes: Deque::with_size_limit(PLOT_HISTORY_MAX),
84110
mode_strings: vec![
85111
GnssModes::Spp.to_string(),
@@ -480,9 +506,9 @@ impl SolutionTab {
480506
self.table
481507
.insert(String::from(HEIGHT), format!("{:.3}", height));
482508
self.table
483-
.insert(String::from(HORIZ_ACC), format!("{:.12}", h_accuracy));
509+
.insert(String::from(HORIZ_ACC), format!("{:.3}", h_accuracy));
484510
self.table
485-
.insert(String::from(VERT_ACC), format!("{:.12}", v_accuracy));
511+
.insert(String::from(VERT_ACC), format!("{:.3}", v_accuracy));
486512

487513
self.lats.add(lat);
488514
self.lngs.add(lon);
@@ -559,7 +585,7 @@ impl SolutionTab {
559585
.iter()
560586
.zip(self.slns[&lng_string].get().iter())
561587
.filter(|(x, y)| !x.is_nan() || !y.is_nan())
562-
.map(|(x, y)| (*x, *y))
588+
.map(|(x, y)| (*y, *x))
563589
.collect();
564590
if update_current {
565591
if self.sln_data[idx].len() > 0 {
@@ -568,6 +594,13 @@ impl SolutionTab {
568594
self.sln_cur_data[idx] = (f64::NAN, f64::NAN);
569595
}
570596
}
597+
if self.sln_data[idx].len()>10 {
598+
self.lat_max = self.sln_data[idx][0].1;
599+
self.lat_min = self.sln_data[idx][self.sln_data[idx].len()-1].1;
600+
self.lon_max = self.sln_data[idx][0].0;
601+
self.lon_min = self.sln_data[idx][self.sln_data[idx].len()-1].0;
602+
}
603+
571604
}
572605
}
573606

@@ -581,30 +614,40 @@ impl SolutionTab {
581614
let msg = builder.init_root::<m::message::Builder>();
582615

583616
let mut solution_status = msg.init_solution_position_status();
584-
// velocity_status.set_min(self.min);
585-
// velocity_status.set_max(self.max);
617+
solution_status.set_lat_min(self.lat_min);
618+
solution_status.set_lat_max(self.lat_max);
619+
solution_status.set_lon_min(self.lon_min);
620+
solution_status.set_lon_max(self.lon_max);
586621

587622
let mut solution_points = solution_status
588623
.reborrow()
589624
.init_data(self.sln_data.len() as u32);
590625
for idx in 0..self.sln_data.len() {
591-
let points = self.sln_data.get_mut(idx).unwrap().get();
626+
let points = self.sln_data.get_mut(idx).unwrap();
592627
let mut point_idx = solution_points
593628
.reborrow()
594629
.init(idx as u32, points.len() as u32);
595-
for (i, (x, OrderedFloat(y))) in points.iter().enumerate() {
630+
for (i, (x, y)) in points.iter().enumerate() {
596631
let mut point_val = point_idx.reborrow().get(i as u32);
597632
point_val.set_x(*x);
598633
point_val.set_y(*y);
599634
}
600635
}
601-
// let mut colors = velocity_status
602-
// .reborrow()
603-
// .init_colors(self.colors.len() as u32);
636+
let mut colors = solution_status
637+
.reborrow()
638+
.init_colors(self.colors.len() as u32);
604639

605-
// for (i, color) in self.colors.iter().enumerate() {
606-
// colors.set(i as u32, color);
607-
// }
640+
for (i, color) in self.colors.iter().enumerate() {
641+
colors.set(i as u32, color);
642+
}
643+
644+
let mut labels = solution_status
645+
.reborrow()
646+
.init_labels(self.mode_strings.len() as u32);
647+
648+
for (i, label) in self.mode_strings.iter().enumerate() {
649+
labels.set(i as u32, label);
650+
}
608651

609652
let mut msg_bytes: Vec<u8> = vec![];
610653
serialize::write_message(&mut msg_bytes, &builder).unwrap();

resources/SolutionTab.qml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ Item {
6868
height: parent.height
6969
currentIndex: solutionBar.currentIndex
7070

71-
Item {
72-
id: solutionPositionTab
71+
SolutionTabComponents.SolutionPositionTab {
7372
}
7473

7574
SolutionTabComponents.SolutionVelocityTab {

0 commit comments

Comments
 (0)