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.
|
2019-09-08 00:11:49 -04:00
|
|
|
|
2022-10-15 16:33:14 -07:00
|
|
|
#include <numbers>
|
2019-09-08 00:11:49 -04:00
|
|
|
|
2023-08-28 15:13:34 -07:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/math/kinematics/DifferentialDriveKinematics.hpp"
|
|
|
|
|
#include "wpi/math/kinematics/DifferentialDriveOdometry.hpp"
|
2019-09-08 00:11:49 -04:00
|
|
|
|
|
|
|
|
static constexpr double kEpsilon = 1E-9;
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
2021-09-21 06:12:50 -07:00
|
|
|
TEST(DifferentialDriveOdometryTest, EncoderDistances) {
|
2022-11-18 23:42:00 -05:00
|
|
|
DifferentialDriveOdometry odometry{45_deg, 0_m, 0_m};
|
2019-11-19 12:56:34 -05:00
|
|
|
|
2022-08-17 13:42:36 -07:00
|
|
|
const auto& pose =
|
2022-10-15 16:33:14 -07:00
|
|
|
odometry.Update(135_deg, 0_m, units::meter_t{5 * std::numbers::pi});
|
2019-11-19 12:56:34 -05:00
|
|
|
|
2021-10-25 08:58:12 -07:00
|
|
|
EXPECT_NEAR(pose.X().value(), 5.0, kEpsilon);
|
|
|
|
|
EXPECT_NEAR(pose.Y().value(), 5.0, kEpsilon);
|
|
|
|
|
EXPECT_NEAR(pose.Rotation().Degrees().value(), 90.0, kEpsilon);
|
2019-11-19 12:56:34 -05:00
|
|
|
}
|