mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
Update to wpilib 2023 beta 7 (#607)
We now need platform specific jars -- reworks actions to support that. Currently only generates 32 bit pi images.
This commit is contained in:
@@ -46,7 +46,7 @@ class Packet {
|
||||
* Constructs a packet with the given data.
|
||||
* @param data The packet data.
|
||||
*/
|
||||
explicit Packet(std::vector<char> data) : packetData(data) {}
|
||||
explicit Packet(std::vector<uint8_t> data) : packetData(data) {}
|
||||
|
||||
/**
|
||||
* Clears the packet and resets the read and write positions.
|
||||
@@ -61,7 +61,7 @@ class Packet {
|
||||
* Returns the packet data.
|
||||
* @return The packet data.
|
||||
*/
|
||||
const std::vector<char>& GetData() { return packetData; }
|
||||
const std::vector<uint8_t>& GetData() { return packetData; }
|
||||
|
||||
/**
|
||||
* Returns the number of bytes in the data.
|
||||
@@ -105,7 +105,7 @@ class Packet {
|
||||
if constexpr (wpi::support::endian::system_endianness() ==
|
||||
wpi::support::endianness::little) {
|
||||
// Reverse to little endian for host.
|
||||
char& raw = reinterpret_cast<char&>(value);
|
||||
uint8_t& raw = reinterpret_cast<uint8_t&>(value);
|
||||
std::reverse(&raw, &raw + sizeof(T));
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class Packet {
|
||||
|
||||
private:
|
||||
// Data stored in the packet
|
||||
std::vector<char> packetData;
|
||||
std::vector<uint8_t> packetData;
|
||||
|
||||
size_t readPos = 0;
|
||||
size_t writePos = 0;
|
||||
|
||||
@@ -27,9 +27,13 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <networktables/BooleanTopic.h>
|
||||
#include <networktables/DoubleTopic.h>
|
||||
#include <networktables/IntegerTopic.h>
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <networktables/NetworkTableEntry.h>
|
||||
#include <networktables/NetworkTableInstance.h>
|
||||
#include <networktables/RawTopic.h>
|
||||
#include <networktables/StringTopic.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
@@ -146,13 +150,17 @@ class PhotonCamera {
|
||||
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;
|
||||
nt::RawSubscriber rawBytesEntry;
|
||||
nt::BooleanPublisher driverModeEntry;
|
||||
nt::BooleanPublisher inputSaveImgEntry;
|
||||
nt::BooleanPublisher outputSaveImgEntry;
|
||||
nt::IntegerPublisher pipelineIndexEntry;
|
||||
nt::IntegerPublisher ledModeEntry;
|
||||
nt::StringSubscriber versionEntry;
|
||||
|
||||
nt::BooleanSubscriber driverModeSubscriber;
|
||||
nt::IntegerSubscriber pipelineIndexSubscriber;
|
||||
nt::IntegerSubscriber ledModeSubscriber;
|
||||
|
||||
std::string path;
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
#include <frc/Errors.h>
|
||||
#include <units/time.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "photonlib/Packet.h"
|
||||
#include "photonlib/PhotonTrackedTarget.h"
|
||||
@@ -51,7 +51,7 @@ class PhotonPipelineResult {
|
||||
* @param targets The list of targets identified by the pipeline.
|
||||
*/
|
||||
PhotonPipelineResult(units::second_t latency,
|
||||
wpi::span<const PhotonTrackedTarget> targets);
|
||||
std::span<const PhotonTrackedTarget> targets);
|
||||
|
||||
/**
|
||||
* Returns the best target in this pipeline result. If there are no targets,
|
||||
@@ -105,7 +105,7 @@ class PhotonPipelineResult {
|
||||
* Returns a reference to the vector of targets.
|
||||
* @return A reference to the vector of targets.
|
||||
*/
|
||||
const wpi::span<const PhotonTrackedTarget> GetTargets() const {
|
||||
const std::span<const PhotonTrackedTarget> GetTargets() const {
|
||||
return targets;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,12 @@ class PhotonTrackedTarget {
|
||||
*/
|
||||
double GetSkew() const { return skew; }
|
||||
|
||||
/**
|
||||
* Get the Fiducial ID of the target currently being tracked,
|
||||
* or -1 if not set.
|
||||
*/
|
||||
double GetFiducialId() const { return fiducialId; }
|
||||
|
||||
/**
|
||||
* Returns the corners of the minimum area rectangle bounding this target.
|
||||
*/
|
||||
|
||||
@@ -47,6 +47,7 @@ class SimPhotonCamera : public PhotonCamera {
|
||||
targetAreaEntry = rootTable->GetEntry("targetAreaEntry");
|
||||
targetSkewEntry = rootTable->GetEntry("targetSkewEntry");
|
||||
targetPoseEntry = rootTable->GetEntry("targetPoseEntry");
|
||||
rawBytesPublisher = rootTable->GetRawTopic("rawBytes").Publish("raw");
|
||||
versionEntry = instance->GetTable("photonvision")->GetEntry("version");
|
||||
// versionEntry.SetString(PhotonVersion.versionString);
|
||||
}
|
||||
@@ -86,10 +87,9 @@ class SimPhotonCamera : public PhotonCamera {
|
||||
PhotonPipelineResult newResult{latency, targetList};
|
||||
Packet packet{};
|
||||
packet << newResult;
|
||||
rawBytesEntry.SetRaw(
|
||||
std::string_view{packet.GetData().data(), packet.GetDataSize()});
|
||||
|
||||
std::string rawBytesGet = rawBytesEntry.GetRaw("ohono");
|
||||
rawBytesPublisher.Set(
|
||||
std::span{packet.GetData().data(), packet.GetDataSize()});
|
||||
|
||||
bool hasTargets = newResult.HasTargets();
|
||||
hasTargetEntry.SetBoolean(hasTargets);
|
||||
@@ -97,7 +97,8 @@ class SimPhotonCamera : public PhotonCamera {
|
||||
targetPitchEntry.SetDouble(0.0);
|
||||
targetYawEntry.SetDouble(0.0);
|
||||
targetAreaEntry.SetDouble(0.0);
|
||||
targetPoseEntry.SetDoubleArray({0.0, 0.0, 0.0});
|
||||
targetPoseEntry.SetDoubleArray(
|
||||
std::vector<double>{0.0, 0.0, 0.0, 0, 0, 0, 0});
|
||||
targetSkewEntry.SetDouble(0.0);
|
||||
} else {
|
||||
PhotonTrackedTarget bestTarget = newResult.GetBestTarget();
|
||||
@@ -107,9 +108,12 @@ class SimPhotonCamera : public PhotonCamera {
|
||||
targetSkewEntry.SetDouble(bestTarget.GetSkew());
|
||||
|
||||
frc::Transform3d transform = bestTarget.GetBestCameraToTarget();
|
||||
targetPoseEntry.SetDoubleArray(
|
||||
{transform.X().to<double>(), transform.Y().to<double>(),
|
||||
transform.Rotation().ToRotation2d().Degrees().to<double>()});
|
||||
targetPoseEntry.SetDoubleArray(std::vector<double>{
|
||||
transform.X().to<double>(), transform.Y().to<double>(),
|
||||
transform.Z().to<double>(), transform.Rotation().GetQuaternion().W(),
|
||||
transform.Rotation().GetQuaternion().X(),
|
||||
transform.Rotation().GetQuaternion().Y(),
|
||||
transform.Rotation().GetQuaternion().Z()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,5 +126,6 @@ class SimPhotonCamera : public PhotonCamera {
|
||||
nt::NetworkTableEntry targetSkewEntry;
|
||||
nt::NetworkTableEntry targetPoseEntry;
|
||||
nt::NetworkTableEntry versionEntry;
|
||||
nt::RawPublisher rawBytesPublisher;
|
||||
};
|
||||
} // namespace photonlib
|
||||
|
||||
Reference in New Issue
Block a user