|
| 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/PIDOutput.h" |
| 11 | + |
| 12 | +namespace frc { |
| 13 | + |
| 14 | +/** |
| 15 | + * Interface for speed controlling devices. |
| 16 | + */ |
| 17 | +class SpeedController : public PIDOutput { |
| 18 | + public: |
| 19 | + virtual ~SpeedController() = default; |
| 20 | + |
| 21 | + /** |
| 22 | + * Common interface for setting the speed of a speed controller. |
| 23 | + * |
| 24 | + * @param speed The speed to set. Value should be between -1.0 and 1.0. |
| 25 | + */ |
| 26 | + virtual void Set(double speed) = 0; |
| 27 | + |
| 28 | + /** |
| 29 | + * Common interface for getting the current set speed of a speed controller. |
| 30 | + * |
| 31 | + * @return The current set speed. Value is between -1.0 and 1.0. |
| 32 | + */ |
| 33 | + virtual double Get() const = 0; |
| 34 | + |
| 35 | + /** |
| 36 | + * Common interface for inverting direction of a speed controller. |
| 37 | + * |
| 38 | + * @param isInverted The state of inversion, true is inverted. |
| 39 | + */ |
| 40 | + virtual void SetInverted(bool isInverted) = 0; |
| 41 | + |
| 42 | + /** |
| 43 | + * Common interface for returning the inversion state of a speed controller. |
| 44 | + * |
| 45 | + * @return isInverted The state of inversion, true is inverted. |
| 46 | + */ |
| 47 | + virtual bool GetInverted() const = 0; |
| 48 | + |
| 49 | + /** |
| 50 | + * Common interface for disabling a motor. |
| 51 | + */ |
| 52 | + virtual void Disable() = 0; |
| 53 | + |
| 54 | + /** |
| 55 | + * Common interface to stop the motor until Set is called again. |
| 56 | + */ |
| 57 | + virtual void StopMotor() = 0; |
| 58 | +}; |
| 59 | + |
| 60 | +} // namespace frc |
0 commit comments