diff --git a/Cargo.toml b/Cargo.toml index 2a8cd95..e1f4108 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,5 +28,5 @@ resolver = "2" [workspace.package] -version = "0.2.8" +version = "0.2.9" edition = "2021" diff --git a/krec/bindings/src/lib.rs b/krec/bindings/src/lib.rs index a782256..3632295 100644 --- a/krec/bindings/src/lib.rs +++ b/krec/bindings/src/lib.rs @@ -855,7 +855,10 @@ impl PyKRec { // Sample frame details (first frame) output.push_str("\nFirst frame details:\n"); - output.push_str(&format!(" Frame number: {}\n", first_frame.frame_number)); + output.push_str(&format!( + " Video frame number: {}\n", + first_frame.video_frame_number + )); output.push_str(&format!( " Inference step: {}\n", first_frame.inference_step @@ -891,7 +894,10 @@ impl PyKRec { output.push_str(&format!("Frame {}\n", frame_number)); output.push_str("=========\n\n"); output.push_str(&format!("Video timestamp: {}\n", frame.video_timestamp)); - output.push_str(&format!("Frame number: {}\n", frame.frame_number)); + output.push_str(&format!( + "Video frame number: {}\n", + frame.video_frame_number + )); output.push_str(&format!("Inference step: {}\n", frame.inference_step)); // Actuator states @@ -1144,12 +1150,13 @@ struct PyKRecFrame { #[pymethods] impl PyKRecFrame { #[new] - #[pyo3(signature = (video_timestamp=None, frame_number=None, inference_step=None, values=None))] + #[pyo3(signature = (video_timestamp=None, video_frame_number=None, inference_step=None, real_timestamp=None, values=None))] fn new( py: Python<'_>, video_timestamp: Option, - frame_number: Option, + video_frame_number: Option, inference_step: Option, + real_timestamp: Option, values: Option>, ) -> PyResult { if let Some(values) = values { @@ -1159,31 +1166,34 @@ impl PyKRecFrame { let item = item?; items.push(item.to_object(py)); } - if items.len() != 3 { + if items.len() != 4 { return Err(PyValueError::new_err( - "Iterable must contain exactly 3 values: [video_timestamp, frame_number, inference_step]" + "Iterable must contain exactly 4 values: [video_timestamp, frame_number, inference_step, real_timestamp]" )); } let mut inner = KRecFrame::default(); inner.video_timestamp = items[0].extract::(py)?; - inner.frame_number = items[1].extract::(py)?; + inner.video_frame_number = items[1].extract::(py)?; inner.inference_step = items[2].extract::(py)?; + inner.real_timestamp = items[3].extract::(py)?; return Ok(Self { inner }); } } let mut inner = KRecFrame::default(); inner.video_timestamp = video_timestamp.unwrap_or(0); - inner.frame_number = frame_number.unwrap_or(0); + inner.video_frame_number = video_frame_number.unwrap_or(0); inner.inference_step = inference_step.unwrap_or(0); + inner.real_timestamp = real_timestamp.unwrap_or(0); Ok(Self { inner }) } fn __repr__(&self) -> String { format!( - "KRecFrame(video_timestamp={}, frame_number={}, inference_step={}, states={}, has_commands={}, has_imu={})", + "KRecFrame(real_timestamp={}, video_timestamp={}, video_frame_number={}, inference_step={}, states={}, has_commands={}, has_imu={})", + self.inner.real_timestamp, self.inner.video_timestamp, - self.inner.frame_number, + self.inner.video_frame_number, self.inner.inference_step, self.inner.actuator_states.len(), !self.inner.actuator_commands.is_empty(), @@ -1202,12 +1212,12 @@ impl PyKRecFrame { } #[getter] - fn get_frame_number(&self) -> u64 { - self.inner.frame_number + fn get_video_frame_number(&self) -> u64 { + self.inner.video_frame_number } #[setter] - fn set_frame_number(&mut self, value: u64) { - self.inner.frame_number = value; + fn set_video_frame_number(&mut self, value: u64) { + self.inner.video_frame_number = value; } #[getter] @@ -1219,6 +1229,15 @@ impl PyKRecFrame { self.inner.inference_step = value; } + #[getter] + fn get_real_timestamp(&self) -> u64 { + self.inner.real_timestamp + } + #[setter] + fn set_real_timestamp(&mut self, value: u64) { + self.inner.real_timestamp = value; + } + // Methods for actuator states fn add_actuator_state(&mut self, state: &PyActuatorState) { self.inner.actuator_states.push(state.inner.clone()); diff --git a/proto/krec.proto b/proto/krec.proto index 7bf54c4..96f4b1c 100644 --- a/proto/krec.proto +++ b/proto/krec.proto @@ -13,12 +13,13 @@ message KRecHeader { } message KRecFrame { - uint64 video_timestamp = 1; - uint64 frame_number = 2; - uint64 inference_step = 3; - repeated ActuatorState actuator_states = 4; - repeated ActuatorCommand actuator_commands = 5; - optional IMUValues imu_values = 6; + uint64 real_timestamp = 1; + uint64 video_timestamp = 2; + uint64 video_frame_number = 3; + uint64 inference_step = 4; + repeated ActuatorState actuator_states = 5; + repeated ActuatorCommand actuator_commands = 6; + optional IMUValues imu_values = 7; } message ActuatorConfig {