WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
AnalogAccelerometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 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 
12 #include "frc/AnalogInput.h"
13 #include "frc/ErrorBase.h"
14 #include "frc/PIDSource.h"
15 #include "frc/smartdashboard/SendableBase.h"
16 
17 namespace frc {
18 
27  public SendableBase,
28  public PIDSource {
29  public:
38  explicit AnalogAccelerometer(int channel);
39 
50  explicit AnalogAccelerometer(AnalogInput* channel);
51 
62  explicit AnalogAccelerometer(std::shared_ptr<AnalogInput> channel);
63 
64  ~AnalogAccelerometer() override = default;
65 
67  AnalogAccelerometer& operator=(AnalogAccelerometer&&) = default;
68 
76  double GetAcceleration() const;
77 
87  void SetSensitivity(double sensitivity);
88 
97  void SetZero(double zero);
98 
104  double PIDGet() override;
105 
106  void InitSendable(SendableBuilder& builder) override;
107 
108  private:
112  void InitAccelerometer();
113 
114  std::shared_ptr<AnalogInput> m_analogInput;
115  double m_voltsPerG = 1.0;
116  double m_zeroGVoltage = 2.5;
117 };
118 
119 } // namespace frc
double PIDGet() override
Get the Acceleration for the PID Source parent.
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
double GetAcceleration() const
Return the acceleration in Gs.
void SetSensitivity(double sensitivity)
Set the accelerometer sensitivity.
Handle operation of an analog accelerometer.
Definition: AnalogAccelerometer.h:26
Base class for most objects.
Definition: ErrorBase.h:74
Definition: SendableBase.h:19
Definition: SendableBuilder.h:23
void SetZero(double zero)
Set the voltage that corresponds to 0 G.
AnalogAccelerometer(int channel)
Create a new instance of an accelerometer.
Analog input class.
Definition: AnalogInput.h:32