AprilTagFieldLayout json file for C++

Can anyone point me to the location of the json file containing the April Tag Field layout information for use with (in C++):

◆ AprilTagFieldLayout() [2/3]
frc::AprilTagFieldLayout::AprilTagFieldLayout	(	std::string_view 	path	)	
explicit
Construct a new AprilTagFieldLayout with values imported from a JSON file.

Parameters
path	Path of the JSON file to import from.

Hoping it already exists somewhere and I don’t have to create it. :slight_smile:

Don’t use AprilTagFieldLayout’s loading functions directly. Use frc::LoadAprilTagLayoutField() from frc/apriltag/AprilTagFields.h.

https://github.wpilib.org/allwpilib/docs/release/cpp/_april_tag_fields_8h.html

Imo, the class layout is confusing. You’re the third person I’ve seen at this point asking where the JSON file is, which shows AprilTagFields is not discoverable in either C++ or Java. It would make more sense if the contents of AprilTagFields was in AprilTagFieldLayout as static factory functions or a constructor overload that takes an enum.

EDIT: For continuity: The AprilTagFieldLayout/AprilTagFields initialization split is confusing · Issue #6326 · wpilibsuite/allwpilib · GitHub

1 Like

Got it… So looks like this for people who need to know:

// include both of these...
//#include <frc/apriltag/AprilTagFieldLayout.h>
//#include <frc/apriltag/AprilTagFields.h>

frc::AprilTagFieldLayout aprilTagFieldLayout = frc::LoadAprilTagLayoutField(frc::AprilTagField::k2024Crescendo);

… and in Java

import edu.wpi.first.apriltag.AprilTagFieldLayout;
import edu.wpi.first.apriltag.AprilTagFields;

AprilTagFieldLayout aprilTagFieldLayout = AprilTagFields.k2024Crescendo.loadAprilTagLayoutField();
1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.