WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
AnalogAccelerometer.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2017. 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 <string>
12 
13 #include "AnalogInput.h"
14 #include "LiveWindow/LiveWindowSendable.h"
15 #include "PIDSource.h"
16 #include "SensorBase.h"
17 
18 namespace frc {
19 
27  public PIDSource,
28  public LiveWindowSendable {
29  public:
30  explicit AnalogAccelerometer(int channel);
31  explicit AnalogAccelerometer(AnalogInput* channel);
32  explicit AnalogAccelerometer(std::shared_ptr<AnalogInput> channel);
33  virtual ~AnalogAccelerometer() = default;
34 
35  double GetAcceleration() const;
36  void SetSensitivity(double sensitivity);
37  void SetZero(double zero);
38  double PIDGet() override;
39 
40  void UpdateTable() override;
41  void StartLiveWindowMode() override;
42  void StopLiveWindowMode() override;
43  std::string GetSmartDashboardType() const override;
44  void InitTable(std::shared_ptr<ITable> subTable) override;
45  std::shared_ptr<ITable> GetTable() const override;
46 
47  private:
48  void InitAccelerometer();
49 
50  std::shared_ptr<AnalogInput> m_analogInput;
51  double m_voltsPerG = 1.0;
52  double m_zeroGVoltage = 2.5;
53 
54  std::shared_ptr<ITable> m_table;
55 };
56 
57 } // namespace frc
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: AnalogAccelerometer.cpp:118
void SetSensitivity(double sensitivity)
Set the accelerometer sensitivity.
Definition: AnalogAccelerometer.cpp:97
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Base class for all sensors.
Definition: SensorBase.h:22
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: AnalogAccelerometer.cpp:124
double GetAcceleration() const
Return the acceleration in Gs.
Definition: AnalogAccelerometer.cpp:84
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:19
void InitTable(std::shared_ptr< ITable > subTable) override
Initializes a table for this sendable object.
Definition: AnalogAccelerometer.cpp:132
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: AnalogAccelerometer.cpp:126
AnalogAccelerometer(int channel)
Create a new instance of an accelerometer.
Definition: AnalogAccelerometer.cpp:34
Handle operation of an analog accelerometer.
Definition: AnalogAccelerometer.h:26
std::shared_ptr< ITable > GetTable() const override
Definition: AnalogAccelerometer.cpp:137
std::string GetSmartDashboardType() const override
Definition: AnalogAccelerometer.cpp:128
double PIDGet() override
Get the Acceleration for the PID Source parent.
Definition: AnalogAccelerometer.cpp:116
void SetZero(double zero)
Set the voltage that corresponds to 0 G.
Definition: AnalogAccelerometer.cpp:109
Analog input class.
Definition: AnalogInput.h:32