Class Params
java.lang.Object
frc.spectrumLib.params.Params
Robot params: values tuned on the robot that survive the next deploy, without editing code.
Layers
Each param is declared in code (ParamGroup) and resolved from these layers, later ones
winning:
- the default in the declaration;
<deploy>/params/<group>.json, in git;<deploy>/params/robots/<robot>/<group>.json, for one robot, in git;<robot>/<group>.jsonin the robot-local folder (e.g./home/systemcore/params/FM2026/), which a deploy does not wipe: what was saved in the pit. A hard-stop group's file is used only on the robot it was saved on (HardwareStamp);- live changes from the dashboard, only with a transport (tuning mode) and only while
disabled with no field attached (
liveChangesAllowed(boolean, boolean)).
key: value; a value may also be an object with the value
under "value" (the local file records replaced and savedAt that way).
Never stops the robot booting
A missing file is skipped. An unreadable file (bad JSON, or a key given twice), or a value of the wrong type or out of bounds, is skipped too, and raises an alert; the value comes from the layer below. A key no code declares raises an info alert, since it is usually a typo. A bad default in code is a bug and throws.Moving a controller between robots
The local folder is per robot config, and a hard-stop group's file (swerve offsets, soft limits) carries aHardwareStamp: a file saved on another robot, or one whose robot cannot be
checked, is refused with an error alert and the group's values come from git. A file saved before
the folder was per robot (<local>/<group>.json) is read from there until the next save
moves it; a hard-stop group's such file has no stamp, so it is refused the same way.
Replay
Every value and the layer it came from is a logged input (ParamsInputs), processed when a
param is declared and whenever a value changes, so replay runs on the robot's values. Live
changes are applied in periodic() on the main thread, never in replay.
Saving
The transport'sSaveParams button, or requestSave(), writes every value that
differs from the git layers to the robot-local folder. Disabled only; the file write runs on a
background thread and reaches the disk before it replaces the old file.
Main thread only.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringNT folder theNetworkTablesTransportpublishes params under. -
Method Summary
Modifier and TypeMethodDescriptionProblems with a params file against the params declared so far: unreadable, a key nobody declares, or a value of the wrong type or out of bounds.static Param<?> The declared param atgroup/key, or null.static ParamGroupStarts declaring params in a group.static booleanWhether live tuning is running (tuning mode on and a transport given).static voidperiodic()Applies live changes (liveChangesAllowed(boolean, boolean)), logs the values, handles a save.static booleanrefusedInFile(Param<?> p) Whether a params file refused this param's value (wrong type or out of bounds), or its group's file is unreadable or was saved on another robot, so the value came from a lower layer.static voidAsks for a save at the nextperiodic(); refused unless disabled.static voidstart(Path deployParamsDir, String robot, Path localRoot, ParamTransport transport) start(Path, String, Path, ParamTransport, Map)with no hard-stop groups.static voidstart(Path deployParamsDir, String robot, Path localRoot, ParamTransport transport, Map<String, HardwareStamp> stamps) Reads the params files and re-resolves anything declared so far.
-
Field Details
-
NT_PREFIX
NT folder theNetworkTablesTransportpublishes params under.- See Also:
-
-
Method Details
-
group
Starts declaring params in a group. Hold the params instatic finalfields so each is declared once. -
start
public static void start(Path deployParamsDir, String robot, Path localRoot, ParamTransport transport) start(Path, String, Path, ParamTransport, Map)with no hard-stop groups. -
start
public static void start(Path deployParamsDir, String robot, Path localRoot, ParamTransport transport, Map<String, HardwareStamp> stamps) Reads the params files and re-resolves anything declared so far. Call once at boot, afterLogger.start()and before the subsystems are built.- Parameters:
deployParamsDir- the deploy folder'sparamsdirectoryrobot- this robot's name, forparams/robots/<robot>/and<localRoot>/<robot>/localRoot- the robot-local folder that survives deploys, or null for none (replay)transport- where live tuning comes from; used only inTuningModestamps- the hard-stop groups, whose local file must have been saved on this robot
-
periodic
public static void periodic()Applies live changes (liveChangesAllowed(boolean, boolean)), logs the values, handles a save. Call once per loop, before anything reads a param. -
requestSave
public static void requestSave()Asks for a save at the nextperiodic(); refused unless disabled. -
liveTuning
public static boolean liveTuning()Whether live tuning is running (tuning mode on and a transport given). -
find
-
refusedInFile
Whether a params file refused this param's value (wrong type or out of bounds), or its group's file is unreadable or was saved on another robot, so the value came from a lower layer. Read-only, for checks. Judged on the files this run read: in replay, the replaying PC's. -
checkFile
-