#include <MechanismTelemetry.hpp>
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.
◆ AddMotorController()
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
-
| subTableName | Name of the child table to nest this motor's telemetry under, relative to the mechanism's data and tuning tables. |
| motorController | SmartMotorController 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
-
| key | NetworkTables key, relative to this mechanism's data table. |
| unit | Unit 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
-
| T | Type of the published value. |
- Parameters
-
| key | NetworkTables 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
-
| T | Type of the published array elements. |
- Parameters
-
| key | NetworkTables 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
-
| mechanismName | Telemetry 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
-
| mechanismName | Telemetry name (sub-table key). |
| dataLogName | DataLog entry name prefix for this mechanism's fields. |
◆ SetupTelemetry() [3/3]
Set up NT4 tables and SMC telemetry for a named mechanism.
- Parameters
-
| mechanismName | Telemetry name (sub-table key). |
| motorController | Motor 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: