PhotonVision C++ dev-v2025.0.0-beta-8-2-gbd1c5c03
Loading...
Searching...
No Matches
NTTopicSet.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Photon Vision.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <memory>
21#include <string>
22
23#include <frc/geometry/Transform3d.h>
24#include <networktables/BooleanTopic.h>
25#include <networktables/DoubleArrayTopic.h>
26#include <networktables/DoubleTopic.h>
27#include <networktables/IntegerTopic.h>
28#include <networktables/NetworkTable.h>
29#include <networktables/RawTopic.h>
30#include <networktables/StructTopic.h>
31
32namespace photon {
34 std::string{"photonstruct:PhotonPipelineResult:"} +
36
38 public:
39 std::shared_ptr<nt::NetworkTable> subTable;
40 nt::RawPublisher rawBytesEntry;
41
42 nt::IntegerPublisher pipelineIndexPublisher;
43 nt::IntegerSubscriber pipelineIndexRequestSub;
44
45 nt::BooleanTopic driverModeEntry;
46 nt::BooleanPublisher driverModePublisher;
47 nt::BooleanSubscriber driverModeSubscriber;
48
49 nt::DoublePublisher latencyMillisEntry;
50 nt::BooleanPublisher hasTargetEntry;
51 nt::DoublePublisher targetPitchEntry;
52 nt::DoublePublisher targetYawEntry;
53 nt::DoublePublisher targetAreaEntry;
54 nt::StructPublisher<frc::Transform3d> targetPoseEntry;
55 nt::DoublePublisher targetSkewEntry;
56
57 nt::DoublePublisher bestTargetPosX;
58 nt::DoublePublisher bestTargetPosY;
59
60 nt::IntegerTopic heartbeatTopic;
61 nt::IntegerPublisher heartbeatPublisher;
62
63 nt::DoubleArrayPublisher cameraIntrinsicsPublisher;
64 nt::DoubleArrayPublisher cameraDistortionPublisher;
65
67 nt::PubSubOptions options;
68 options.periodic = 0.01;
69 options.sendAll = true;
70 rawBytesEntry = subTable->GetRawTopic("rawBytes")
71 .Publish(PhotonPipelineResult_TYPE_STRING, options);
72
74 subTable->GetIntegerTopic("pipelineIndexState").Publish();
76 subTable->GetIntegerTopic("pipelineIndexRequest").Subscribe(0);
77
78 driverModePublisher = subTable->GetBooleanTopic("driverMode").Publish();
80 subTable->GetBooleanTopic("driverModeRequest").Subscribe(0);
81
82 driverModeSubscriber.GetTopic().Publish().SetDefault(false);
83
84 latencyMillisEntry = subTable->GetDoubleTopic("latencyMillis").Publish();
85 hasTargetEntry = subTable->GetBooleanTopic("hasTargets").Publish();
86
87 targetPitchEntry = subTable->GetDoubleTopic("targetPitch").Publish();
88 targetAreaEntry = subTable->GetDoubleTopic("targetArea").Publish();
89 targetYawEntry = subTable->GetDoubleTopic("targetYaw").Publish();
91 subTable->GetStructTopic<frc::Transform3d>("targetPose").Publish();
92 targetSkewEntry = subTable->GetDoubleTopic("targetSkew").Publish();
93
94 bestTargetPosX = subTable->GetDoubleTopic("targetPixelsX").Publish();
95 bestTargetPosY = subTable->GetDoubleTopic("targetPixelsY").Publish();
96
97 heartbeatTopic = subTable->GetIntegerTopic("heartbeat");
99
101 subTable->GetDoubleArrayTopic("cameraIntrinsics").Publish();
103 subTable->GetDoubleArrayTopic("cameraDistortion").Publish();
104 }
105
106 private:
107};
108} // namespace photon
Definition NTTopicSet.h:37
nt::StructPublisher< frc::Transform3d > targetPoseEntry
Definition NTTopicSet.h:54
nt::DoublePublisher targetPitchEntry
Definition NTTopicSet.h:51
nt::DoublePublisher targetAreaEntry
Definition NTTopicSet.h:53
nt::IntegerPublisher heartbeatPublisher
Definition NTTopicSet.h:61
std::shared_ptr< nt::NetworkTable > subTable
Definition NTTopicSet.h:39
nt::DoublePublisher bestTargetPosX
Definition NTTopicSet.h:57
nt::DoublePublisher targetYawEntry
Definition NTTopicSet.h:52
nt::IntegerPublisher pipelineIndexPublisher
Definition NTTopicSet.h:42
nt::BooleanPublisher hasTargetEntry
Definition NTTopicSet.h:50
nt::BooleanPublisher driverModePublisher
Definition NTTopicSet.h:46
nt::DoublePublisher latencyMillisEntry
Definition NTTopicSet.h:49
nt::BooleanTopic driverModeEntry
Definition NTTopicSet.h:45
nt::RawPublisher rawBytesEntry
Definition NTTopicSet.h:40
nt::DoubleArrayPublisher cameraDistortionPublisher
Definition NTTopicSet.h:64
nt::DoublePublisher targetSkewEntry
Definition NTTopicSet.h:55
nt::DoubleArrayPublisher cameraIntrinsicsPublisher
Definition NTTopicSet.h:63
nt::IntegerTopic heartbeatTopic
Definition NTTopicSet.h:60
void UpdateEntries()
Definition NTTopicSet.h:66
nt::BooleanSubscriber driverModeSubscriber
Definition NTTopicSet.h:47
nt::IntegerSubscriber pipelineIndexRequestSub
Definition NTTopicSet.h:43
nt::DoublePublisher bestTargetPosY
Definition NTTopicSet.h:58
Definition VisionEstimation.h:32
const std::string PhotonPipelineResult_TYPE_STRING
Definition NTTopicSet.h:33
static constexpr std::string_view GetSchemaHash()
Definition PhotonPipelineResultSerde.h:41