WPILibC++  2020.3.2
NidecBrushless.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "frc/DigitalOutput.h"
11 #include "frc/ErrorBase.h"
12 #include "frc/MotorSafety.h"
13 #include "frc/PWM.h"
14 #include "frc/SpeedController.h"
15 #include "frc/smartdashboard/Sendable.h"
16 #include "frc/smartdashboard/SendableHelper.h"
17 
18 namespace frc {
19 
20 class SendableBuilder;
21 
26  public MotorSafety,
27  public Sendable,
28  public SendableHelper<NidecBrushless> {
29  public:
38  NidecBrushless(int pwmChannel, int dioChannel);
39 
40  ~NidecBrushless() override = default;
41 
42  NidecBrushless(NidecBrushless&&) = default;
43  NidecBrushless& operator=(NidecBrushless&&) = default;
44 
45  // SpeedController interface
54  void Set(double speed) override;
55 
61  double Get() const override;
62 
63  void SetInverted(bool isInverted) override;
64 
65  bool GetInverted() const override;
66 
71  void Disable() override;
72 
77  void Enable();
78 
79  // PIDOutput interface
85  void PIDWrite(double output) override;
86 
87  // MotorSafety interface
88  void StopMotor() override;
89  void GetDescription(wpi::raw_ostream& desc) const override;
90 
96  int GetChannel() const;
97 
98  // Sendable interface
99  void InitSendable(SendableBuilder& builder) override;
100 
101  private:
102  bool m_isInverted = false;
103  bool m_disabled = false;
104  DigitalOutput m_dio;
105  PWM m_pwm;
106  double m_speed = 0.0;
107 };
108 
109 } // namespace frc
frc::PWM
Class implements the PWM generation in the FPGA.
Definition: PWM.h:40
frc::NidecBrushless::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::DigitalOutput
Class to write to digital outputs.
Definition: DigitalOutput.h:27
frc::MotorSafety
This base class runs a watchdog timer and calls the subclass's StopMotor() function if the timeout ex...
Definition: MotorSafety.h:24
frc::NidecBrushless::Enable
void Enable()
Re-enable the motor after Disable() has been called.
frc::NidecBrushless::SetInverted
void SetInverted(bool isInverted) override
Common interface for inverting direction of a speed controller.
frc::NidecBrushless::GetChannel
int GetChannel() const
Gets the channel number associated with the object.
frc::NidecBrushless::PIDWrite
void PIDWrite(double output) override
Write out the PID value as seen in the PIDOutput base object.
frc::NidecBrushless::GetInverted
bool GetInverted() const override
Common interface for returning the inversion state of a speed controller.
frc::NidecBrushless
Nidec Brushless Motor.
Definition: NidecBrushless.h:25
frc::NidecBrushless::Get
double Get() const override
Get the recently set value of the PWM.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::NidecBrushless::Set
void Set(double speed) override
Set the PWM value.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::SpeedController
Interface for speed controlling devices.
Definition: SpeedController.h:19
wpi::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:47
frc::NidecBrushless::NidecBrushless
NidecBrushless(int pwmChannel, int dioChannel)
Constructor.
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23
frc::NidecBrushless::Disable
void Disable() override
Disable the motor.