Class State

Inheritance Relationships

Base Type

  • public VecX

Derived Types

Class Documentation

class State : public VecX

Generic labeled state vector: a VecX augmented with a type tag, per-element names/units, and a reference Frame.

This is the common base class for all concrete state representations used throughout LuPNT (e.g. Cart6, ClassicalOE, ClockState3, AttitudeState). Dynamics models (Dynamics::Propagate, Dynamics::PropagateWithParams), frame conversions (ConvertFrame, ConvertState), filters (Filter, JointState), and measurement models pass and return State objects so that the numerical vector always carries along its type/frame/units metadata for bookkeeping, logging (ToString), and runtime type checks (LUPNT_CHECK(x.GetType() == ...)).

Subclassed by lupnt::Acceleration, lupnt::AngularVelocity, lupnt::Attitude, lupnt::AzElRange, lupnt::Cart2, lupnt::Cart3, lupnt::Cart6, lupnt::ClassicalOE, lupnt::ClockState2, lupnt::ClockState3, lupnt::DelaunayOE, lupnt::EquinoctialOE, lupnt::ImuState, lupnt::JointOrbitClockState, lupnt::LatLonAlt, lupnt::ParamState, lupnt::QuasiNonsingROE, lupnt::QuasiNonsingularOE, lupnt::Quaternion, lupnt::RelCart6, lupnt::RollPitchYaw, lupnt::SingularROE, lupnt::SurfaceState2D

Public Functions

State()

Construct an empty (zero-length) state.

State(int n)

Construct a zero-initialized state of length n, with placeholder names/units (see SetNamesAndUnits).

Parameters:

n – Number of elements in the state vector.

State(int rows, int cols)

Construct a zero-initialized column-vector state with rows elements; cols must be 1.

Parameters:
  • rows – Number of elements (vector length).

  • cols – Must be 1 (states are always column vectors); checked via LUPNT_CHECK.

State(const VecX &vec, const std::vector<std::string> &names, const std::vector<std::string> &units)

Construct a state from a raw vector together with explicit per-element names and units.

Used e.g. by Dynamics::Propagate/filter_utils to wrap a propagated numerical vector back into a State while preserving the original state’s element labels and units.

Parameters:
  • vec – Underlying numerical values.

  • names – Per-element variable names (same length as vec).

  • units – Per-element unit strings (same length as vec).

template<typename T, int N>
State(const State &state, const Vector<T, N> &vec)

Construct a state by copying the type/names/units/frame metadata from state but using the numerical values from vec.

Used when a derived-state type needs to rebuild itself from a plain Eigen vector (e.g. after an arithmetic operation) while keeping the original state’s labeling.

Parameters:
  • state – Source state to copy type/names/units/frame from.

  • vec – New numerical values (must match state’s size).

State(const State &other)

Copy constructor: copies the numerical vector plus type/names/units/frame metadata from other.

template<typename Derived, typename = std::enable_if_t<(Derived::ColsAtCompileTime == 1 || Derived::RowsAtCompileTime == 1)>>
inline State(const Eigen::DenseBase<Derived> &x)

Construct a state directly from any Eigen column- or row-vector expression, assigning placeholder names/units via SetNamesAndUnits.

Enables implicit/explicit construction of State (and derived types) from Eigen vector expressions (e.g. Vec6, head()/tail() slices) throughout the dynamics and conversion code.

Parameters:

x – Eigen vector (or row-vector) expression to copy values from.

void SetFrame(Frame frame)

Set the reference frame (e.g. Frame::GCRF, Frame::MOON_CI) this state’s coordinates are expressed in. Read by ConvertFrame / ConvertState to determine the source frame for a conversion.

void SetType(StateType type)

Set the state-type tag (e.g. Cart6::TYPE, ClassicalOE::TYPE), used by LUPNT_CHECK(x.GetType() == ...) runtime checks throughout the dynamics/conversion code to verify a State holds the expected representation.

void SetName(const std::string &name)

Set the human-readable name of this state (e.g. for logging).

void SetNames(const std::vector<std::string> &names)

Set the per-element variable names (e.g. {“r_x”,”r_y”,…}), used by ToString/formatters and by JointState when concatenating sub-states into a combined labeled vector.

void SetUnits(const std::vector<std::string> &units)

Set the per-element unit strings (e.g. {“m”,”m”,”m”,”m/s”,…}), used by ToString/formatters and by JointState when concatenating sub-states into a combined labeled vector.

Frame GetFrame() const

Get the reference frame this state’s coordinates are expressed in.

Returns:

Reference frame (e.g. Frame::GCRF, Frame::MOON_CI).

StateType GetType() const

Get the state-type tag (e.g. Cart6::TYPE).

Returns:

State type identifier string.

std::string GetName() const

Get the human-readable name of this state.

std::vector<std::string> GetNames() const

Get the per-element variable names.

Returns:

Names, one per element of this state vector.

std::vector<std::string> GetUnits() const

Get the per-element unit strings.

Returns:

Units, one per element of this state vector.

State &operator=(const State &other)

Copy-assign the numerical vector plus type/names/units/frame metadata from other.

template<typename Derived, typename = std::enable_if_t<(Derived::ColsAtCompileTime == 1 || Derived::RowsAtCompileTime == 1)>>
inline State &operator=(const Eigen::DenseBase<Derived> &x)

Assign this state’s numerical values from any Eigen column- or row-vector expression, leaving existing type/names/units/frame metadata unchanged.

Parameters:

x – Eigen vector (or row-vector) expression to copy values from (must match this state’s size).

std::string ToString() const

Format this state as "<Type>(<values>, <Frame>)" for logging and debugging (e.g. via fmt::format / the fmt::formatter<State> specialization below).

Returns:

Human-readable string representation of this state.

Public Static Attributes

static StateType TYPE = UNDEFINED