Skip to content

Commit

Permalink
wot
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Nov 16, 2023
1 parent 813f177 commit aa8f0f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
10 changes: 6 additions & 4 deletions photon-lib/src/main/native/cpp/photonlib/PhotonCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ PhotonCamera::PhotonCamera(nt::NetworkTableInstance instance,
: mainTable(instance.GetTable("photonvision")),
rootTable(mainTable->GetSubTable(cameraName)),
pipelineResultsSubscriber(
rootTable->GetProtobufTopic<PhotonPipelineResult>("result_proto").Subscribe(PhotonPipelineResult(), {.periodic = 0.01, .sendAll = true})
),
rootTable->GetProtobufTopic<PhotonPipelineResult>("result_proto")
.Subscribe(PhotonPipelineResult(),
{.periodic = 0.01, .sendAll = true})),
inputSaveImgEntry(
rootTable->GetIntegerTopic("inputSaveImgCmd").Publish()),
inputSaveImgSubscriber(
Expand Down Expand Up @@ -87,8 +88,9 @@ PhotonPipelineResult PhotonCamera::GetLatestResult() {
// Create the new result;
PhotonPipelineResult result = pipelineResultsSubscriber.Get();

result.SetTimestamp(units::microsecond_t(pipelineResultsSubscriber.GetLastChange()) -
result.GetLatency());
result.SetTimestamp(
units::microsecond_t(pipelineResultsSubscriber.GetLastChange()) -
result.GetLatency());

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,15 @@ wpi::Protobuf<photonlib::PhotonTrackedTarget>::Unpack(

auto m = static_cast<const ProtobufPhotonTrackedTarget*>(&msg);

return photonlib::PhotonTrackedTarget{};
return photonlib::PhotonTrackedTarget(
m->yaw(), m->pitch(), m->area(), m->skew(), m->fiducialid(),
wpi::UnpackProtobuf<frc::Transform3d>(m->bestcameratotarget()),
wpi::UnpackProtobuf<frc::Transform3d>(m->altcameratotarget()),
m->poseambiguity(),
// corners
{},
// detected corners
{});
}

void wpi::Protobuf<photonlib::PhotonTrackedTarget>::Pack(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
#include <memory>
#include <string>

#include <networktables/ProtobufTopic.h>
#include <networktables/BooleanTopic.h>
#include <networktables/DoubleArrayTopic.h>
#include <networktables/DoubleTopic.h>
#include <networktables/IntegerTopic.h>
#include <networktables/MultiSubscriber.h>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
#include <networktables/ProtobufTopic.h>
#include <networktables/StringTopic.h>
#include <units/time.h>
#include <wpi/deprecated.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class SimPhotonCamera : public PhotonCamera {
targetAreaEntry = rootTable->GetEntry("targetAreaEntry");
targetSkewEntry = rootTable->GetEntry("targetSkewEntry");
targetPoseEntry = rootTable->GetEntry("targetPoseEntry");
// rawBytesPublisher = rootTable->GetRawTopic("rawBytes").Publish("rawBytes");
// rawBytesPublisher =
// rootTable->GetRawTopic("rawBytes").Publish("rawBytes");
versionEntry = instance.GetTable("photonvision")->GetEntry("version");
}

Expand Down

0 comments on commit aa8f0f5

Please sign in to comment.