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 #pragma once
9 
10 #include <memory>
11 #include <string>
12 
13 #include "Commands/Command.h"
14 #include "PIDController.h"
15 #include "PIDOutput.h"
16 #include "PIDSource.h"
17 
18 namespace frc {
19 
20 class PIDCommand : public Command, public PIDOutput, public PIDSource {
21  public:
22  PIDCommand(const std::string& name, double p, double i, double d);
23  PIDCommand(const std::string& name, double p, double i, double d,
24  double period);
25  PIDCommand(const std::string& name, double p, double i, double d, double f,
26  double period);
27  PIDCommand(double p, double i, double d);
28  PIDCommand(double p, double i, double d, double period);
29  PIDCommand(double p, double i, double d, double f, double period);
30  virtual ~PIDCommand() = default;
31 
32  void SetSetpointRelative(double deltaSetpoint);
33 
34  // PIDOutput interface
35  virtual void PIDWrite(double output);
36 
37  // PIDSource interface
38  virtual double PIDGet();
39 
40  protected:
41  std::shared_ptr<PIDController> GetPIDController() const;
42  virtual void _Initialize();
43  virtual void _Interrupted();
44  virtual void _End();
45  void SetSetpoint(double setpoint);
46  double GetSetpoint() const;
47  double GetPosition();
48 
49  virtual double ReturnPIDInput() = 0;
50  virtual void UsePIDOutput(double output) = 0;
51 
52  private:
54  std::shared_ptr<PIDController> m_controller;
55 
56  public:
57  void InitTable(std::shared_ptr<ITable> subtable) override;
58  std::string GetSmartDashboardType() const override;
59 };
60 
61 } // namespace frc
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:19
Definition: PIDCommand.h:20
PIDOutput interface is a generic output for the PID class.
Definition: PIDOutput.h:20
std::string GetSmartDashboardType() const override
Definition: PIDCommand.cpp:70
void InitTable(std::shared_ptr< ITable > subtable) override
Initializes a table for this sendable object.
Definition: PIDCommand.cpp:72
The Command class is at the very core of the entire command framework.
Definition: Command.h:52