WPILibC++  unspecified
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 "SafePWM.h"
11 #include "SpeedController.h"
12 
13 namespace frc {
14 
21 class Servo : public SafePWM {
22  public:
23  explicit Servo(int channel);
24  void Set(double value);
25  void SetOffline();
26  double Get() const;
27  void SetAngle(double angle);
28  double GetAngle() const;
29  static double GetMaxAngle() { return kMaxServoAngle; }
30  static double GetMinAngle() { return kMinServoAngle; }
31 
32  void InitSendable(SendableBuilder& builder) override;
33 
34  private:
35  double GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
36 
37  static constexpr double kMaxServoAngle = 180.0;
38  static constexpr double kMinServoAngle = 0.0;
39 
40  static constexpr double kDefaultMaxServoPWM = 2.4;
41  static constexpr double kDefaultMinServoPWM = .6;
42 };
43 
44 } // namespace frc
Standard hobby style servo.
Definition: Servo.h:21
Definition: RobotController.cpp:14
double GetAngle() const
Get the servo angle.
Definition: Servo.cpp:96
double Get() const
Get the servo position.
Definition: Servo.cpp:62
void SetAngle(double angle)
Set the servo angle.
Definition: Servo.cpp:78
void Set(double value)
Set the servo position.
Definition: Servo.cpp:45
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: Servo.cpp:100
A safe version of the PWM class.
Definition: SafePWM.h:28
Definition: SendableBuilder.h:23
void SetOffline()
Set the servo to offline.
Definition: Servo.cpp:52
Servo(int channel)
Definition: Servo.cpp:26