WPILibC++ 2024.3.2
NidecBrushless.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 <string>
8
9#include <wpi/deprecated.h>
12
13#include "frc/DigitalOutput.h"
14#include "frc/MotorSafety.h"
15#include "frc/PWM.h"
17
18namespace frc {
19
21
22/**
23 * Nidec Brushless Motor.
24 */
26 public MotorSafety,
27 public wpi::Sendable,
28 public wpi::SendableHelper<NidecBrushless> {
29 public:
30 /**
31 * Constructor.
32 *
33 * @param pwmChannel The PWM channel that the Nidec Brushless controller is
34 * attached to. 0-9 are on-board, 10-19 are on the MXP port.
35 * @param dioChannel The DIO channel that the Nidec Brushless controller is
36 * attached to. 0-9 are on-board, 10-25 are on the MXP port.
37 */
38 NidecBrushless(int pwmChannel, int dioChannel);
39
40 ~NidecBrushless() override = default;
41
44
45 // MotorController interface
46 /**
47 * Set the PWM value.
48 *
49 * The PWM value is set using a range of -1.0 to 1.0, appropriately scaling
50 * the value for the FPGA.
51 *
52 * @param speed The speed value between -1.0 and 1.0 to set.
53 */
54 void Set(double speed) override;
55
56 /**
57 * Get the recently set value of the PWM.
58 *
59 * @return The most recently set value for the PWM between -1.0 and 1.0.
60 */
61 double Get() const override;
62
63 void SetInverted(bool isInverted) override;
64
65 bool GetInverted() const override;
66
67 /**
68 * Disable the motor. The Enable() function must be called to re-enable the
69 * motor.
70 */
71 void Disable() override;
72
73 /**
74 * Re-enable the motor after Disable() has been called. The Set() function
75 * must be called to set a new motor speed.
76 */
77 void Enable();
78
79 // MotorSafety interface
80 void StopMotor() override;
81 std::string GetDescription() const override;
82
83 /**
84 * Gets the channel number associated with the object.
85 *
86 * @return The channel number.
87 */
88 int GetChannel() const;
89
90 // Sendable interface
91 void InitSendable(wpi::SendableBuilder& builder) override;
92
93 private:
94 bool m_isInverted = false;
95 bool m_disabled = false;
96 DigitalOutput m_dio;
97 PWM m_pwm;
98 double m_speed = 0.0;
99};
100
102
103} // namespace frc
Class to write to digital outputs.
Definition: DigitalOutput.h:25
Interface for motor controlling devices.
Definition: MotorController.h:14
The Motor Safety feature acts as a watchdog timer for an individual motor.
Definition: MotorSafety.h:25
Nidec Brushless Motor.
Definition: NidecBrushless.h:28
NidecBrushless(int pwmChannel, int dioChannel)
Constructor.
double Get() const override
Get the recently set value of the PWM.
void StopMotor() override
Called to stop the motor when the timeout expires.
NidecBrushless(NidecBrushless &&)=default
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
std::string GetDescription() const override
Returns a description to print when an error occurs.
void Enable()
Re-enable the motor after Disable() has been called.
int GetChannel() const
Gets the channel number associated with the object.
void Set(double speed) override
Set the PWM value.
bool GetInverted() const override
Common interface for returning the inversion state of a motor controller.
void Disable() override
Disable the motor.
~NidecBrushless() override=default
NidecBrushless & operator=(NidecBrushless &&)=default
void SetInverted(bool isInverted) override
Common interface for inverting direction of a motor controller.
Class implements the PWM generation in the FPGA.
Definition: PWM.h:26
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:19
Interface for Sendable objects.
Definition: Sendable.h:16
#define WPI_IGNORE_DEPRECATED
Definition: deprecated.h:20
#define WPI_UNIGNORE_DEPRECATED
Definition: deprecated.h:31
Definition: AprilTagPoseEstimator.h:15