2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2019-11-01 12:32:40 -04:00
|
|
|
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
2016-01-02 03:02:34 -08:00
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
2013-12-15 18:30:16 -05:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2016-01-02 03:02:34 -08:00
|
|
|
|
2014-05-02 17:54:01 -04:00
|
|
|
#pragma once
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2019-11-01 12:32:40 -04:00
|
|
|
#include <units/units.h>
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/PIDOutput.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
namespace frc {
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Interface for speed controlling devices.
|
|
|
|
|
*/
|
2015-06-25 15:07:55 -04:00
|
|
|
class SpeedController : public PIDOutput {
|
|
|
|
|
public:
|
2015-06-24 01:06:29 -07:00
|
|
|
virtual ~SpeedController() = default;
|
2018-04-30 10:30:16 -07:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/**
|
|
|
|
|
* Common interface for setting the speed of a speed controller.
|
|
|
|
|
*
|
|
|
|
|
* @param speed The speed to set. Value should be between -1.0 and 1.0.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
virtual void Set(double speed) = 0;
|
2015-06-15 15:32:47 -04:00
|
|
|
|
2019-11-01 12:32:40 -04:00
|
|
|
/**
|
|
|
|
|
* Sets the voltage output of the SpeedController. Compensates for
|
|
|
|
|
* the current bus voltage to ensure that the desired voltage is output even
|
|
|
|
|
* if the battery voltage is below 12V - highly useful when the voltage
|
|
|
|
|
* outputs are "meaningful" (e.g. they come from a feedforward calculation).
|
|
|
|
|
*
|
|
|
|
|
* <p>NOTE: This function *must* be called regularly in order for voltage
|
|
|
|
|
* compensation to work properly - unlike the ordinary set function, it is not
|
|
|
|
|
* "set it and forget it."
|
|
|
|
|
*
|
|
|
|
|
* @param output The voltage to output.
|
|
|
|
|
*/
|
|
|
|
|
virtual void SetVoltage(units::volt_t output);
|
|
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/**
|
|
|
|
|
* Common interface for getting the current set speed of a speed controller.
|
|
|
|
|
*
|
|
|
|
|
* @return The current set speed. Value is between -1.0 and 1.0.
|
|
|
|
|
*/
|
2016-11-20 07:25:03 -08:00
|
|
|
virtual double Get() const = 0;
|
2015-06-15 15:32:47 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/**
|
2017-07-09 22:43:56 -04:00
|
|
|
* Common interface for inverting direction of a speed controller.
|
|
|
|
|
*
|
|
|
|
|
* @param isInverted The state of inversion, true is inverted.
|
2015-06-25 15:07:55 -04:00
|
|
|
*/
|
2017-07-09 22:43:56 -04:00
|
|
|
virtual void SetInverted(bool isInverted) = 0;
|
2015-06-15 15:32:47 -04:00
|
|
|
|
2015-06-25 15:07:55 -04:00
|
|
|
/**
|
|
|
|
|
* Common interface for returning the inversion state of a speed controller.
|
2017-07-09 22:43:56 -04:00
|
|
|
*
|
2015-06-25 15:07:55 -04:00
|
|
|
* @return isInverted The state of inversion, true is inverted.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool GetInverted() const = 0;
|
2016-02-10 14:00:06 -05:00
|
|
|
|
2017-07-09 22:43:56 -04:00
|
|
|
/**
|
|
|
|
|
* Common interface for disabling a motor.
|
|
|
|
|
*/
|
|
|
|
|
virtual void Disable() = 0;
|
|
|
|
|
|
2016-02-10 14:00:06 -05:00
|
|
|
/**
|
|
|
|
|
* Common interface to stop the motor until Set is called again.
|
|
|
|
|
*/
|
|
|
|
|
virtual void StopMotor() = 0;
|
2013-12-15 18:30:16 -05:00
|
|
|
};
|
2016-11-01 22:33:12 -07:00
|
|
|
|
|
|
|
|
} // namespace frc
|