Fix PhotonCamera typestring checks (#1480)

Previously NT would quietly drop readQueue changes.
This commit is contained in:
Matt
2024-10-20 22:21:24 -07:00
committed by GitHub
parent 7224561b76
commit 7da2ec1948
7 changed files with 50 additions and 19 deletions

View File

@@ -18,15 +18,22 @@
#pragma once
#include <memory>
#include <string>
#include <frc/geometry/Transform3d.h>
#include <networktables/BooleanTopic.h>
#include <networktables/DoubleArrayTopic.h>
#include <networktables/DoubleTopic.h>
#include <networktables/IntegerTopic.h>
#include <networktables/NetworkTable.h>
#include <networktables/RawTopic.h>
#include <networktables/StructTopic.h>
namespace photon {
const std::string PhotonPipelineResult_TYPE_STRING =
std::string{"photonstruct:PhotonPipelineResult:"} +
std::string{SerdeType<PhotonPipelineResult>::GetSchemaHash()};
class NTTopicSet {
public:
std::shared_ptr<nt::NetworkTable> subTable;
@@ -44,7 +51,7 @@ class NTTopicSet {
nt::DoublePublisher targetPitchEntry;
nt::DoublePublisher targetYawEntry;
nt::DoublePublisher targetAreaEntry;
nt::DoubleArrayPublisher targetPoseEntry;
nt::StructPublisher<frc::Transform3d> targetPoseEntry;
nt::DoublePublisher targetSkewEntry;
nt::DoublePublisher bestTargetPosX;
@@ -60,8 +67,8 @@ class NTTopicSet {
nt::PubSubOptions options;
options.periodic = 0.01;
options.sendAll = true;
rawBytesEntry =
subTable->GetRawTopic("rawBytes").Publish("rawBytes", options);
rawBytesEntry = subTable->GetRawTopic("rawBytes")
.Publish(PhotonPipelineResult_TYPE_STRING, options);
pipelineIndexPublisher =
subTable->GetIntegerTopic("pipelineIndexState").Publish();
@@ -80,7 +87,8 @@ class NTTopicSet {
targetPitchEntry = subTable->GetDoubleTopic("targetPitch").Publish();
targetAreaEntry = subTable->GetDoubleTopic("targetArea").Publish();
targetYawEntry = subTable->GetDoubleTopic("targetYaw").Publish();
targetPoseEntry = subTable->GetDoubleArrayTopic("targetPose").Publish();
targetPoseEntry =
subTable->GetStructTopic<frc::Transform3d>("targetPose").Publish();
targetSkewEntry = subTable->GetDoubleTopic("targetSkew").Publish();
bestTargetPosX = subTable->GetDoubleTopic("targetPixelsX").Publish();