-
Notifications
You must be signed in to change notification settings - Fork 284
Create comprehensive AprilTagFieldLayout documentation article #3138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Create comprehensive AprilTagFieldLayout documentation article #3138
Conversation
Creates new article documenting AprilTagFieldLayout usage including loading layouts, getting tag poses, using setOrigin(), and common pitfalls. Covers both premade field layouts and custom layouts. Fixes wpilibsuite#2253
|
||
## Setting the Origin | ||
|
||
One of the most common sources of confusion is the **origin location**. FRC fields are symmetric, with identical tag layouts on both the red and blue alliance sides. The field layout needs to know which alliance you're on to give you correct positions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely correct!
// In robotInit() or robotPeriodic(): | ||
var alliance = DriverStation.getAlliance(); | ||
if (alliance.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expand this example to handle the else case, so that you're always calling setOrigin() explicitly. Applies to all 3 language examples.
- Clarified field symmetry description (rotational vs mirror) - Added else case to setOrigin() examples to always explicitly set origin - Defaults to blue alliance when not connected to FMS
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.apriltag.AprilTagFieldLayout.OriginPosition; | ||
// In robotInit() or robotPeriodic(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't put this in robotInit only. Isn't there already docs on getting alliance color safetly?
) | ||
``` | ||
|
||
## Loading Custom Layouts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it needs more details to be useful. What is the spec for the file? How does it get to robot (put in deploy directory). Besides manually editing a file, how could you make one (use WPICal), etc.
|
||
The ``AprilTagFieldLayout`` class helps robots understand where AprilTags are located on the field. This is essential for using vision measurements with :doc:`pose estimators </docs/software/advanced-controls/state-space/state-space-pose-estimators>` to determine your robot's position. | ||
|
||
## What is AprilTagFieldLayout? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like there should be a link to the coordinate system page somewhere
import edu.wpi.first.apriltag.AprilTagFields; | ||
// Load the official field layout for the current year | ||
AprilTagFieldLayout fieldLayout = AprilTagFieldLayout.loadField(AprilTagFields.k2024Crescendo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 2024?
#include <frc/apriltag/AprilTagFields.h> | ||
// Load the official field layout for the current year | ||
frc::AprilTagFieldLayout fieldLayout = frc::LoadAprilTagLayoutField(frc::AprilTagField::k2024Crescendo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this deprecated?
Replace deprecated frc::LoadAprilTagLayoutField() with frc::AprilTagFieldLayout::LoadField() per the deprecation warning in the WPILib headers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changes: - Removed robotInit() from setOrigin() examples (alliance color not available during robotInit) - Added note and link to alliancecolor.rst for getting alliance color safely - Updated comments to suggest robotPeriodic(), autonomousInit(), or teleopInit() - Expanded custom layouts section with: - JSON format specification and example - Deploy directory instructions - Multiple methods for creating layouts (manual, WPICalibrator, programmatic) - Code examples using Filesystem.getDeployDirectory() - Added links to coordinate-system.rst in Common Pitfalls and See Also sections 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changed from k2024Crescendo to k2025ReefscapeWelded to reflect the current year (2025). Added note explaining the two 2025 field layout options (Welded vs AndyMark) so teams can choose the correct one for their practice field. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Summary
Creates a new comprehensive article documenting
AprilTagFieldLayout
usage, including loading layouts, getting tag poses, usingsetOrigin()
, and avoiding common pitfalls.Changes
apriltag-field-layout.rst
with complete AprilTagFieldLayout documentationsetOrigin()
for flipping coordinates between alliancesindex.rst
to include new article in toctreeFixes #2253