WPILibC++ 2023.4.3
AnalogEncoderSim.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
11
12namespace frc {
13
14class AnalogEncoder;
15
16namespace sim {
17
18/**
19 * Class to control a simulated analog encoder.
20 */
22 public:
23 /**
24 * Constructs from an AnalogEncoder object.
25 *
26 * @param encoder AnalogEncoder to simulate
27 */
28 explicit AnalogEncoderSim(const AnalogEncoder& encoder);
29
30 /**
31 * Set the position using an Rotation2d.
32 *
33 * @param angle The angle.
34 */
36
37 /**
38 * Set the position of the encoder.
39 *
40 * @param turns The position.
41 */
42 void SetTurns(units::turn_t turns);
43
44 /**
45 * Get the simulated position.
46 */
47 units::turn_t GetTurns();
48
49 /**
50 * Get the position as a Rotation2d.
51 */
53
54 private:
55 hal::SimDouble m_positionSim;
56};
57} // namespace sim
58} // namespace frc
Class for supporting continuous analog encoders, such as the US Digital MA3.
Definition: AnalogEncoder.h:25
A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Definition: Rotation2d.h:26
Class to control a simulated analog encoder.
Definition: AnalogEncoderSim.h:21
AnalogEncoderSim(const AnalogEncoder &encoder)
Constructs from an AnalogEncoder object.
Rotation2d GetPosition()
Get the position as a Rotation2d.
void SetPosition(Rotation2d angle)
Set the position using an Rotation2d.
void SetTurns(units::turn_t turns)
Set the position of the encoder.
units::turn_t GetTurns()
Get the simulated position.
Definition: AprilTagFieldLayout.h:22