Class Device

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class Device : public lupnt::DataLogger

Base class for all onboard hardware devices (clocks, IMUs, cameras, comms radios) that can be attached to an Agent.

Concrete devices (Clock, Imu, Camera, Transmitter/Receiver/ Transponder, GnssTransmitter/GnssReceiver) derive from Device and override Step/Setup/Log to plug into the agent’s simulation loop: Setup is called once during agent initialization to register the device (e.g. schedule periodic Step calls or bind to a Channel), and Step is then invoked by the Simulation event scheduler at the device’s configured frequency_ to advance its internal state/dynamics and produce measurements. DataLogger::Log is used by Step overrides to record device state to the simulation output.

Subclassed by lupnt::Camera, lupnt::Clock, lupnt::Imu, lupnt::Receiver, lupnt::Transmitter, lupnt::Transponder

Public Functions

Device() = default
Device(Config &config)

Construct a device from a YAML config node, reading the common name and (optional) frequency [Hz] fields used by Agent/ Simulation to schedule periodic Step calls.

virtual ~Device() = default
virtual void Step(Real t)

Advance the device’s internal state/dynamics by one simulation step at time t [s].

Called by the Simulation event scheduler (via the periodic event registered in Setup) once per device update at the device’s configured frequency_. Derived devices (Clock, Imu, Camera, comms radios) override this to propagate dynamics, generate measurements, and/or log state.

Parameters:

tSimulation time of this step [s]

virtual void Setup()

One-time initialization performed when the device is attached to an Agent and the simulation is built.

The base implementation schedules a recurring Step event (priority Event::Priority::DEVICE) on the owning agent’s Simulation if frequency_ > 0. Derived devices (e.g. Transmitter/Receiver/ Transponder) override this to additionally resolve their Channel from the simulation by name.

inline std::string GetName() const

Human-readable identifier for this device, used in log messages and DataLogger output paths (e.g. "<name>/state/...").

inline void SetName(std::string name)

Set the device’s identifier (see GetName).

inline Agent *GetAgent() const

The Agent this device is attached to (e.g. a satellite, rover, or ground station), or nullptr if not yet attached.

inline void SetAgent(Agent *agent)

Attach this device to an owning Agent (called by Agent::AddDevice).

inline Real GetFrequency() const

Update rate at which Step is scheduled [Hz]; 0 means no periodic stepping is scheduled by the base Setup.

inline void SetFrequency(Real frequency)

Set the periodic Step update rate [Hz] (see GetFrequency).

inline virtual void Log(Real time)

Record this device’s current state to the simulation’s DataLogger output at time t [s]. Overridden by derived devices (e.g. Clock::Log) to log model-specific quantities; the base implementation is a no-op.

Protected Attributes

Config config_
Real frequency_ = 0.0
std::string name_
Agent *agent_ = nullptr
Real time_ = 0.0