WPILibC++  2019.1.1-beta-4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Servo.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 "frc/PWM.h"
11 #include "frc/SpeedController.h"
12 
13 namespace frc {
14 
21 class Servo : public PWM {
22  public:
27  explicit Servo(int channel);
28 
29  Servo(Servo&&) = default;
30  Servo& operator=(Servo&&) = default;
31 
40  void Set(double value);
41 
47  void SetOffline();
48 
57  double Get() const;
58 
73  void SetAngle(double angle);
74 
83  double GetAngle() const;
84 
90  double GetMaxAngle() const;
91 
97  double GetMinAngle() const;
98 
99  void InitSendable(SendableBuilder& builder) override;
100 
101  private:
102  double GetServoAngleRange() const;
103 
104  static constexpr double kMaxServoAngle = 180.0;
105  static constexpr double kMinServoAngle = 0.0;
106 
107  static constexpr double kDefaultMaxServoPWM = 2.4;
108  static constexpr double kDefaultMinServoPWM = .6;
109 };
110 
111 } // namespace frc
Standard hobby style servo.
Definition: Servo.h:21
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
double GetMaxAngle() const
Get the maximum angle of the servo.
void Set(double value)
Set the servo position.
double GetMinAngle() const
Get the minimum angle of the servo.
Servo(int channel)
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: SendableBuilder.h:23
void SetAngle(double angle)
Set the servo angle.
double GetAngle() const
Get the servo angle.
double Get() const
Get the servo position.
Class implements the PWM generation in the FPGA.
Definition: PWM.h:37
void SetOffline()
Set the servo to offline.