Class AbstractConfig

java.lang.Object
frc.robot.shared.config.AbstractConfig
Direct Known Subclasses:
AbstractSubsystemConfig, DpadTargetConfig, DriverControllerConfig, FeedforwardConfig, MotorConfig, PidConfig, PoseFilterConfig, SetAndSeekMotionConfig, SysIdRoutineConfig, TrenchZoneConfig, TriggerBindingsConfig, VelocityMotionConfig

public abstract class AbstractConfig extends Object
Base configuration bundle that mirrors values to AdvantageKit-backed SmartDashboard entries so they can be tuned without redeploying. Concrete configs inherit the tunable readers provided here.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Describes the 3D pivot offset for an articulated component in AdvantageScope.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a config base and derives the default SmartDashboard prefix from the class name.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    Returns the current SmartDashboard prefix used for tunable key resolution.
    void
    Recursively sets the SmartDashboard prefix on nested AbstractConfig fields so their tunable keys appear under the parent's namespace.
    protected boolean
    readTunableBoolean(String key, boolean defaultValue)
    Reads a tunable boolean backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency.
    protected double
    readTunableDegrees(String key, double fallbackDegrees)
    Reads a tunable number that represents degrees.
    protected double
    readTunableDegreesAsRadians(String key, double fallbackDegrees)
    Reads a tunable number stored in degrees and returns the value in radians.
    protected double
    readTunableNumber(String key, double defaultValue)
    Reads a tunable number backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency.
    protected String
    readTunableString(String key, String defaultValue)
    Reads a tunable string backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency.
    void
    Overrides the SmartDashboard prefix used for tunable key resolution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractConfig

      protected AbstractConfig()
      Creates a config base and derives the default SmartDashboard prefix from the class name.

      Subclasses should call this implicitly when deserialized from JSON.

  • Method Details

    • setDashboardPrefix

      public void setDashboardPrefix(String prefix)
      Overrides the SmartDashboard prefix used for tunable key resolution.

      Call this after Jackson deserialization to propagate a parent config's prefix into nested config objects so their tunable keys appear under the parent's namespace (e.g., FeederSubsystem/pid/kP instead of Pid/kP).

      Parameters:
      prefix - the new dashboard prefix including a trailing slash (e.g., "FeederSubsystem/pid/")
    • initializeNestedDashboardPrefixes

      public void initializeNestedDashboardPrefixes()
      Recursively sets the SmartDashboard prefix on nested AbstractConfig fields so their tunable keys appear under the parent's namespace.

      Call this after Jackson deserialization. For each public field of type AbstractConfig (that is not an AbstractSubsystemConfig), the method sets the field's prefix to parentPrefix + fieldName + "/" and then recurses into that field. Arrays of AbstractConfig are also handled: each element receives a prefix of parentPrefix + fieldName + "/" + index + "/" so that every element has unique tunable keys. Subsystem configs are skipped because they own their own prefix based on their class name.

    • getDashboardPrefix

      protected String getDashboardPrefix()
      Returns the current SmartDashboard prefix used for tunable key resolution.
      Returns:
      the dashboard prefix (includes trailing slash)
    • readTunableNumber

      protected double readTunableNumber(String key, double defaultValue)
      Reads a tunable number backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency. Warning: when FMS is attached, this short-circuits to the default and does not create or read any dashboard entry.
      Parameters:
      key - dashboard key suffix to read (class prefix is applied automatically)
      defaultValue - fallback value used when FMS is attached or no entry exists
      Returns:
      latest tunable number or the provided default when FMS is attached
    • readTunableBoolean

      protected boolean readTunableBoolean(String key, boolean defaultValue)
      Reads a tunable boolean backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency. Warning: when FMS is attached, this short-circuits to the default and does not create or read any dashboard entry.
      Parameters:
      key - dashboard key suffix to read (class prefix is applied automatically)
      defaultValue - fallback value used when FMS is attached or no entry exists
      Returns:
      latest tunable boolean or the provided default when FMS is attached
    • readTunableString

      protected String readTunableString(String key, String defaultValue)
      Reads a tunable string backed by AdvantageKit's logged network inputs so tweaks are captured in logs and respected during replay, but still falls back to the default when attached to FMS to avoid match-time latency. Warning: when FMS is attached, this short-circuits to the default and does not create or read any dashboard entry.
      Parameters:
      key - dashboard key suffix to read (class prefix is applied automatically)
      defaultValue - fallback value used when FMS is attached or no entry exists
      Returns:
      latest tunable string or the provided default when FMS is attached
    • readTunableDegrees

      protected double readTunableDegrees(String key, double fallbackDegrees)
      Reads a tunable number that represents degrees.

      Use this helper when the stored value is in degrees so all configs share the same conversion pattern.

      Parameters:
      key - dashboard key suffix to read (class prefix is applied automatically)
      fallbackDegrees - fallback value in degrees used when FMS is attached or no entry exists
      Returns:
      latest tunable value in degrees, or the provided fallback when FMS is attached
    • readTunableDegreesAsRadians

      protected double readTunableDegreesAsRadians(String key, double fallbackDegrees)
      Reads a tunable number stored in degrees and returns the value in radians.

      Call this when your config stores angles in degrees but your subsystem expects radians.

      Parameters:
      key - dashboard key suffix to read (class prefix is applied automatically)
      fallbackDegrees - fallback value in degrees used when FMS is attached or no entry exists
      Returns:
      latest tunable value in radians, or the provided fallback when FMS is attached