PhotonVision C++ v2027.0.0-alpha-2
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 <wpi/math/geometry/Transform3d.hpp>
24#include <wpi/nt/BooleanTopic.hpp>
25#include <wpi/nt/DoubleArrayTopic.hpp>
26#include <wpi/nt/DoubleTopic.hpp>
27#include <wpi/nt/IntegerTopic.hpp>
28#include <wpi/nt/NetworkTable.hpp>
29#include <wpi/nt/RawTopic.hpp>
30#include <wpi/nt/StructTopic.hpp>
31
32namespace photon {
34 std::string{"photonstruct:PhotonPipelineResult:"} +
36
38 public:
39 std::shared_ptr<wpi::nt::NetworkTable> subTable;
40 wpi::nt::RawPublisher rawBytesEntry;
41
42 wpi::nt::IntegerPublisher pipelineIndexPublisher;
43 wpi::nt::IntegerSubscriber pipelineIndexRequestSub;
44
45 wpi::nt::BooleanTopic driverModeEntry;
46 wpi::nt::BooleanPublisher driverModePublisher;
47 wpi::nt::BooleanSubscriber driverModeSubscriber;
48
49 wpi::nt::DoublePublisher latencyMillisEntry;
50 wpi::nt::BooleanPublisher hasTargetEntry;
51 wpi::nt::DoublePublisher targetPitchEntry;
52 wpi::nt::DoublePublisher targetYawEntry;
53 wpi::nt::DoublePublisher targetAreaEntry;
54 wpi::nt::StructPublisher<wpi::math::Transform3d> targetPoseEntry;
55 wpi::nt::DoublePublisher targetSkewEntry;
56
57 wpi::nt::DoublePublisher bestTargetPosX;
58 wpi::nt::DoublePublisher bestTargetPosY;
59
60 wpi::nt::IntegerTopic heartbeatTopic;
61 wpi::nt::IntegerPublisher heartbeatPublisher;
62
63 wpi::nt::DoubleArrayPublisher cameraIntrinsicsPublisher;
64 wpi::nt::DoubleArrayPublisher cameraDistortionPublisher;
65
67 wpi::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<wpi::math::Transform3d>("targetPose")
92 .Publish();
93 targetSkewEntry = subTable->GetDoubleTopic("targetSkew").Publish();
94
95 bestTargetPosX = subTable->GetDoubleTopic("targetPixelsX").Publish();
96 bestTargetPosY = subTable->GetDoubleTopic("targetPixelsY").Publish();
97
98 heartbeatTopic = subTable->GetIntegerTopic("heartbeat");
100
102 subTable->GetDoubleArrayTopic("cameraIntrinsics").Publish();
104 subTable->GetDoubleArrayTopic("cameraDistortion").Publish();
105 }
106};
107} // namespace photon
Definition NTTopicSet.h:37
wpi::nt::DoublePublisher targetAreaEntry
Definition NTTopicSet.h:53
wpi::nt::BooleanTopic driverModeEntry
Definition NTTopicSet.h:45
wpi::nt::StructPublisher< wpi::math::Transform3d > targetPoseEntry
Definition NTTopicSet.h:54
wpi::nt::IntegerTopic heartbeatTopic
Definition NTTopicSet.h:60
wpi::nt::DoublePublisher bestTargetPosX
Definition NTTopicSet.h:57
wpi::nt::DoublePublisher latencyMillisEntry
Definition NTTopicSet.h:49
wpi::nt::IntegerPublisher pipelineIndexPublisher
Definition NTTopicSet.h:42
wpi::nt::DoublePublisher targetSkewEntry
Definition NTTopicSet.h:55
wpi::nt::BooleanSubscriber driverModeSubscriber
Definition NTTopicSet.h:47
std::shared_ptr< wpi::nt::NetworkTable > subTable
Definition NTTopicSet.h:39
wpi::nt::IntegerSubscriber pipelineIndexRequestSub
Definition NTTopicSet.h:43
wpi::nt::BooleanPublisher driverModePublisher
Definition NTTopicSet.h:46
wpi::nt::IntegerPublisher heartbeatPublisher
Definition NTTopicSet.h:61
wpi::nt::DoublePublisher targetYawEntry
Definition NTTopicSet.h:52
wpi::nt::BooleanPublisher hasTargetEntry
Definition NTTopicSet.h:50
void UpdateEntries()
Definition NTTopicSet.h:66
wpi::nt::DoubleArrayPublisher cameraIntrinsicsPublisher
Definition NTTopicSet.h:63
wpi::nt::DoublePublisher bestTargetPosY
Definition NTTopicSet.h:58
wpi::nt::RawPublisher rawBytesEntry
Definition NTTopicSet.h:40
wpi::nt::DoublePublisher targetPitchEntry
Definition NTTopicSet.h:51
wpi::nt::DoubleArrayPublisher cameraDistortionPublisher
Definition NTTopicSet.h:64
Definition VisionEstimation.h:30
const std::string PhotonPipelineResult_TYPE_STRING
Definition NTTopicSet.h:33
static constexpr std::string_view GetSchemaHash()
Definition PhotonPipelineResultSerde.h:48