Fix version verification with non-default networktable (#407)

Adds version verification to c++ too
This commit is contained in:
Matt
2022-01-24 12:38:45 -05:00
committed by GitHub
parent b09a6d6a2d
commit b2a3f34433
11 changed files with 133 additions and 32 deletions

View File

@@ -45,10 +45,15 @@ class PhotonCamera {
public:
/**
* Constructs a PhotonCamera from a root table.
* @param rootTable The root table that the camera is broadcasting information
*
* @param instance The NetworkTableInstance to pull data from. This can be a
* custom instance in simulation, but should *usually* be the default
* NTInstance from {@link NetworkTableInstance::getDefault}
* @param cameraName The name of the camera, as seen in the UI.
* over.
*/
explicit PhotonCamera(std::shared_ptr<nt::NetworkTable> rootTable);
explicit PhotonCamera(std::shared_ptr<nt::NetworkTableInstance> instance,
const std::string& cameraName);
/**
* Constructs a PhotonCamera from the name of the camera.
@@ -133,19 +138,23 @@ class PhotonCamera {
"This method should be replaced with PhotonPipelineResult::HasTargets()")
bool HasTargets() const { return GetLatestResult().HasTargets(); }
private:
std::shared_ptr<nt::NetworkTable> mainTable =
nt::NetworkTableInstance::GetDefault().GetTable("photonvision");
protected:
std::shared_ptr<nt::NetworkTable> mainTable;
std::shared_ptr<nt::NetworkTable> rootTable;
nt::NetworkTableEntry rawBytesEntry;
nt::NetworkTableEntry driverModeEntry;
nt::NetworkTableEntry inputSaveImgEntry;
nt::NetworkTableEntry outputSaveImgEntry;
nt::NetworkTableEntry pipelineIndexEntry;
nt::NetworkTableEntry ledModeEntry;
nt::NetworkTableEntry versionEntry;
std::string path;
mutable Packet packet;
private:
void VerifyVersion() const;
};
} // namespace photonlib

View File

@@ -44,10 +44,13 @@ class SimPhotonCamera : public PhotonCamera {
/**
* Constructs a Simulated PhotonCamera from a root table.
*
* @param rootTable The root table that the camera is broadcasting information
* over.
* @param instance The NetworkTableInstance to pull data from. This can be a
* custom instance in simulation, but should *usually* be the default
* NTInstance from {@link NetworkTableInstance::getDefault}
* @param cameraName The name of the camera, as seen in the UI.
*/
explicit SimPhotonCamera(std::shared_ptr<nt::NetworkTable> rootTable);
explicit SimPhotonCamera(std::shared_ptr<nt::NetworkTableInstance> instance,
const std::string& cameraName);
/**
* Constructs a Simulated PhotonCamera from the name of the camera.