Class AgentWithDynamics

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class AgentWithDynamics : public lupnt::Agent

Subclassed by lupnt::GroundStation, lupnt::Rover, lupnt::Satellite, lupnt::SurfaceStation

Public Functions

AgentWithDynamics() = default
AgentWithDynamics(Config &agent_config)

Construct an agent with orbital and attitude dynamics from a YAML config node.

Extends Agent::Agent: in addition to devices/application, creates the dynamics: and attitude_dynamics: blocks via their respective AssetFactory (defaulting attitude dynamics to FixedAttitudeDynamics if not specified), initializes state_/ attitude_ to zero in the MOON_CI frame, and reads the optional precompute interval. Used as the base constructor for Satellite, Rover, GroundStation, and SurfaceStation.

Parameters:

agent_config – YAML config node for this agent

virtual void Setup() override

Base-class setup (schedule periodic Step, set up devices); AgentWithDynamics currently adds no further initialization beyond Agent::Setup.

virtual void Step(Real time) override

Advance this agent by one simulation step: propagate orbital/attitude dynamics to time via Propagate, then log the resulting state via Log.

Parameters:

time – Target simulation time [s]

inline Real GetTime() const

Get the agent’s current simulation time [s].

inline void SetTime(Real t)

Set the agent’s current simulation time [s] (without propagating; use Propagate to advance the state consistently).

inline Real GetFrequency() const

Get the agent’s Step scheduling frequency [Hz].

inline void SetFrequency(Real frequency)

Set the agent’s Step scheduling frequency [Hz], used by Setup to register the periodic simulation callback.

inline State GetState() const

Get the agent’s current Cartesian state [r; v] (in the frame returned by dynamics_->GetFrame(), typically MOON_CI).

inline void SetState(const State &x)

Set the agent’s current Cartesian state [r; v], e.g. to initialize a scenario or apply a filter/estimator correction.

inline Attitude GetAttitude() const

Get the agent’s current attitude (quaternion + angular rate).

inline void SetAttitude(const Attitude &attitude)

Set the agent’s current attitude (quaternion + angular rate).

inline State GetControl() const

Get the agent’s current control input (e.g. rover linear/angular velocity commands), passed to dynamics_->Propagate.

inline void SetControl(const State &control)

Set the agent’s current control input, applied on the next call to Propagate/Step.

inline Dynamics *GetDynamics() const

Get the orbital/translational Dynamics model driving Propagate.

Returns:

Raw pointer to the dynamics model (aborts via LUPNT_CHECK if none has been set).

inline void SetDynamics(Ptr<Dynamics> dyn)

Set the orbital/translational dynamics model, called during construction (from the dynamics: config block) or to swap dynamics models at runtime.

inline AttitudeDynamics *GetAttitudeDynamics() const

Get the AttitudeDynamics model driving attitude propagation in Propagate/GetAttitudeAt.

Returns:

Raw pointer to the attitude dynamics model (aborts via LUPNT_CHECK if none has been set).

inline void SetAttitudeDynamics(Ptr<AttitudeDynamics> dyn)

Set the attitude dynamics model, called during construction (from the attitude_dynamics: config block, defaulting to FixedAttitudeDynamics) or to swap models at runtime.

inline void SetBodyId(BodyId body_id)

Set the ID of the central body this agent’s dynamics are referenced to (e.g. BodyId::EARTH, BodyId::MOON).

inline BodyId GetBodyId() const

Get the ID of the central body this agent’s dynamics are referenced to.

virtual void Propagate(Real t)

Advance the agent’s stored orbital state, attitude, and time from time_ to t by integrating dynamics_/attitude_dynamics_.

Called once per Step by AgentWithDynamics::Step (and overridden by Rover::Propagate for its 2D surface-dynamics model). Mutates state_, attitude_, and time_ in place using the current control_.

Parameters:

t – Target simulation time [s]

virtual Cart6 GetStateAt(Real t) const override

Compute the agent’s Cartesian state [r; v] at time t without mutating the stored state.

If t matches the agent’s current time_ (within EPS), returns the cached state_ directly; otherwise propagates a copy of state_ from time_ to t via dynamics_->Propagate. Used by measurement models and other agents to query this agent’s position/velocity at an arbitrary (e.g. light-time-corrected) epoch.

Parameters:

t – Query time [s]

Returns:

Cartesian state [r; v] at time t

virtual Attitude GetAttitudeAt(Real t) const

Compute the agent’s attitude at time t without mutating the stored attitude.

If t matches time_ (within EPS), or no attitude dynamics are set, returns the cached attitude_ directly; otherwise propagates a copy of attitude_ from time_ to t via attitude_dynamics_->Propagate.

Parameters:

t – Query time [s]

Returns:

Attitude (quaternion + angular rate) at time t

virtual void Log(Real time) override

Log this agent’s state, attitude, and control vectors (and the attached application’s state, if any) to the DataLogger. Called once per Step by AgentWithDynamics::Step.

Parameters:

time – Current simulation time [s]

virtual void LogCesium() override

Push this agent’s geometry to the Cesium 3D viewer. Currently a no-op for the base AgentWithDynamics; Satellite/SurfaceStation override it (see their respective headers).

Protected Attributes

BodyId body_id_
Real precompute_ = 0.0
Real frequency_ = 0.0
Real time_ = 0.0
Cart6 state_
Attitude attitude_
State control_
Ptr<Dynamics> dynamics_
Ptr<AttitudeDynamics> attitude_dynamics_