WPILibC++ 2027.0.0-alpha-4
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 duty cycle of the motor controller.
20 *
21 * @param dutyCycle The duty cycle between -1 and 1 (sign indicates
22 * direction).
23 */
24 virtual void SetDutyCycle(double dutyCycle) = 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 duty cycle of the motor controller.
44 *
45 * @return The duty cycle between -1 and 1 (sign indicates direction).
46 */
47 virtual double GetDutyCycle() const = 0;
48
49 /**
50 * Sets the inversion state of the motor controller.
51 *
52 * @param isInverted The inversion state.
53 */
54 virtual void SetInverted(bool isInverted) = 0;
55
56 /**
57 * Gets the inversion state of the motor controller.
58 *
59 * @return The inversion state.
60 */
61 virtual bool GetInverted() const = 0;
62
63 /**
64 * Disables the motor controller.
65 */
66 virtual void Disable() = 0;
67};
68
69} // namespace wpi
Interface for motor controlling devices.
Definition MotorController.hpp:14
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 GetDutyCycle() const =0
Gets the duty cycle of the motor controller.
virtual void SetDutyCycle(double dutyCycle)=0
Sets the duty cycle of the motor controller.
virtual void SetInverted(bool isInverted)=0
Sets the inversion state of the motor controller.
Definition CvSource.hpp:15