WPILibC++ 2023.4.3
MotorControllerGroup.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 <functional>
8#include <vector>
9
12
14
15namespace frc {
16
17/**
18 * Allows multiple MotorController objects to be linked together.
19 */
21 public MotorController,
22 public wpi::SendableHelper<MotorControllerGroup> {
23 public:
24 template <class... MotorControllers>
25 explicit MotorControllerGroup(MotorController& motorController,
26 MotorControllers&... motorControllers);
28 std::vector<std::reference_wrapper<MotorController>>&& motorControllers);
29
32
33 void Set(double speed) override;
34 void SetVoltage(units::volt_t output) override;
35 double Get() const override;
36 void SetInverted(bool isInverted) override;
37 bool GetInverted() const override;
38 void Disable() override;
39 void StopMotor() override;
40
41 void InitSendable(wpi::SendableBuilder& builder) override;
42
43 private:
44 bool m_isInverted = false;
45 std::vector<std::reference_wrapper<MotorController>> m_motorControllers;
46
47 void Initialize();
48};
49
50} // namespace frc
51
Allows multiple MotorController objects to be linked together.
Definition: MotorControllerGroup.h:22
double Get() const override
Common interface for getting the current set speed of a motor controller.
void StopMotor() override
Common interface to stop the motor until Set is called again.
MotorControllerGroup & operator=(MotorControllerGroup &&)=default
void SetVoltage(units::volt_t output) override
Sets the voltage output of the MotorController.
MotorControllerGroup(MotorController &motorController, MotorControllers &... motorControllers)
Definition: MotorControllerGroup.inc:15
void Set(double speed) override
Common interface for setting the speed of a motor controller.
bool GetInverted() const override
Common interface for returning the inversion state of a motor controller.
MotorControllerGroup(MotorControllerGroup &&)=default
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
MotorControllerGroup(std::vector< std::reference_wrapper< MotorController > > &&motorControllers)
void SetInverted(bool isInverted) override
Common interface for inverting direction of a motor controller.
void Disable() override
Common interface for disabling a motor.
Interface for motor controlling devices.
Definition: MotorController.h:14
Definition: SendableBuilder.h:18
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Interface for Sendable objects.
Definition: Sendable.h:16
Definition: AprilTagFieldLayout.h:22