WPILibC++ 2023.4.3
UltrasonicSim.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <hal/SimDevice.h>
8#include <units/length.h>
9
10namespace frc {
11
12class Ultrasonic;
13
14namespace sim {
15
16/**
17 * Class to control a simulated {@link Ultrasonic}.
18 */
20 public:
21 /**
22 * Constructor.
23 *
24 * @param ultrasonic The real ultrasonic to simulate
25 */
26 explicit UltrasonicSim(const Ultrasonic& ultrasonic);
27
28 /**
29 * Constructor.
30 *
31 * @param ping unused.
32 * @param echo the ultrasonic's echo channel.
33 */
34 UltrasonicSim(int ping, int echo);
35
36 /**
37 * Sets if the range measurement is valid.
38 *
39 * @param isValid True if valid
40 */
41 void SetRangeValid(bool isValid);
42
43 /**
44 * Sets the range measurement
45 *
46 * @param range The range
47 */
48 void SetRange(units::inch_t range);
49
50 private:
51 hal::SimBoolean m_simRangeValid;
52 hal::SimDouble m_simRange;
53};
54
55} // namespace sim
56} // namespace frc
Ultrasonic rangefinder class.
Definition: Ultrasonic.h:39
Class to control a simulated Ultrasonic.
Definition: UltrasonicSim.h:19
UltrasonicSim(int ping, int echo)
Constructor.
void SetRange(units::inch_t range)
Sets the range measurement.
UltrasonicSim(const Ultrasonic &ultrasonic)
Constructor.
void SetRangeValid(bool isValid)
Sets if the range measurement is valid.
Definition: AprilTagFieldLayout.h:22