2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2020-08-14 23:40:33 -07:00
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include "frc/estimator/MerweScaledSigmaPoints.h"
|
|
|
|
|
|
2021-09-17 22:51:51 -07:00
|
|
|
TEST(MerweScaledSigmaPointsTest, ZeroMean) {
|
2020-08-14 23:40:33 -07:00
|
|
|
frc::MerweScaledSigmaPoints<2> sigmaPoints;
|
2022-06-08 22:19:01 -07:00
|
|
|
auto points = sigmaPoints.SquareRootSigmaPoints(
|
2022-04-29 22:29:20 -07:00
|
|
|
frc::Vectord<2>{0.0, 0.0}, frc::Matrixd<2, 2>{{1.0, 0.0}, {0.0, 1.0}});
|
2020-08-14 23:40:33 -07:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
2022-04-29 22:29:20 -07:00
|
|
|
(points - frc::Matrixd<2, 5>{{0.0, 0.00173205, 0.0, -0.00173205, 0.0},
|
2021-08-19 00:23:48 -07:00
|
|
|
{0.0, 0.0, 0.00173205, 0.0, -0.00173205}})
|
2020-08-14 23:40:33 -07:00
|
|
|
.norm() < 1e-3);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-17 22:51:51 -07:00
|
|
|
TEST(MerweScaledSigmaPointsTest, NonzeroMean) {
|
2020-08-14 23:40:33 -07:00
|
|
|
frc::MerweScaledSigmaPoints<2> sigmaPoints;
|
2022-06-08 22:19:01 -07:00
|
|
|
auto points = sigmaPoints.SquareRootSigmaPoints(
|
|
|
|
|
frc::Vectord<2>{1.0, 2.0},
|
|
|
|
|
frc::Matrixd<2, 2>{{1.0, 0.0}, {0.0, std::sqrt(10.0)}});
|
2020-08-14 23:40:33 -07:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
2022-04-29 22:29:20 -07:00
|
|
|
(points - frc::Matrixd<2, 5>{{1.0, 1.00173205, 1.0, 0.998268, 1.0},
|
2021-08-19 00:23:48 -07:00
|
|
|
{2.0, 2.0, 2.00548, 2.0, 1.99452}})
|
2020-08-14 23:40:33 -07:00
|
|
|
.norm() < 1e-3);
|
|
|
|
|
}
|