Remove hasTargets member variable and fix docs warnings (#283)

hasTargets is redundant because the same information can be obtained by
checking the size of the targets array.
This commit is contained in:
Tyler Veness
2021-09-03 19:19:38 -07:00
committed by GitHub
parent affb27038b
commit 798b8e398a
8 changed files with 27 additions and 30 deletions

View File

@@ -57,12 +57,12 @@ class PhotonPipelineResult {
if (!HasTargets() && !HAS_WARNED) {
::frc::DriverStation::ReportError(
"This PhotonPipelineResult object has no targets associated with it! "
"Please check hasTargets() before calling this method. For more "
"Please check HasTargets() before calling this method. For more "
"information, please review the PhotonLib documentation at "
"http://docs.photonvision.org");
HAS_WARNED = true;
}
return hasTargets ? targets[0] : PhotonTrackedTarget();
return HasTargets() ? targets[0] : PhotonTrackedTarget();
}
/**
@@ -75,7 +75,7 @@ class PhotonPipelineResult {
* Returns whether the pipeline has targets.
* @return Whether the pipeline has targets.
*/
bool HasTargets() const { return hasTargets; }
bool HasTargets() const { return targets.size() > 0; }
/**
* Returns a reference to the vector of targets.
@@ -93,7 +93,6 @@ class PhotonPipelineResult {
private:
units::second_t latency = 0_s;
bool hasTargets = false;
wpi::SmallVector<PhotonTrackedTarget, 10> targets;
inline static bool HAS_WARNED = false;
};