Skip to content

Commit

Permalink
[apriltag] Add GetTags to C++ version of AprilTagFieldLayout (wpilibs…
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stered authored Nov 4, 2023
1 parent 87a8a1c commit 04a781b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apriltag/src/main/native/cpp/AprilTagFieldLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ units::meter_t AprilTagFieldLayout::GetFieldWidth() const {
return m_fieldWidth;
}

std::vector<AprilTag> AprilTagFieldLayout::GetTags() const {
std::vector<AprilTag> tags;
tags.reserve(m_apriltags.size());
for (const auto& tag : m_apriltags) {
tags.emplace_back(tag.second);
}
return tags;
}

void AprilTagFieldLayout::SetOrigin(OriginPosition origin) {
switch (origin) {
case OriginPosition::kBlueAllianceWallRightSide:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
*/
units::meter_t GetFieldWidth() const;

/**
* Returns a vector of all the april tags used in this layout.
* @return list of tags
*/
std::vector<AprilTag> GetTags() const;

/**
* Sets the origin based on a predefined enumeration of coordinate frame
* origins. The origins are calculated from the field dimensions.
Expand Down

0 comments on commit 04a781b

Please sign in to comment.