[sim] Add sim wrappers for sensors that use SimDevice (#3517)

This commit is contained in:
PJ Reiniger
2021-08-21 02:19:59 -04:00
committed by GitHub
parent 2b3e2ebc11
commit 2edd510ab7
35 changed files with 771 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
// 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.
#include "frc/Ultrasonic.h"
#include "frc/simulation/UltrasonicSim.h"
#include "gtest/gtest.h"
namespace frc {
TEST(UltrasonicTest, SimDevices) {
Ultrasonic ultrasonic{0, 1};
sim::UltrasonicSim sim{ultrasonic};
EXPECT_EQ(0, ultrasonic.GetRange().to<double>());
EXPECT_TRUE(ultrasonic.IsRangeValid());
sim.SetRange(units::meter_t{35.04});
EXPECT_EQ(35.04, ultrasonic.GetRange().to<double>());
sim.SetRangeValid(false);
EXPECT_FALSE(ultrasonic.IsRangeValid());
EXPECT_EQ(0, ultrasonic.GetRange().to<double>());
}
} // namespace frc