YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
yams::telemetry::DoubleTelemetry< F > Class Template Reference

#include <SmartMotorControllerTelemetry.hpp>

Public Member Functions

 DoubleTelemetry (std::string key, double defaultVal, F field, bool tunable, std::string unit)
void SetDefaultValue (double value)
void SetupNetworkTables (std::shared_ptr< wpi::nt::NetworkTable > dataTable, std::shared_ptr< wpi::nt::NetworkTable > tuningTable)
void SetupNetworkTable (std::shared_ptr< wpi::nt::NetworkTable > dataTable)
void SetupDataLog (const std::string &prefix)
void TransformUnit (const motorcontrollers::SmartMotorControllerConfig &cfg)
void ForceSet (double value)
bool Set (double value)
double Get () const
bool IsTunable ()
void Enable ()
void Disable ()
void Display (bool state)
F GetField () const
bool IsEnabled () const
void Close ()

Detailed Description

template<typename F>
class yams::telemetry::DoubleTelemetry< F >

NT4 pub/sub wrapper for a single double-valued telemetry field.

Tunable fields use a subscriber so that values changed in NetworkTables are reflected back into the motor controller via ApplyTuningValues. Read-only fields only publish.

Generic over the enum type F identifying which field this entry represents, so the same wrapper can be reused across unrelated telemetry coordinators (e.g. SmartMotorControllerTelemetry uses DoubleTelemetry<DoubleTelemetryField>, while SwerveDriveTelemetry uses its own field enum).

Template Parameters
FEnum type identifying which field this telemetry entry represents.

Constructor & Destructor Documentation

◆ DoubleTelemetry()

template<typename F>
yams::telemetry::DoubleTelemetry< F >::DoubleTelemetry ( std::string key,
double defaultVal,
F field,
bool tunable,
std::string unit )
inline

Construct a DoubleTelemetry entry.

Parameters
keyNT4 table key for this field.
defaultValDefault numeric value published on startup.
fieldField identifier.
tunabletrue if the field should be placed in the tuning table with a subscriber.
unitUnit string embedded in the NT4 topic metadata (e.g. "amps", "volts").

Member Function Documentation

◆ Close()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::Close ( )
inline

Release all NT4 publishers/subscribers and DataLog entries.

◆ Disable()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::Disable ( )
inline

Disable this field so publishing and reading are skipped.

◆ Display()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::Display ( bool state)
inline

Enable or disable this field.

Parameters
statetrue to enable.

◆ Enable()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::Enable ( )
inline

Enable this field so it is published / read each loop.

◆ ForceSet()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::ForceSet ( double value)
inline

Forcibly overwrite the tunable value in NetworkTables, bypassing the subscriber-must-match guard in Set(double). The next IsTunable() reports the change, as if it was made on the dashboard.

Parameters
valueValue to force.

◆ Get()

template<typename F>
double yams::telemetry::DoubleTelemetry< F >::Get ( ) const
inline

Read the current value from the subscriber (tunable) or return the default.

Returns
Current field value.

◆ GetField()

template<typename F>
F yams::telemetry::DoubleTelemetry< F >::GetField ( ) const
inline
Returns
The field identifier for this entry.

◆ IsEnabled()

template<typename F>
bool yams::telemetry::DoubleTelemetry< F >::IsEnabled ( ) const
inline
Returns
true if this field is currently enabled.

◆ IsTunable()

template<typename F>
bool yams::telemetry::DoubleTelemetry< F >::IsTunable ( )
inline

Return true if a tunable subscriber is active and the value has changed since the last call.

Returns
true when the NT4 subscriber holds a value different from the cached value.

◆ Set()

template<typename F>
bool yams::telemetry::DoubleTelemetry< F >::Set ( double value)
inline

Publish a value; returns false if the field is disabled or a tunable subscriber disagrees.

Parameters
valueValue to publish.
Returns
true if the value was accepted and published.

◆ SetDefaultValue()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::SetDefaultValue ( double value)
inline

Override the default published value (e.g. to seed a limit from the config).

Parameters
valueNew default value.

◆ SetupDataLog()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::SetupDataLog ( const std::string & prefix)
inline

Create a DataLog entry under the given prefix path.

Parameters
prefixDataLog path prefix (a trailing "/" is added if missing).

◆ SetupNetworkTable()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::SetupNetworkTable ( std::shared_ptr< wpi::nt::NetworkTable > dataTable)
inline

Create a read-only NT4 publisher under the data table (no tuning table).

Parameters
dataTableNT4 table for sensor data.

◆ SetupNetworkTables()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::SetupNetworkTables ( std::shared_ptr< wpi::nt::NetworkTable > dataTable,
std::shared_ptr< wpi::nt::NetworkTable > tuningTable )
inline

Create the NT4 publisher (and subscriber if tunable) under the given tables.

Parameters
dataTableNT4 table for read-only sensor data.
tuningTableNT4 table for live-tunable gains.

◆ TransformUnit()

template<typename F>
void yams::telemetry::DoubleTelemetry< F >::TransformUnit ( const motorcontrollers::SmartMotorControllerConfig & cfg)
inline

Resolve the "tunable_*" / "position" / "velocity" unit placeholders to concrete unit strings based on whether the config uses linear (meter) or angular (degree/rotation) control.

Parameters
cfgSmartMotorControllerConfig used to determine the active measurement space.

The documentation for this class was generated from the following file: