WPILibC++ 2025.3.1
Loading...
Searching...
No Matches
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
10#include <wpi/deprecated.h>
13
15
17
18namespace frc {
19
20/**
21 * Allows multiple MotorController objects to be linked together.
22 */
23class [[deprecated(
24 "Use PWMMotorController::AddFollower() or if using CAN motor controllers,"
25 "use their method of following.")]] MotorControllerGroup
26 : public wpi::Sendable,
27 public MotorController,
28 public wpi::SendableHelper<MotorControllerGroup> {
29 public:
30 /**
31 * Create a new MotorControllerGroup with the provided MotorControllers.
32 *
33 * @tparam MotorControllers The MotorController types.
34 * @param motorController The first MotorController to add
35 * @param motorControllers The MotorControllers to add
36 */
37 template <class... MotorControllers>
38 explicit MotorControllerGroup(MotorController& motorController,
39 MotorControllers&... motorControllers)
40 : m_motorControllers(std::vector<std::reference_wrapper<MotorController>>{
41 motorController, motorControllers...}) {
42 Initialize();
43 }
44
45 /**
46 * Create a new MotorControllerGroup with the provided MotorControllers.
47 *
48 * @param motorControllers The MotorControllers to add.
49 */
51 std::vector<std::reference_wrapper<MotorController>>&& motorControllers);
52
55
56 void Set(double speed) override;
57 void SetVoltage(units::volt_t output) override;
58 double Get() const override;
59 void SetInverted(bool isInverted) override;
60 bool GetInverted() const override;
61 void Disable() override;
62 void StopMotor() override;
63
64 void InitSendable(wpi::SendableBuilder& builder) override;
65
66 private:
67 bool m_isInverted = false;
68 std::vector<std::reference_wrapper<MotorController>> m_motorControllers;
69
70 void Initialize();
71};
72
73} // namespace frc
74
Allows multiple MotorController objects to be linked together.
Definition MotorControllerGroup.h:28
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)
Create a new MotorControllerGroup with the provided MotorControllers.
Definition MotorControllerGroup.h:38
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)
Create a new MotorControllerGroup with the provided 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
Helper class for building Sendable dashboard representations.
Definition SendableBuilder.h:21
A helper class for use with objects that add themselves to SendableRegistry.
Definition SendableHelper.h:21
Interface for Sendable objects.
Definition Sendable.h:16
#define WPI_IGNORE_DEPRECATED
Definition deprecated.h:16
#define WPI_UNIGNORE_DEPRECATED
Definition deprecated.h:27
Definition CAN.h:11
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280