WPILibC++ 2023.4.3
MotorController.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <units/voltage.h>
8
9namespace frc {
10
11/**
12 * Interface for motor controlling devices.
13 */
15 public:
16 virtual ~MotorController() = default;
17
18 /**
19 * Common interface for setting the speed of a motor controller.
20 *
21 * @param speed The speed to set. Value should be between -1.0 and 1.0.
22 */
23 virtual void Set(double speed) = 0;
24
25 /**
26 * Sets the voltage output of the MotorController. Compensates for
27 * the current bus voltage to ensure that the desired voltage is output even
28 * if the battery voltage is below 12V - highly useful when the voltage
29 * outputs are "meaningful" (e.g. they come from a feedforward calculation).
30 *
31 * <p>NOTE: This function *must* be called regularly in order for voltage
32 * compensation to work properly - unlike the ordinary set function, it is not
33 * "set it and forget it."
34 *
35 * @param output The voltage to output.
36 */
37 virtual void SetVoltage(units::volt_t output);
38
39 /**
40 * Common interface for getting the current set speed of a motor controller.
41 *
42 * @return The current set speed. Value is between -1.0 and 1.0.
43 */
44 virtual double Get() const = 0;
45
46 /**
47 * Common interface for inverting direction of a motor controller.
48 *
49 * @param isInverted The state of inversion, true is inverted.
50 */
51 virtual void SetInverted(bool isInverted) = 0;
52
53 /**
54 * Common interface for returning the inversion state of a motor controller.
55 *
56 * @return isInverted The state of inversion, true is inverted.
57 */
58 virtual bool GetInverted() const = 0;
59
60 /**
61 * Common interface for disabling a motor.
62 */
63 virtual void Disable() = 0;
64
65 /**
66 * Common interface to stop the motor until Set is called again.
67 */
68 virtual void StopMotor() = 0;
69};
70
71} // namespace frc
Interface for motor controlling devices.
Definition: MotorController.h:14
virtual ~MotorController()=default
virtual void Set(double speed)=0
Common interface for setting the speed of a motor controller.
virtual void Disable()=0
Common interface for disabling a motor.
virtual void SetInverted(bool isInverted)=0
Common interface for inverting direction of a motor controller.
virtual void SetVoltage(units::volt_t output)
Sets the voltage output of the MotorController.
virtual void StopMotor()=0
Common interface to stop the motor until Set is called again.
virtual double Get() const =0
Common interface for getting the current set speed of a motor controller.
virtual bool GetInverted() const =0
Common interface for returning the inversion state of a motor controller.
Definition: AprilTagFieldLayout.h:22