WPILibC++  2020.3.2-23-gf6df921
Servo.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 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 = 0.6;
109 };
110 
111 } // namespace frc
frc::PWM
Class implements the PWM generation in the FPGA.
Definition: PWM.h:40
frc::Servo::GetMaxAngle
double GetMaxAngle() const
Get the maximum angle of the servo.
frc::Servo::Servo
Servo(int channel)
frc::Servo::GetAngle
double GetAngle() const
Get the servo angle.
frc::Servo::GetMinAngle
double GetMinAngle() const
Get the minimum angle of the servo.
frc::Servo::SetOffline
void SetOffline()
Set the servo to offline.
frc::Servo::Get
double Get() const
Get the servo position.
frc::Servo::Set
void Set(double value)
Set the servo position.
frc::Servo::SetAngle
void SetAngle(double angle)
Set the servo angle.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: RoboRioSim.h:16
frc::Servo::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::Servo
Standard hobby style servo.
Definition: Servo.h:21
frc::SendableBuilder
Definition: SendableBuilder.h:23