WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
MotorController.hpp
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 "wpi/units/voltage.hpp"
8
9namespace wpi {
10
11/**
12 * Interface for motor controlling devices.
13 */
15 public:
16 virtual ~MotorController() = default;
17
18 /**
19 * Sets the throttle of the motor controller.
20 *
21 * @param throttle The throttle where -1 indicates full reverse and 1
22 * indicates full forward.
23 */
24 virtual void SetThrottle(double throttle) = 0;
25
26 /**
27 * Sets the voltage output of the motor controller.
28 *
29 * Compensates for the current bus voltage to ensure that the desired voltage
30 * is output even if the battery voltage is below 12V - highly useful when the
31 * voltage outputs are "meaningful" (e.g. they come from a feedforward
32 * calculation).
33 *
34 * NOTE: This function *must* be called regularly in order for voltage
35 * compensation to work properly - unlike the ordinary set function, it is not
36 * "set it and forget it."
37 *
38 * @param voltage The voltage.
39 */
40 virtual void SetVoltage(wpi::units::volt_t voltage);
41
42 /**
43 * Gets the throttle of the motor controller.
44 *
45 * @return The throttle where -1 represents full reverse and 1 represents full
46 * forward.
47 */
48 virtual double GetThrottle() const = 0;
49
50 /**
51 * Sets the inversion state of the motor controller.
52 *
53 * @param isInverted The inversion state.
54 */
55 virtual void SetInverted(bool isInverted) = 0;
56
57 /**
58 * Gets the inversion state of the motor controller.
59 *
60 * @return The inversion state.
61 */
62 virtual bool GetInverted() const = 0;
63
64 /**
65 * Disables the motor controller.
66 */
67 virtual void Disable() = 0;
68};
69
70} // namespace wpi
Interface for motor controlling devices.
Definition MotorController.hpp:14
virtual void SetThrottle(double throttle)=0
Sets the throttle of the motor controller.
virtual ~MotorController()=default
virtual void Disable()=0
Disables the motor controller.
virtual bool GetInverted() const =0
Gets the inversion state of the motor controller.
virtual void SetVoltage(wpi::units::volt_t voltage)
Sets the voltage output of the motor controller.
virtual double GetThrottle() const =0
Gets the throttle of the motor controller.
virtual void SetInverted(bool isInverted)=0
Sets the inversion state of the motor controller.
Definition CvSource.hpp:15