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.
|
2014-07-21 08:57:03 -04:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/BuiltInAccelerometer.h" // NOLINT(build/include_order)
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2023-08-28 15:13:34 -07:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/Timer.h"
|
2016-05-25 22:38:11 -07:00
|
|
|
|
2014-07-24 18:19:43 -04:00
|
|
|
static constexpr double kAccelerationTolerance = 0.1;
|
2021-05-31 10:21:34 -07:00
|
|
|
|
2014-07-21 08:57:03 -04:00
|
|
|
/**
|
|
|
|
|
* There's not much we can automatically test with the on-board accelerometer,
|
|
|
|
|
* but checking for gravity is probably good enough to tell that it's working.
|
|
|
|
|
*/
|
2014-07-31 15:49:55 -04:00
|
|
|
TEST(BuiltInAccelerometerTest, Accelerometer) {
|
2021-05-31 10:21:34 -07:00
|
|
|
frc::BuiltInAccelerometer accelerometer;
|
2014-07-21 08:57:03 -04:00
|
|
|
|
2021-05-31 10:21:34 -07:00
|
|
|
// The testbench sometimes shakes a little from a previous test. Give it some
|
|
|
|
|
// time.
|
|
|
|
|
frc::Wait(1_s);
|
2014-07-24 18:19:43 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
ASSERT_NEAR(0.0, accelerometer.GetX(), kAccelerationTolerance);
|
|
|
|
|
ASSERT_NEAR(1.0, accelerometer.GetY(), kAccelerationTolerance);
|
|
|
|
|
ASSERT_NEAR(0.0, accelerometer.GetZ(), kAccelerationTolerance);
|
2014-07-21 08:57:03 -04:00
|
|
|
}
|