Class Clock

Inheritance Relationships

Base Type

Class Documentation

class Clock : public lupnt::Device

Onboard clock device: tracks a clock-bias state (bias, drift, drift-rate) using a ClockDynamics model and exposes the agent’s current “true” time via Read.

Attached to a satellite/rover/ground-station Agent (e.g. as the "clock" device) and used by ClockDynamics/JointOrbitClockDynamics to propagate clock error states for measurement simulation (pseudorange/ carrier-phase clock-bias terms in measurements/) and by navigation filters as the truth/reference against which receiver clock states are estimated.

Public Functions

Clock()
Clock(Config &config)
Real Read(Real t)

Propagate the clock state from its last-read time to t and return the resulting clock time (true time t plus the current clock bias, converted from bias_unit_ to seconds) [s].

Called whenever a device/measurement model needs the agent’s clock reading instead of true simulation time (e.g. when generating timestamped GNSS measurements). Internally advances state_ via ClockDynamics::Propagate (or PropagateWithRelativity if use_relativity_ is enabled, using BuildRelativityContext) from the previously stored time_ to t, updates time_ = t, and adds the propagated bias (converted to seconds via ClockDynamics::BiasUnitsToSeconds) to t.

Parameters:

tSimulation (true) time to read the clock at [s]; must be >= the time of the previous Read/current time_

Returns:

Clock-reading time = t + bias [s]

virtual void Step(Real t) override

Clock device step; currently a no-op (clock propagation happens lazily in Read).

virtual void Setup() override

Clock device setup; currently a no-op.

void SetModel(ClockModel model)

Set the clock noise/drift model (e.g. USO, CSAC, RAFS) and propagate it to the underlying ClockDynamics.

inline ClockModel GetModel() const

Get the configured clock noise/drift model.

inline void SetState(const ClockState3 &state)

Set the clock-bias state (bias, drift, drift-rate) and refresh its unit labels via ApplyClockStateUnits.

inline ClockState3 GetState() const

Get the current clock-bias state (bias, drift, drift-rate), in units given by GetClockBiasUnit.

inline void SetTime(Real time)

Set the clock’s internal last-propagated time [s] (does not propagate the state).

inline Real GetTime() const

Get the clock’s internal last-propagated time [s] (the time argument of the most recent Read call).

void SetClockBiasUnit(ClockBiasUnit unit)

Set the unit (seconds, range-equivalent meters, or kilometers) in which the clock-bias state is represented, and propagate it to the underlying ClockDynamics.

inline ClockBiasUnit GetClockBiasUnit() const

Get the unit in which the clock-bias state is represented.

inline void SetUseRelativity(bool use_relativity)

Enable/disable general-relativistic clock-rate corrections (gravitational frequency shift + special-relativistic time dilation) in Read, via ClockDynamics::PropagateWithRelativity.

inline bool GetUseRelativity() const

Whether relativistic clock-rate corrections are applied in Read.

inline void SetRelativityCenterBody(BodyId center_body)

Set the central body (e.g. BodyId::EARTH) whose gravitational potential and inertial frame define the relativistic clock-rate correction computed in BuildRelativityContext.

inline BodyId GetRelativityCenterBody() const

Get the relativity center body (see SetRelativityCenterBody).

inline bool HasRelativityCenterBody() const

Whether a relativity center body has been explicitly set; if false, BuildRelativityContext falls back to the frame center of the agent’s state at the propagation end time.

inline void ClearRelativityCenterBody()

Clear a previously-set relativity center body (see HasRelativityCenterBody).

inline void SetRelativityUnits(const UnitSystem &units)

Set the unit system (e.g. SI) used to look up the relativity center body’s physical constants (GM, speed of light) in BuildRelativityContext.

inline UnitSystem GetRelativityUnits() const

Get the unit system used for relativity-related physical constants.

void SetDynamics(Ptr<ClockDynamics> dynamics)

Replace the underlying ClockDynamics model, propagating the current clock model and bias unit to it.

inline ClockDynamics *GetDynamics() const

Get a raw (non-owning) pointer to the underlying ClockDynamics.

inline Ptr<ClockDynamics> GetDynamicsSharedPtr() const

Get a shared pointer to the underlying ClockDynamics.

virtual void Log(Real time) override

Log the clock’s current time and bias-state components (with unit-aware names, e.g. "<name>/state/b_s") to the simulation’s DataLogger output. Overrides Device::Log.