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
|
|
|
|
2021-05-26 00:09:36 -07:00
|
|
|
#include <wpi/numbers>
|
2019-09-08 00:11:49 -04:00
|
|
|
|
|
|
|
|
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
|
|
|
|
#include "frc/kinematics/DifferentialDriveOdometry.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
static constexpr double kEpsilon = 1E-9;
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
2021-09-21 06:12:50 -07:00
|
|
|
TEST(DifferentialDriveOdometryTest, EncoderDistances) {
|
2019-12-01 02:10:29 -05:00
|
|
|
DifferentialDriveOdometry odometry{Rotation2d(45_deg)};
|
2019-11-19 12:56:34 -05:00
|
|
|
|
|
|
|
|
const auto& pose = odometry.Update(Rotation2d(135_deg), 0_m,
|
2021-05-26 00:09:36 -07:00
|
|
|
units::meter_t(5 * wpi::numbers::pi));
|
2019-11-19 12:56:34 -05:00
|
|
|
|
2020-07-02 18:09:36 -07:00
|
|
|
EXPECT_NEAR(pose.X().to<double>(), 5.0, kEpsilon);
|
|
|
|
|
EXPECT_NEAR(pose.Y().to<double>(), 5.0, kEpsilon);
|
2019-11-19 12:56:34 -05:00
|
|
|
EXPECT_NEAR(pose.Rotation().Degrees().to<double>(), 90.0, kEpsilon);
|
|
|
|
|
}
|