libPlayingWithFusion  2020.02.24
Playing With Fusion driver library for FRC roboRIO
TimeOfFlight.h
1 #pragma once
2 
3 #include "frc/PIDSource.h"
4 #include "frc/smartdashboard/SendableBase.h"
5 #include "frc/smartdashboard/SendableBuilder.h"
6 #include "TimeOfFlightApi.h"
7 
8 namespace frc {
9 class TimeOfFlightImpl;
10 
11 class TimeOfFlight : public PIDSource, public SendableBase {
12 public:
13  enum RangingMode {
14  kShort = 0,
15  kMedium = 1,
16  kLong = 2
17  };
18 
19  enum Status {
23  kValid = 0,
24 
31 
39 
47 
52 
61 
66 
70  kInvalid = 14
71  };
72 
73 
85  explicit TimeOfFlight(uint8_t sensorID);
86  virtual ~TimeOfFlight();
87 
88  // Delete Copy constructor and assignment operator
89  TimeOfFlight(const TimeOfFlight&) =delete;
90  TimeOfFlight& operator=(const TimeOfFlight&) =delete;
91 
92  // Use default Move constructor and assignment operator
93  TimeOfFlight(TimeOfFlight&&) =default;
94  TimeOfFlight& operator=(TimeOfFlight&&) =default;
95 
101  void IdentifySensor();
102 
108  uint32_t GetFirmwareVersion() const;
109 
115  uint32_t GetSerialNumber() const;
116 
122  bool IsRangeValid() const;
123 
129  double GetRange() const;
130 
136  double GetRangeSigma() const;
137 
143  double GetAmbientLightLevel() const;
144 
150  Status GetStatus() const;
151 
170  void SetRangingMode(RangingMode mode, double sampleTime);
171 
202  void SetRangeOfInterest(uint8_t topLeftX, uint8_t topLeftY, uint8_t bottomRightX, uint8_t bottomRightY);
203 
209  double PIDGet() override;
210 
211  void SetPIDSourceType(PIDSourceType pidSource) override;
212 
213  void InitSendable(SendableBuilder& builder) override;
214 
215 private:
216  TimeOfFlight_t *m_timeOfFlightHandle;
217  RangingMode m_rangingMode;
218 };
219 
220 }
frc::TimeOfFlight::GetStatus
Status GetStatus() const
Definition: TimeOfFlight.cpp:45
frc::TimeOfFlight::PIDGet
double PIDGet() override
Definition: TimeOfFlight.cpp:57
frc::TimeOfFlight::TimeOfFlight
TimeOfFlight(uint8_t sensorID)
Definition: TimeOfFlight.cpp:6
frc::TimeOfFlight::GetRange
double GetRange() const
Definition: TimeOfFlight.cpp:33
frc::TimeOfFlight::GetAmbientLightLevel
double GetAmbientLightLevel() const
Definition: TimeOfFlight.cpp:41
frc::TimeOfFlight::Status
Status
Definition: TimeOfFlight.h:19
frc::TimeOfFlight::IsRangeValid
bool IsRangeValid() const
Definition: TimeOfFlight.cpp:29
frc::TimeOfFlight::kWrappedTarget
Definition: TimeOfFlight.h:60
frc::TimeOfFlight
Definition: TimeOfFlight.h:11
frc::TimeOfFlight::kReturnSignalLow
Definition: TimeOfFlight.h:38
frc::TimeOfFlight::SetRangingMode
void SetRangingMode(RangingMode mode, double sampleTime)
Definition: TimeOfFlight.cpp:49
frc::TimeOfFlight::kSigmaHigh
Definition: TimeOfFlight.h:30
frc::TimeOfFlight::kInternalError
Definition: TimeOfFlight.h:65
frc::TimeOfFlight::kReturnPhaseBad
Definition: TimeOfFlight.h:46
frc::TimeOfFlight::kValid
Definition: TimeOfFlight.h:23
frc::TimeOfFlight::IdentifySensor
void IdentifySensor()
Definition: TimeOfFlight.cpp:17
frc::TimeOfFlight::GetRangeSigma
double GetRangeSigma() const
Definition: TimeOfFlight.cpp:37
frc::TimeOfFlight::kHardwareFailure
Definition: TimeOfFlight.h:51
frc::TimeOfFlight::SetRangeOfInterest
void SetRangeOfInterest(uint8_t topLeftX, uint8_t topLeftY, uint8_t bottomRightX, uint8_t bottomRightY)
Definition: TimeOfFlight.cpp:53
frc::TimeOfFlight::GetFirmwareVersion
uint32_t GetFirmwareVersion() const
Definition: TimeOfFlight.cpp:21
frc::TimeOfFlight::GetSerialNumber
uint32_t GetSerialNumber() const
Definition: TimeOfFlight.cpp:25
frc::TimeOfFlight::kInvalid
Definition: TimeOfFlight.h:70