Class Agent

Inheritance Relationships

Base Types

Derived Type

Class Documentation

class Agent : public lupnt::Object<Agent>, public lupnt::DataLogger

Subclassed by lupnt::AgentWithDynamics

Public Functions

Agent() = default
Agent(Config &agent_config)

Construct an agent from a YAML config node, creating and attaching its devices (and, if specified, application).

Called by AssetFactory<Agent, Config&> (via AgentFactory) when the simulation builder instantiates the agents: section of a scenario config; reads name, frequency, devices, and application keys and creates each listed device/application through its own factory, wiring it back to this agent via AddDevice/SetApplication.

Parameters:

agent_config – YAML config node for this agent

inline Simulation *GetSimulation() const

Get the Simulation this agent is registered with.

Returns:

Pointer to the owning Simulation (aborts via LUPNT_CHECK if the agent has not yet been added to one).

inline void SetSimulation(Simulation *sim)

Register this agent with a Simulation, called by Simulation::AddAgent so that GetSimulation/Setup can access the event scheduler and Cesium viewer.

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].

inline std::string GetName() const

Get the agent’s name (used as a prefix for device names and data-logger keys).

inline void SetName(std::string name)

Set the agent’s name.

inline std::map<std::string, Ptr<Device>> GetDevices() const

Get the map of devices (camera, clock, radio, etc.) attached to this agent, keyed by device name.

void AddDevice(Ptr<Device> device)

Attach a Device to this agent, called during construction (from the devices: section of the config) or by application setup code that adds devices programmatically. Sets the device’s back-link to this agent and registers it under device->GetName().

Parameters:

deviceDevice to attach; ownership is transferred into devices_

Ptr<Device> GetDevice(const std::string &name) const

Look up a previously-attached device by name, trying both the bare name and <agent_name>/<name> (the convention used by AddDevice/Agent::Agent). Used by application/measurement code to retrieve e.g. a Clock or Transmitter device from its owning agent. Aborts via LUPNT_CHECK if no matching device is found.

Parameters:

nameDevice name (with or without the <agent_name>/ prefix)

Returns:

The matching device

inline Ptr<Application> GetApplication() const

Get the Application attached to this agent (e.g. an LNSS, rover, or surface-station application), if any.

inline void SetApplication(Ptr<Application> app)

Attach an Application to this agent, called during construction (from the application: section of the config).

virtual void Setup()

Perform one-time setup before the simulation starts: schedules a periodic Step callback with the simulation event scheduler (if frequency_ > 0) and calls Setup on each attached device.

Called once by Simulation::Setup for every registered agent, before the main time-stepping loop begins. AgentWithDynamics and GnssConstellation override/extend this for their own initialization needs.

virtual void Step(Real time)

Advance the agent by one simulation step at time time (propagate dynamics, update devices/application, and log state).

Invoked periodically by the simulation’s event scheduler at the rate configured via frequency_ (see Setup). The base implementation is a no-op (logging only); AgentWithDynamics::Step overrides it to call Propagate and Log.

Parameters:

time – Current simulation time [s]

inline State GetState() const

Get the agent’s current state. The base Agent class has no intrinsic state representation and always returns an empty State(); derived classes such as AgentWithDynamics override this to return their Cartesian/orbital state.

inline void SetState(const State &state)

Set the agent’s current state (base-class no-op storage; see AgentWithDynamics::SetState for the overload that actually drives dynamics propagation).

virtual Cart6 GetStateAt(Real t) const = 0

Compute (or interpolate/propagate) the agent’s Cartesian state [r; v] at an arbitrary time t, without mutating the agent’s stored state/time.

Pure virtual: every concrete agent (Satellite, Rover, GroundStation, SurfaceStation, …) must provide this so that measurement models and other agents can query “where was/will this agent be at time `t`” (e.g. for light-time-corrected GNSS pseudorange computation).

Parameters:

t – Query time [s]

Returns:

Cartesian state [r; v] at time t, in the agent’s dynamics frame

virtual void Log(Real time)

Write this agent’s state/devices/application to the DataLogger. Called once per Step (after propagation) by AgentWithDynamics::Step; the base implementation is a no-op.

Parameters:

time – Current simulation time [s]

virtual void LogCesium()

Push this agent’s current state/geometry to the Cesium 3D viewer (if one is attached to the simulation). Called once per Step alongside Log; the base implementation is a no-op.

Protected Attributes

std::string name_
Simulation *sim_ = nullptr
Config config_
Real frequency_ = 0.0
Real time_ = 0.0
State state_ = State()
std::map<std::string, Ptr<Device>> devices_
Ptr<Application> application_