@@ -2,44 +2,44 @@ use std::{io::Read, time::Duration};
2
2
3
3
use nalgebra:: { Quaternion , Translation3 } ;
4
4
5
- use crate :: decode:: { decode_f32 , decode_f64, decode_i16, decode_i32, decode_i64 , decode_u8} ;
5
+ use crate :: decode:: { decode_f64, decode_i16, decode_i32, decode_u8} ;
6
6
7
+ #[ derive( Debug ) ]
7
8
pub struct PipelineResult {
8
- pub capture_time : i64 ,
9
- pub publish_time : i64 ,
10
- pub receive_time : i64 ,
11
- pub sequence : i64 ,
9
+ pub timestamp : f64 ,
10
+ pub latency : f64 ,
12
11
pub targets : Vec < Target > ,
13
12
pub position_estimate : PositionEstimateResult ,
14
13
}
15
14
16
15
impl PipelineResult {
17
- pub fn decode ( mut reader : impl Read , receive_time : i64 ) -> Result < Self , std:: io:: Error > {
16
+ pub fn decode ( mut reader : impl Read ) -> Result < Self , std:: io:: Error > {
18
17
Ok ( Self {
19
- sequence : decode_i64 ( & mut reader) ?,
20
- capture_time : decode_i64 ( & mut reader) ?,
21
- publish_time : decode_i64 ( & mut reader) ?,
18
+ latency : decode_f64 ( & mut reader) ?,
22
19
targets : ( 0 ..decode_u8 ( & mut reader) ?)
23
20
. map ( |_| Target :: decode ( & mut reader) )
24
21
. collect :: < Result < _ , _ > > ( ) ?,
25
22
position_estimate : PositionEstimateResult :: decode ( & mut reader) ?,
26
- receive_time ,
23
+ timestamp : 0.0 ,
27
24
} )
28
25
}
29
26
27
+ pub ( crate ) fn set_timestamp ( & mut self , timestamp : f64 ) {
28
+ self . timestamp = timestamp;
29
+ }
30
+
30
31
pub fn timestamp ( & self ) -> Duration {
31
- Duration :: from_micros ( ( self . receive_time - ( self . publish_time - self . capture_time ) ) as u64 )
32
+ Duration :: from_secs_f64 ( self . timestamp )
32
33
}
33
34
}
34
35
36
+ #[ derive( Debug ) ]
35
37
pub struct Target {
36
38
pub yaw : f64 ,
37
39
pub pitch : f64 ,
38
40
pub area : f64 ,
39
41
pub skew : f64 ,
40
42
pub apriltag_id : i32 ,
41
- pub class_id : i32 ,
42
- pub confidence : f32 ,
43
43
pub best_camera_to_target : Transform ,
44
44
pub alt_camera_to_target : Transform ,
45
45
pub pose_ambiguity : f64 ,
@@ -55,8 +55,6 @@ impl Target {
55
55
area : decode_f64 ( & mut reader) ?,
56
56
skew : decode_f64 ( & mut reader) ?,
57
57
apriltag_id : decode_i32 ( & mut reader) ?,
58
- class_id : decode_i32 ( & mut reader) ?,
59
- confidence : decode_f32 ( & mut reader) ?,
60
58
best_camera_to_target : Transform :: decode ( & mut reader) ?,
61
59
alt_camera_to_target : Transform :: decode ( & mut reader) ?,
62
60
pose_ambiguity : decode_f64 ( & mut reader) ?,
@@ -70,6 +68,7 @@ impl Target {
70
68
}
71
69
}
72
70
71
+ #[ derive( Debug ) ]
73
72
pub struct Corner {
74
73
pub x : f64 ,
75
74
pub y : f64 ,
@@ -84,6 +83,7 @@ impl Corner {
84
83
}
85
84
}
86
85
86
+ #[ derive( Debug ) ]
87
87
pub struct Transform {
88
88
pub translation : Translation3 < f64 > ,
89
89
pub rotation : Quaternion < f64 > ,
@@ -107,11 +107,13 @@ impl Transform {
107
107
}
108
108
}
109
109
110
+ #[ derive( Debug ) ]
110
111
pub struct PositionEstimateResult {
111
112
pub apriltag_ids : Vec < i16 > ,
112
113
pub estimate : Option < PositionEstimate > ,
113
114
}
114
115
116
+ #[ derive( Debug ) ]
115
117
pub struct PositionEstimate {
116
118
pub best : Transform ,
117
119
pub best_reprojection_err : f64 ,
@@ -136,7 +138,7 @@ impl PositionEstimateResult {
136
138
pub fn decode ( mut reader : impl Read ) -> Result < Self , std:: io:: Error > {
137
139
Ok ( Self {
138
140
estimate : {
139
- if decode_u8 ( & mut reader) ? == 1 {
141
+ if dbg ! ( decode_u8( & mut reader) ?) == 1 {
140
142
Some ( PositionEstimate :: decode ( & mut reader) ?)
141
143
} else {
142
144
None
0 commit comments