WPILibC++  2020.3.2
AnalogGyroSim.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 #include <utility>
12 
13 #include "CallbackStore.h"
14 #include "mockdata/AnalogGyroData.h"
15 
16 namespace frc {
17 namespace sim {
19  public:
20  explicit AnalogGyroSim(int index) { m_index = index; }
21 
22  std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
23  bool initialNotify) {
24  auto store = std::make_unique<CallbackStore>(
25  m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
26  store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
27  m_index, &CallbackStoreThunk, store.get(), initialNotify));
28  return store;
29  }
30 
31  double GetAngle() const { return HALSIM_GetAnalogGyroAngle(m_index); }
32 
33  void SetAngle(double angle) { HALSIM_SetAnalogGyroAngle(m_index, angle); }
34 
35  std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
36  bool initialNotify) {
37  auto store = std::make_unique<CallbackStore>(
38  m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
39  store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
40  m_index, &CallbackStoreThunk, store.get(), initialNotify));
41  return store;
42  }
43 
44  double GetRate() const { return HALSIM_GetAnalogGyroRate(m_index); }
45 
46  void SetRate(double rate) { HALSIM_SetAnalogGyroRate(m_index, rate); }
47 
48  std::unique_ptr<CallbackStore> RegisterInitializedCallback(
49  NotifyCallback callback, bool initialNotify) {
50  auto store = std::make_unique<CallbackStore>(
51  m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
52  store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
53  m_index, &CallbackStoreThunk, store.get(), initialNotify));
54  return store;
55  }
56 
57  bool GetInitialized() const {
58  return HALSIM_GetAnalogGyroInitialized(m_index);
59  }
60 
61  void SetInitialized(bool initialized) {
62  HALSIM_SetAnalogGyroInitialized(m_index, initialized);
63  }
64 
65  void ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
66 
67  private:
68  int m_index;
69 };
70 } // namespace sim
71 } // namespace frc
frc::sim::AnalogGyroSim
Definition: AnalogGyroSim.h:18
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16