Class FieldMapHash
java.lang.Object
frc.spectrumLib.vision.FieldMapHash
A short fingerprint of an AprilTag field map, so the robot and each coprocessor can tell whether
they solve with the same tags. Every side computes it the same way (the SpectrumJetson code
implements this exact text), so change nothing here without changing them too:
- Tags sorted by ID, one line each:
id,x,y,z,qw,qx,qy,qz(meters, and the quaternion of the tag's pose). - A last line
field,<length m>,<width m>. - Every number with four decimals,
String.format(Locale.ROOT, "%.4f"); lines joined with"\n", no trailing newline. Java rounds the shortest decimal form half-up (0.55245 gives 0.5525), where C and Python's"%.4f"round the exact binary value (0.5524): another implementation must round like Java, e.g. Python'sDecimal(repr(x)).quantize(Decimal("0.0001"), ROUND_HALF_UP). - SHA-256 of the UTF-8 bytes, lowercase hex, the first
LENGTHcharacters.
Four decimals is a tenth of a millimeter: well under what any solve can see, and coarse enough that the same map read by two JSON parsers hashes the same.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcanonicalText(AprilTagFieldLayout layout) The text that is hashed, for tests and for comparing with another implementation.static Stringof(AprilTagFieldLayout layout) The canonical hash of a layout.
-
Field Details
-
LENGTH
public static final int LENGTHHex characters kept.- See Also:
-
-
Method Details
-
of
The canonical hash of a layout.- Parameters:
layout- the field map- Returns:
LENGTHlowercase hex characters
-
canonicalText
The text that is hashed, for tests and for comparing with another implementation.- Parameters:
layout- the field map- Returns:
- the canonical lines, joined with
"\n"
-