2021-08-21 02:19:59 -04: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.
|
|
|
|
|
|
|
|
|
|
#include "frc/simulation/UltrasonicSim.h"
|
|
|
|
|
|
|
|
|
|
#include "frc/Ultrasonic.h"
|
|
|
|
|
#include "frc/simulation/SimDeviceSim.h"
|
|
|
|
|
|
|
|
|
|
using namespace frc::sim;
|
|
|
|
|
|
2023-01-09 02:33:07 +02:00
|
|
|
UltrasonicSim::UltrasonicSim(const frc::Ultrasonic& ultrasonic)
|
|
|
|
|
: UltrasonicSim(0, ultrasonic.GetEchoChannel()) {}
|
|
|
|
|
|
|
|
|
|
UltrasonicSim::UltrasonicSim(int ping, int echo) {
|
|
|
|
|
frc::sim::SimDeviceSim deviceSim{"Ultrasonic", echo};
|
2021-08-21 02:19:59 -04:00
|
|
|
m_simRangeValid = deviceSim.GetBoolean("Range Valid");
|
|
|
|
|
m_simRange = deviceSim.GetDouble("Range (in)");
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 07:35:59 -08:00
|
|
|
void UltrasonicSim::SetRangeValid(bool valid) {
|
|
|
|
|
m_simRangeValid.Set(valid);
|
2021-08-21 02:19:59 -04:00
|
|
|
}
|
|
|
|
|
|
2023-01-09 02:33:07 +02:00
|
|
|
void UltrasonicSim::SetRange(units::inch_t range) {
|
2021-10-25 08:58:12 -07:00
|
|
|
m_simRange.Set(range.value());
|
2021-08-21 02:19:59 -04:00
|
|
|
}
|