mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
Bump to WPILib 2025 Beta 1 & remove C++ protobuf (#1484)
Remove C++ protobuf support until https://github.com/wpilibsuite/allwpilib/issues/7250 is addressed. Developers should upgrade to wpilib vscode 2025 beta 1. --------- Co-authored-by: Matt <matthew.morley.ca@gmail.com>
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "photon/targeting/proto/MultiTargetPNPResultProto.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "photon.pb.h"
|
||||
#include "photon/targeting/proto/PNPResultProto.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<photon::MultiTargetPNPResult>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
photonvision::proto::ProtobufMultiTargetPNPResult>(arena);
|
||||
}
|
||||
|
||||
photon::MultiTargetPNPResult
|
||||
wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const photonvision::proto::ProtobufMultiTargetPNPResult*>(
|
||||
&msg);
|
||||
|
||||
std::vector<int16_t> fiducialIdsUsed;
|
||||
fiducialIdsUsed.reserve(32);
|
||||
|
||||
for (int i = 0; i < m->fiducial_ids_used_size(); i++) {
|
||||
fiducialIdsUsed.push_back(m->fiducial_ids_used(i));
|
||||
}
|
||||
|
||||
return photon::MultiTargetPNPResult{photon::MultiTargetPNPResult_PhotonStruct{
|
||||
wpi::UnpackProtobuf<photon::PnpResult>(m->estimated_pose()),
|
||||
fiducialIdsUsed}};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<photon::MultiTargetPNPResult>::Pack(
|
||||
google::protobuf::Message* msg, const photon::MultiTargetPNPResult& value) {
|
||||
auto m = static_cast<photonvision::proto::ProtobufMultiTargetPNPResult*>(msg);
|
||||
|
||||
wpi::PackProtobuf(m->mutable_estimated_pose(), value.estimatedPose);
|
||||
|
||||
m->clear_fiducial_ids_used();
|
||||
for (const auto& t : value.fiducialIDsUsed) {
|
||||
m->add_fiducial_ids_used(t);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "photon/targeting/proto/PNPResultProto.h"
|
||||
|
||||
#include "photon.pb.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<photon::PnpResult>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
photonvision::proto::ProtobufPNPResult>(arena);
|
||||
}
|
||||
|
||||
photon::PnpResult wpi::Protobuf<photon::PnpResult>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const photonvision::proto::ProtobufPNPResult*>(&msg);
|
||||
|
||||
return photon::PnpResult{photon::PnpResult_PhotonStruct{
|
||||
wpi::UnpackProtobuf<frc::Transform3d>(m->best()),
|
||||
wpi::UnpackProtobuf<frc::Transform3d>(m->alt()), m->best_reproj_err(),
|
||||
m->alt_reproj_err(), m->ambiguity()}};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<photon::PnpResult>::Pack(google::protobuf::Message* msg,
|
||||
const photon::PnpResult& value) {
|
||||
auto m = static_cast<photonvision::proto::ProtobufPNPResult*>(msg);
|
||||
|
||||
// m->set_is_present(value.isPresent);
|
||||
wpi::PackProtobuf(m->mutable_best(), value.best);
|
||||
m->set_best_reproj_err(value.bestReprojErr);
|
||||
wpi::PackProtobuf(m->mutable_alt(), value.alt);
|
||||
m->set_alt_reproj_err(value.altReprojErr);
|
||||
m->set_ambiguity(value.ambiguity);
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "photon/targeting/proto/PhotonPipelineResultProto.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "photon.pb.h"
|
||||
#include "photon/targeting/proto/MultiTargetPNPResultProto.h"
|
||||
#include "photon/targeting/proto/PhotonTrackedTargetProto.h"
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<photon::PhotonPipelineResult>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
photonvision::proto::ProtobufPhotonPipelineResult>(arena);
|
||||
}
|
||||
|
||||
photon::PhotonPipelineResult
|
||||
wpi::Protobuf<photon::PhotonPipelineResult>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m =
|
||||
static_cast<const photonvision::proto::ProtobufPhotonPipelineResult*>(
|
||||
&msg);
|
||||
|
||||
std::vector<photon::PhotonTrackedTarget> targets;
|
||||
targets.reserve(m->targets_size());
|
||||
for (const auto& t : m->targets()) {
|
||||
targets.emplace_back(wpi::UnpackProtobuf<photon::PhotonTrackedTarget>(t));
|
||||
}
|
||||
|
||||
return photon::PhotonPipelineResult{photon::PhotonPipelineResult_PhotonStruct{
|
||||
photon::PhotonPipelineMetadata{
|
||||
photon::PhotonPipelineMetadata_PhotonStruct{
|
||||
m->sequence_id(),
|
||||
m->capture_timestamp_micros(),
|
||||
m->nt_publish_timestamp_micros(),
|
||||
}},
|
||||
targets,
|
||||
// TODO need to pull this into an optional
|
||||
m->has_multi_target_result()
|
||||
? std::optional<photon::MultiTargetPNPResult>{wpi::UnpackProtobuf<
|
||||
photon::MultiTargetPNPResult>(m->multi_target_result())}
|
||||
: std::nullopt,
|
||||
}};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<photon::PhotonPipelineResult>::Pack(
|
||||
google::protobuf::Message* msg, const photon::PhotonPipelineResult& value) {
|
||||
auto m = static_cast<photonvision::proto::ProtobufPhotonPipelineResult*>(msg);
|
||||
|
||||
m->set_sequence_id(value.metadata.sequenceID);
|
||||
m->set_capture_timestamp_micros(value.metadata.captureTimestampMicros);
|
||||
m->set_nt_publish_timestamp_micros(value.metadata.publishTimestampMicros);
|
||||
|
||||
m->clear_targets();
|
||||
for (const auto& t : value.GetTargets()) {
|
||||
wpi::PackProtobuf(m->add_targets(), t);
|
||||
}
|
||||
|
||||
// TODO this is dumb and bad
|
||||
if (value.multitagResult) {
|
||||
wpi::PackProtobuf(m->mutable_multi_target_result(), *value.multitagResult);
|
||||
} else {
|
||||
m->clear_multi_target_result();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Photon Vision.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "photon/targeting/proto/PhotonTrackedTargetProto.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "photon.pb.h"
|
||||
|
||||
using photon::TargetCorner;
|
||||
using photon::TargetCorner_PhotonStruct;
|
||||
|
||||
google::protobuf::Message* wpi::Protobuf<photon::PhotonTrackedTarget>::New(
|
||||
google::protobuf::Arena* arena) {
|
||||
return google::protobuf::Arena::CreateMessage<
|
||||
photonvision::proto::ProtobufPhotonTrackedTarget>(arena);
|
||||
}
|
||||
|
||||
photon::PhotonTrackedTarget wpi::Protobuf<photon::PhotonTrackedTarget>::Unpack(
|
||||
const google::protobuf::Message& msg) {
|
||||
auto m = static_cast<const photonvision::proto::ProtobufPhotonTrackedTarget*>(
|
||||
&msg);
|
||||
|
||||
std::vector<photon::TargetCorner> minAreaRectCorners;
|
||||
minAreaRectCorners.reserve(4);
|
||||
for (const auto& t : m->min_area_rect_corners()) {
|
||||
minAreaRectCorners.emplace_back(
|
||||
TargetCorner{TargetCorner_PhotonStruct{t.x(), t.y()}});
|
||||
}
|
||||
|
||||
std::vector<photon::TargetCorner> detectedCorners;
|
||||
detectedCorners.reserve(m->detected_corners_size());
|
||||
for (const auto& t : m->detected_corners()) {
|
||||
minAreaRectCorners.emplace_back(
|
||||
TargetCorner{TargetCorner_PhotonStruct{t.x(), t.y()}});
|
||||
}
|
||||
|
||||
return photon::PhotonTrackedTarget{photon::PhotonTrackedTarget_PhotonStruct{
|
||||
m->yaw(), m->pitch(), m->area(), m->skew(), m->fiducial_id(),
|
||||
m->obj_detection_id(), m->obj_detection_conf(),
|
||||
wpi::UnpackProtobuf<frc::Transform3d>(m->best_camera_to_target()),
|
||||
wpi::UnpackProtobuf<frc::Transform3d>(m->alt_camera_to_target()),
|
||||
m->pose_ambiguity(), minAreaRectCorners, detectedCorners}};
|
||||
}
|
||||
|
||||
void wpi::Protobuf<photon::PhotonTrackedTarget>::Pack(
|
||||
google::protobuf::Message* msg, const photon::PhotonTrackedTarget& value) {
|
||||
auto m = static_cast<photonvision::proto::ProtobufPhotonTrackedTarget*>(msg);
|
||||
|
||||
m->set_yaw(value.yaw);
|
||||
m->set_pitch(value.pitch);
|
||||
m->set_area(value.area);
|
||||
m->set_skew(value.skew);
|
||||
m->set_fiducial_id(value.fiducialId);
|
||||
m->set_obj_detection_id(value.objDetectId);
|
||||
m->set_obj_detection_conf(value.objDetectConf);
|
||||
wpi::PackProtobuf(m->mutable_best_camera_to_target(),
|
||||
value.bestCameraToTarget);
|
||||
wpi::PackProtobuf(m->mutable_alt_camera_to_target(), value.altCameraToTarget);
|
||||
m->set_pose_ambiguity(value.poseAmbiguity);
|
||||
|
||||
m->clear_min_area_rect_corners();
|
||||
for (const auto& t : value.GetMinAreaRectCorners()) {
|
||||
auto* corner = m->add_min_area_rect_corners();
|
||||
corner->set_x(t.x);
|
||||
corner->set_y(t.y);
|
||||
}
|
||||
|
||||
m->clear_detected_corners();
|
||||
for (const auto& t : value.GetDetectedCorners()) {
|
||||
auto* corner = m->add_detected_corners();
|
||||
corner->set_x(t.x);
|
||||
corner->set_y(t.y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user