Skip to main content

Clock

Struct Clock 

Source
pub struct Clock { /* private fields */ }
Expand description

A clock for querying time

Clocks provide access to different time sources. Each node typically has an associated clock, but you can also create standalone clocks.

Implementations§

Source§

impl Clock

Source

pub const fn new(clock_type: ClockType) -> Clock

Create a new clock of the specified type

Source

pub const fn system() -> Clock

Create a system time clock

System time reflects the real-world wall clock time.

Source

pub const fn steady() -> Clock

Create a steady (monotonic) time clock

Steady time is guaranteed to only increase and is not affected by system time changes.

Source

pub const fn ros_time() -> Clock

Create a ROS time clock

ROS time can be overridden for simulation. When no override is active, it returns system time.

Source

pub const fn clock_type(&self) -> ClockType

Get the clock type

Source

pub fn now(&self) -> Time

Get the current time from this clock

§Platform behavior
  • With std: Uses std::time::SystemTime or std::time::Instant
  • Without std: Uses internal counters that must be updated manually
Source

pub fn set_ros_time_override(nanos: i64)

Set a ROS time override

When set, all RosTime clocks will return this time instead of system time. This is useful for simulation.

§Arguments
  • nanos - Nanoseconds since epoch
Source

pub fn set_ros_time_override_time(time: Time)

Set a ROS time override from a Time value

Source

pub fn clear_ros_time_override()

Clear the ROS time override

After clearing, RosTime clocks will return system time again.

Source

pub fn is_ros_time_override_active() -> bool

Check if a ROS time override is active

Source

pub fn get_ros_time_override() -> Option<Time>

Get the current ROS time override value (if active)

Source

pub fn update_steady_time(delta_nanos: i64)

Update the steady time counter

For no_std environments, call this periodically from your main loop or RTIC task to advance the steady clock.

§Arguments
  • delta_nanos - Nanoseconds elapsed since last call
Source

pub fn update_steady_time_ms(delta_ms: u64)

Update the steady time counter (milliseconds version)

Convenience method for RTIC tasks using millisecond intervals.

§Arguments
  • delta_ms - Milliseconds elapsed since last call
Source

pub fn set_steady_time(nanos: i64)

Set the steady time counter to a specific value

Use this to initialize the clock or synchronize with an external time source.

Source

pub fn get_steady_time_nanos() -> i64

Get the current steady time counter value

Trait Implementations§

Source§

impl Clone for Clock

Source§

fn clone(&self) -> Clock

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Clock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Clock

Source§

fn default() -> Clock

Returns the “default value” for a type. Read more
Source§

impl Copy for Clock

Auto Trait Implementations§

§

impl Freeze for Clock

§

impl RefUnwindSafe for Clock

§

impl Send for Clock

§

impl Sync for Clock

§

impl Unpin for Clock

§

impl UnsafeUnpin for Clock

§

impl UnwindSafe for Clock

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.