Now you can download a copy of these docs so you can use them offline! Download now
Encoder.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef QUAD_ENCODER_H_
8 #define QUAD_ENCODER_H_
9 
10 #include "ChipObject.h"
11 #include "CounterBase.h"
12 #include "SensorBase.h"
13 #include "Counter.h"
14 #include "PIDSource.h"
15 #include "LiveWindow/LiveWindowSendable.h"
16 
17 class DigitalSource;
18 
28 class Encoder: public SensorBase, public CounterBase, public PIDSource, public LiveWindowSendable
29 {
30 public:
31 
32  Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
33  Encoder(uint8_t aModuleNumber, uint32_t aChannel, uint8_t bModuleNumber, uint32_t _bChannel, bool reverseDirection=false, EncodingType encodingType = k4X);
34  Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
35  Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
36  virtual ~Encoder();
37 
38  // CounterBase interface
39  void Start();
40  int32_t Get();
41  int32_t GetRaw();
42  void Reset();
43  void Stop();
44  double GetPeriod();
45  void SetMaxPeriod(double maxPeriod);
46  bool GetStopped();
47  bool GetDirection();
48  double GetDistance();
49  double GetRate();
50  void SetMinRate(double minRate);
51  void SetDistancePerPulse(double distancePerPulse);
52  void SetReverseDirection(bool reverseDirection);
53  void SetSamplesToAverage(int samplesToAverage);
54  int GetSamplesToAverage();
55  void SetPIDSourceParameter(PIDSourceParameter pidSource);
56  double PIDGet();
57 
58  void UpdateTable();
59  void StartLiveWindowMode();
60  void StopLiveWindowMode();
61  std::string GetSmartDashboardType();
62  void InitTable(ITable *subTable);
63  ITable * GetTable();
64 
65 private:
66  void InitEncoder(bool _reverseDirection, EncodingType encodingType);
67  double DecodingScaleFactor();
68 
69  DigitalSource *m_aSource; // the A phase of the quad encoder
70  DigitalSource *m_bSource; // the B phase of the quad encoder
71  bool m_allocatedASource; // was the A source allocated locally?
72  bool m_allocatedBSource; // was the B source allocated locally?
73  tEncoder* m_encoder;
74  uint8_t m_index;
75  double m_distancePerPulse; // distance of travel for each encoder tick
76  Counter *m_counter; // Counter object for 1x and 2x encoding
77  EncodingType m_encodingType; // Encoding type
78  PIDSourceParameter m_pidSource;// Encoder parameter that sources a PID controller
79 
80  ITable *m_table;
81 };
82 
83 #endif
84 
void SetPIDSourceParameter(PIDSourceParameter pidSource)
Definition: Encoder.cpp:548
bool GetStopped()
Definition: Encoder.cpp:365
ITable * GetTable()
Definition: Encoder.cpp:601
void InitTable(ITable *subTable)
Definition: Encoder.cpp:596
void Stop()
Definition: Encoder.cpp:228
virtual ~Encoder()
Definition: Encoder.cpp:193
void Start()
Definition: Encoder.cpp:212
Definition: ITable.h:26
void StartLiveWindowMode()
Definition: Encoder.cpp:581
void Reset()
Definition: Encoder.cpp:279
int32_t GetRaw()
Definition: Encoder.cpp:247
void SetReverseDirection(bool reverseDirection)
Definition: Encoder.cpp:477
void StopLiveWindowMode()
Definition: Encoder.cpp:585
double PIDGet()
Definition: Encoder.cpp:559
double GetRate()
Definition: Encoder.cpp:437
void SetMinRate(double minRate)
Definition: Encoder.cpp:448
void SetDistancePerPulse(double distancePerPulse)
Definition: Encoder.cpp:465
int GetSamplesToAverage()
Definition: Encoder.cpp:524
void SetSamplesToAverage(int samplesToAverage)
Definition: Encoder.cpp:499
void SetMaxPeriod(double maxPeriod)
Definition: Encoder.cpp:343
void UpdateTable()
Definition: Encoder.cpp:573
std::string GetSmartDashboardType()
Definition: Encoder.cpp:589
bool GetDirection()
Definition: Encoder.cpp:385
double GetDistance()
Definition: Encoder.cpp:425
double GetPeriod()
Definition: Encoder.cpp:301
int32_t Get()
Definition: Encoder.cpp:269

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6