WPILibC++ 2023.4.3
DutyCycleEncoderSim.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/angle.h>
9
10namespace frc {
11
12class DutyCycleEncoder;
13
14namespace sim {
15
16/**
17 * Class to control a simulated duty cycle encoder.
18 */
20 public:
21 /**
22 * Constructs from a DutyCycleEncoder object.
23 *
24 * @param encoder DutyCycleEncoder to simulate
25 */
26 explicit DutyCycleEncoderSim(const DutyCycleEncoder& encoder);
27
28 /**
29 * Constructs from a digital input channel.
30 *
31 * @param channel digital input channel
32 */
33 explicit DutyCycleEncoderSim(int channel);
34
35 /**
36 * Set the position in turns.
37 *
38 * @param turns The position.
39 */
40 void Set(units::turn_t turns);
41
42 /**
43 * Set the position.
44 */
45 void SetDistance(double distance);
46
47 private:
48 hal::SimDouble m_simPosition;
49 hal::SimDouble m_simDistancePerRotation;
50};
51
52} // namespace sim
53} // namespace frc
Class for supporting duty cycle/PWM encoders, such as the US Digital MA3 with PWM Output,...
Definition: DutyCycleEncoder.h:28
Class to control a simulated duty cycle encoder.
Definition: DutyCycleEncoderSim.h:19
DutyCycleEncoderSim(int channel)
Constructs from a digital input channel.
void Set(units::turn_t turns)
Set the position in turns.
void SetDistance(double distance)
Set the position.
DutyCycleEncoderSim(const DutyCycleEncoder &encoder)
Constructs from a DutyCycleEncoder object.
Definition: AprilTagFieldLayout.h:22