2019-09-08 00:11:49 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
|
|
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#include <wpi/math>
|
|
|
|
|
|
|
|
|
|
#include "frc/kinematics/DifferentialDriveKinematics.h"
|
|
|
|
|
#include "frc/kinematics/DifferentialDriveOdometry.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
|
|
static constexpr double kEpsilon = 1E-9;
|
|
|
|
|
|
|
|
|
|
using namespace frc;
|
|
|
|
|
|
2019-11-19 12:56:34 -05:00
|
|
|
TEST(DifferentialDriveOdometry, 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,
|
|
|
|
|
units::meter_t(5 * wpi::math::pi));
|
|
|
|
|
|
|
|
|
|
EXPECT_NEAR(pose.Translation().X().to<double>(), 5.0, kEpsilon);
|
|
|
|
|
EXPECT_NEAR(pose.Translation().Y().to<double>(), 5.0, kEpsilon);
|
|
|
|
|
EXPECT_NEAR(pose.Rotation().Degrees().to<double>(), 90.0, kEpsilon);
|
|
|
|
|
}
|