WPILibC++  2018.4.1-1235-g11e5faf
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
PIDController.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 #include <string>
12 
13 #include <wpi/deprecated.h>
14 #include <wpi/mutex.h>
15 
16 #include "frc/Base.h"
17 #include "frc/Controller.h"
18 #include "frc/Notifier.h"
19 #include "frc/PIDBase.h"
20 #include "frc/PIDSource.h"
21 #include "frc/Timer.h"
22 #include "frc/filters/LinearDigitalFilter.h"
23 
24 namespace frc {
25 
26 class PIDOutput;
27 
38 class PIDController : public PIDBase, public Controller {
39  public:
52  PIDController(double p, double i, double d, PIDSource* source,
53  PIDOutput* output, double period = 0.05);
54 
67  PIDController(double p, double i, double d, double f, PIDSource* source,
68  PIDOutput* output, double period = 0.05);
69 
82  PIDController(double p, double i, double d, PIDSource& source,
83  PIDOutput& output, double period = 0.05);
84 
97  PIDController(double p, double i, double d, double f, PIDSource& source,
98  PIDOutput& output, double period = 0.05);
99 
100  ~PIDController() override;
101 
102  PIDController(PIDController&&) = default;
103  PIDController& operator=(PIDController&&) = default;
104 
108  void Enable() override;
109 
114  void Disable() override;
115 
119  void SetEnabled(bool enable);
120 
124  bool IsEnabled() const;
125 
129  void Reset() override;
130 
131  void InitSendable(SendableBuilder& builder) override;
132 
133  private:
134  std::unique_ptr<Notifier> m_controlLoop;
135 };
136 
137 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void Reset() override
Reset the previous error, the integral term, and disable the controller.
Interface for Controllers.
Definition: Controller.h:19
void Enable() override
Begin running the PIDController.
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
Class implements a PID Control Loop.
Definition: PIDController.h:38
PIDOutput interface is a generic output for the PID class.
Definition: PIDOutput.h:20
bool IsEnabled() const
Return true if PIDController is enabled.
PIDController(double p, double i, double d, PIDSource *source, PIDOutput *output, double period=0.05)
Allocate a PID object with the given constants for P, I, D.
Class implements a PID Control Loop.
Definition: PIDBase.h:36
void SetEnabled(bool enable)
Set the enabled state of the PIDController.
Definition: SendableBuilder.h:23
void Disable() override
Stop running the PIDController, this sets the output to zero before stopping.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.