YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yams::telemetry::MechanismTelemetry Class Reference

#include <MechanismTelemetry.hpp>

Public Member Functions

void SetupTelemetry (const std::string &mechanismName, motorcontrollers::SmartMotorController &motorController)
 
void SetupTelemetry (const std::string &mechanismName)
 
void SetupTelemetry (const std::string &mechanismName, const std::string &dataLogName)
 
void AddMotorController (const std::string &subTableName, motorcontrollers::SmartMotorController &motorController)
 
std::function< void(double)> PublishDouble (const std::string &key, const std::string &unit="")
 
template<typename T >
std::function< void(const T &)> PublishStruct (const std::string &key)
 
template<typename T >
std::function< void(std::span< const T >)> PublishStructArray (const std::string &key)
 
void UpdateLoopTime ()
 
std::shared_ptr< wpi::nt::NetworkTable > GetDataTable () const
 
std::shared_ptr< wpi::nt::NetworkTable > GetTuningTable () const
 

Detailed Description

Mechanism-level telemetry coordinator.

Manages the root NT4 tables under "Mechanisms/<name>" and "Tuning/<name>", publishes loop timing, and is the primary coordinator of mechanism telemetry: every field published through PublishDouble()/PublishStruct()/PublishStructArray(), and every SmartMotorController wired in through SetupTelemetry() or AddMotorController(), shares this mechanism's tables and (optionally) DataLog prefix.

Member Function Documentation

◆ AddMotorController()

void yams::telemetry::MechanismTelemetry::AddMotorController ( const std::string &  subTableName,
motorcontrollers::SmartMotorController &  motorController 
)

Wire an additional SmartMotorController's telemetry into a named child table of this mechanism, without disturbing the mechanism's own data/tuning table references or loop-time publisher.

Use this for mechanisms driven by more than one SmartMotorController (e.g. a swerve module's drive and azimuth motors, or a differential mechanism's left and right motors) so that every motor shares the single SetupTelemetry() call and loop timer for the mechanism, instead of each motor re-running SetupTelemetry(name, motorController) and clobbering the previous motor's table/loop-time state.

Parameters
subTableNameName of the child table to nest this motor's telemetry under, relative to the mechanism's data and tuning tables.
motorControllerSmartMotorController to set up telemetry for.

◆ GetDataTable()

std::shared_ptr< wpi::nt::NetworkTable > yams::telemetry::MechanismTelemetry::GetDataTable ( ) const
Returns
The data NT4 table ("Mechanisms/<name>").

◆ GetTuningTable()

std::shared_ptr< wpi::nt::NetworkTable > yams::telemetry::MechanismTelemetry::GetTuningTable ( ) const
Returns
The tuning NT4 table ("Tuning/<name>").

◆ PublishDouble()

std::function< void(double)> yams::telemetry::MechanismTelemetry::PublishDouble ( const std::string &  key,
const std::string &  unit = "" 
)

Publish a mechanism-level double field under this mechanism's data table, and if this mechanism was set up with a DataLog name via SetupTelemetry(name, dataLogName) to the DataLog as well. For fields tied to a SmartMotorController use SetupTelemetry(name, smc) or AddMotorController() instead.

Parameters
keyNetworkTables key, relative to this mechanism's data table.
unitUnit metadata for the field (consumed by Advantage Scope/Elastic), or an empty string for none.
Returns
Callable to push values to.

◆ PublishStruct()

template<typename T >
std::function< void(const T &)> yams::telemetry::MechanismTelemetry::PublishStruct ( const std::string &  key)
inline

Publish a mechanism-level struct field under this mechanism's data table, and if this mechanism was set up with a DataLog name via SetupTelemetry(name, dataLogName) to the DataLog as well.

Template Parameters
TType of the published value.
Parameters
keyNetworkTables key, relative to this mechanism's data table.
Returns
Callable to push values to.

◆ PublishStructArray()

template<typename T >
std::function< void(std::span< const T >)> yams::telemetry::MechanismTelemetry::PublishStructArray ( const std::string &  key)
inline

Publish a mechanism-level struct array field under this mechanism's data table, and if this mechanism was set up with a DataLog name via SetupTelemetry(name, dataLogName) to the DataLog as well.

Template Parameters
TType of the published array elements.
Parameters
keyNetworkTables key, relative to this mechanism's data table.
Returns
Callable to push values to.

◆ SetupTelemetry() [1/3]

void yams::telemetry::MechanismTelemetry::SetupTelemetry ( const std::string &  mechanismName)

Set up NT4 tables for a named mechanism (no motor controller).

Parameters
mechanismNameTelemetry name (sub-table key).

◆ SetupTelemetry() [2/3]

void yams::telemetry::MechanismTelemetry::SetupTelemetry ( const std::string &  mechanismName,
const std::string &  dataLogName 
)

Set up NT4 tables for a named mechanism, additionally logging every field published through PublishDouble(), PublishStruct(), and PublishStructArray() to a WPILib DataLog under the given name.

Parameters
mechanismNameTelemetry name (sub-table key).
dataLogNameDataLog entry name prefix for this mechanism's fields.

◆ SetupTelemetry() [3/3]

void yams::telemetry::MechanismTelemetry::SetupTelemetry ( const std::string &  mechanismName,
motorcontrollers::SmartMotorController &  motorController 
)

Set up NT4 tables and SMC telemetry for a named mechanism.

Parameters
mechanismNameTelemetry name (sub-table key).
motorControllerMotor controller to set up telemetry for.

◆ UpdateLoopTime()

void yams::telemetry::MechanismTelemetry::UpdateLoopTime ( )

Publish loop time (time since the last call) to NT4.


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