Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Nov 24, 2023
1 parent ca15e66 commit 4826b18
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 111 deletions.
1 change: 0 additions & 1 deletion photon-lib/src/test/native/cpp/PhotonPoseEstimatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "photon/PhotonCamera.h"
#include "photon/PhotonPoseEstimator.h"
#include "photon/targeting/MultiTargetPNPResult.h"
#include "photon/targeting/PNPResult.h"
#include "photon/targeting/PhotonPipelineResult.h"
#include "photon/targeting/PhotonTrackedTarget.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,39 @@
#include "photon/targeting/MultiTargetPNPResult.h"

TEST(MultiTargetPNPResultTest, Equality) {
photon::MultiTargetPNPResult a;
photon::MultiTargetPNPResult b;

EXPECT_EQ(a, b);

photon::PNPResult pnpRes{
photon::MultiTargetPNPResult a{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1, 0};
0.1,
0,

photon::MultiTargetPNPResult a1{pnpRes, {1, 2, 3, 4}};
photon::MultiTargetPNPResult b1{pnpRes, {1, 2, 3, 4}};
{1, 2, 3, 4}};
photon::MultiTargetPNPResult b{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
0,
{1, 2, 3, 4}};

EXPECT_EQ(a1, b1);
EXPECT_EQ(a, b);
}

TEST(MultiTargetPNPResultTest, Roundtrip) {
photon::MultiTargetPNPResult result;
photon::MultiTargetPNPResult result{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
0,
{1, 2, 3, 4}};

google::protobuf::Arena arena;
google::protobuf::Message* proto =
Expand All @@ -51,22 +63,4 @@ TEST(MultiTargetPNPResultTest, Roundtrip) {
wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(*proto);

EXPECT_EQ(result, unpacked_data);

photon::PNPResult pnpRes{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1, 0};

photon::MultiTargetPNPResult result1{pnpRes, {1, 2, 3, 4}};

proto = wpi::Protobuf<photon::MultiTargetPNPResult>::New(&arena);
wpi::Protobuf<photon::MultiTargetPNPResult>::Pack(proto, result1);

photon::MultiTargetPNPResult unpacked_data1 =
wpi::Protobuf<photon::MultiTargetPNPResult>::Unpack(*proto);

EXPECT_EQ(result1, unpacked_data1);
}
72 changes: 0 additions & 72 deletions photon-targeting/src/test/native/cpp/targeting/PNPResultTest.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,22 @@ TEST(PhotonPipelineResultTest, Equality) {

EXPECT_EQ(a1, b1);

photon::PNPResult pnpRes{
photon::MultiTargetPNPResult multitagRes{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1, 0};

photon::MultiTargetPNPResult multitagRes{pnpRes, {1, 2, 3, 4}};
0.1,
0,
{1, 2, 3, 4}};

photon::PhotonPipelineResult a2{12_ms, targets, multitagRes};
photon::PhotonPipelineResult b2{12_ms, targets, multitagRes};

EXPECT_EQ(a2, b2);
}

// TODO
TEST(PhotonPipelineResultTest, Roundtrip) {
photon::PhotonPipelineResult result{12_ms, {}};

Expand Down Expand Up @@ -130,15 +129,15 @@ TEST(PhotonPipelineResultTest, Roundtrip) {

EXPECT_EQ(result2, unpacked_data2);

photon::PNPResult pnpRes{
photon::MultiTargetPNPResult multitagRes{
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1,
frc::Transform3d(frc::Translation3d(1_m, 2_m, 3_m),
frc::Rotation3d(1_rad, 2_rad, 3_rad)),
0.1, 0};

photon::MultiTargetPNPResult multitagRes{pnpRes, {1, 2, 3, 4}};
0.1,
0,
{1, 2, 3, 4}};

photon::PhotonPipelineResult result3{12_ms, targets, multitagRes};

Expand Down

0 comments on commit 4826b18

Please sign in to comment.