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"
|
|
|
|
|
|
2020-12-28 01:19:59 -08:00
|
|
|
namespace drake::math {
|
2020-08-14 23:40:33 -07:00
|
|
|
namespace {
|
|
|
|
|
TEST(MerweScaledSigmaPointsTest, TestZeroMean) {
|
|
|
|
|
frc::MerweScaledSigmaPoints<2> sigmaPoints;
|
2021-08-19 00:23:48 -07:00
|
|
|
auto points = sigmaPoints.SigmaPoints(
|
|
|
|
|
Eigen::Vector<double, 2>{0.0, 0.0},
|
|
|
|
|
Eigen::Matrix<double, 2, 2>{{1.0, 0.0}, {0.0, 1.0}});
|
2020-08-14 23:40:33 -07:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
2021-08-19 00:23:48 -07:00
|
|
|
(points -
|
|
|
|
|
Eigen::Matrix<double, 2, 5>{{0.0, 0.00173205, 0.0, -0.00173205, 0.0},
|
|
|
|
|
{0.0, 0.0, 0.00173205, 0.0, -0.00173205}})
|
2020-08-14 23:40:33 -07:00
|
|
|
.norm() < 1e-3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MerweScaledSigmaPointsTest, TestNonzeroMean) {
|
|
|
|
|
frc::MerweScaledSigmaPoints<2> sigmaPoints;
|
2021-08-19 00:23:48 -07:00
|
|
|
auto points = sigmaPoints.SigmaPoints(
|
|
|
|
|
Eigen::Vector<double, 2>{1.0, 2.0},
|
|
|
|
|
Eigen::Matrix<double, 2, 2>{{1.0, 0.0}, {0.0, 10.0}});
|
2020-08-14 23:40:33 -07:00
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
2021-08-19 00:23:48 -07:00
|
|
|
(points -
|
|
|
|
|
Eigen::Matrix<double, 2, 5>{{1.0, 1.00173205, 1.0, 0.998268, 1.0},
|
|
|
|
|
{2.0, 2.0, 2.00548, 2.0, 1.99452}})
|
2020-08-14 23:40:33 -07:00
|
|
|
.norm() < 1e-3);
|
|
|
|
|
}
|
|
|
|
|
} // namespace
|
2020-12-28 01:19:59 -08:00
|
|
|
} // namespace drake::math
|