WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
PIDCommand.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2011-2016. 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 #ifndef __PID_COMMAND_H__
9 #define __PID_COMMAND_H__
10 
11 #include "Commands/Command.h"
12 #include "PIDController.h"
13 #include "PIDSource.h"
14 #include "PIDOutput.h"
15 
16 #include <memory>
17 
18 class PIDCommand : public Command, public PIDOutput, public PIDSource {
19  public:
20  PIDCommand(const std::string &name, double p, double i, double d);
21  PIDCommand(const std::string &name, double p, double i, double d, double period);
22  PIDCommand(const std::string &name, double p, double i, double d, double f,
23  double period);
24  PIDCommand(double p, double i, double d);
25  PIDCommand(double p, double i, double d, double period);
26  PIDCommand(double p, double i, double d, double f, double period);
27  virtual ~PIDCommand() = default;
28 
29  void SetSetpointRelative(double deltaSetpoint);
30 
31  // PIDOutput interface
32  virtual void PIDWrite(float output);
33 
34  // PIDSource interface
35  virtual double PIDGet();
36 
37  protected:
38  std::shared_ptr<PIDController> GetPIDController() const;
39  virtual void _Initialize();
40  virtual void _Interrupted();
41  virtual void _End();
42  void SetSetpoint(double setpoint);
43  double GetSetpoint() const;
44  double GetPosition();
45 
46  virtual double ReturnPIDInput() = 0;
47  virtual void UsePIDOutput(double output) = 0;
48 
49  private:
51  std::shared_ptr<PIDController> m_controller;
52 
53  public:
54  virtual void InitTable(std::shared_ptr<ITable> table);
55  virtual std::string GetSmartDashboardType() const;
56 };
57 
58 #endif
virtual std::string GetSmartDashboardType() const
Definition: PIDCommand.cpp:67
virtual void InitTable(std::shared_ptr< ITable > table)
Initializes a table for this sendable object.
Definition: PIDCommand.cpp:68
PIDOutput interface is a generic output for the PID class.
Definition: PIDOutput.h:18
Definition: PIDCommand.h:18
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:18
The Command class is at the very core of the entire command framework.
Definition: Command.h:54