Expose camera name in PhotonCamera (#523)

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
Lavi Arzi
2022-12-25 07:01:57 +02:00
committed by GitHub
parent e1b39a1723
commit 8330bf9d92
3 changed files with 31 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ namespace photonlib {
constexpr const units::second_t VERSION_CHECK_INTERVAL = 5_s;
PhotonCamera::PhotonCamera(std::shared_ptr<nt::NetworkTableInstance> instance,
const std::string& cameraName)
const std::string_view cameraName)
: mainTable(instance->GetTable("photonvision")),
rootTable(mainTable->GetSubTable(cameraName)),
rawBytesEntry(rootTable->GetRawTopic("rawBytes").Subscribe("raw", {})),
@@ -52,9 +52,10 @@ PhotonCamera::PhotonCamera(std::shared_ptr<nt::NetworkTableInstance> instance,
pipelineIndexSubscriber(
rootTable->GetIntegerTopic("pipelineIndex").Subscribe(-1)),
ledModeSubscriber(mainTable->GetIntegerTopic("ledMode").Subscribe(0)),
path(rootTable->GetPath()) {}
path(rootTable->GetPath()),
m_cameraName(cameraName) {}
PhotonCamera::PhotonCamera(const std::string& cameraName)
PhotonCamera::PhotonCamera(const std::string_view cameraName)
: PhotonCamera(std::make_shared<nt::NetworkTableInstance>(
nt::NetworkTableInstance::GetDefault()),
cameraName) {}
@@ -109,6 +110,10 @@ void PhotonCamera::SetLEDMode(LEDMode mode) {
ledModeEntry.Set(static_cast<double>(static_cast<int>(mode)));
}
const std::string_view PhotonCamera::GetCameraName() const {
return m_cameraName;
}
void PhotonCamera::VerifyVersion() {
if (!PhotonCamera::VERSION_CHECK_ENABLED) return;