Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Jan 11, 2024
1 parent 0de9299 commit 9c1beaa
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rclrs/src/time.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::rcl_bindings::*;
use std::num::TryFromIntError;
use std::ops::{Add, Sub};
use std::sync::{Mutex, Weak};
use std::time::Duration;
use std::num::TryFromIntError;

/// Struct that represents time.
#[derive(Clone, Debug)]
Expand All @@ -13,7 +13,6 @@ pub struct Time {
pub clock: Weak<Mutex<rcl_clock_t>>,
}


impl Time {
/// Compares self to rhs, if they can be compared (originated from the same clock) calls f with
/// the values of the timestamps.
Expand All @@ -29,11 +28,11 @@ impl Time {
/// Convenience function for converting time to ROS message
pub fn to_ros_msg(&self) -> Result<builtin_interfaces::msg::Time, TryFromIntError> {
let nanosec = self.nsec % 1_000_000_000;
let sec = self.nsec / 1_000_000_000;
let sec = self.nsec / 1_000_000_000;

Ok(builtin_interfaces::msg::Time {
nanosec: nanosec.try_into()?,
sec: sec.try_into()?
sec: sec.try_into()?,
})
}
}
Expand Down Expand Up @@ -100,7 +99,9 @@ mod tests {

#[test]
fn test_conversion() {
let time = Time {nsec: 1_000_000_100};
let time = Time {
nsec: 1_000_000_100,
};
let msg = time.to_msg().unwrap();
assert_eq!(msg.nanosec, 100);
assert_eq!(msg.sec, 1);
Expand Down

0 comments on commit 9c1beaa

Please sign in to comment.