WPILibC++  2018.4.1-20180824021726-1174-g488ba79
 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 
73  double GetAcceleration() const;
74 
84  void SetSensitivity(double sensitivity);
85 
94  void SetZero(double zero);
95 
101  double PIDGet() override;
102 
103  void InitSendable(SendableBuilder& builder) override;
104 
105  private:
109  void InitAccelerometer();
110 
111  std::shared_ptr<AnalogInput> m_analogInput;
112  double m_voltsPerG = 1.0;
113  double m_zeroGVoltage = 2.5;
114 };
115 
116 } // 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