WPILibC++  2019.1.1-beta-2-21-gbea0565
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
NidecBrushless.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2018 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 <atomic>
11 
12 #include "frc/DigitalOutput.h"
13 #include "frc/ErrorBase.h"
14 #include "frc/MotorSafety.h"
15 #include "frc/PWM.h"
16 #include "frc/SpeedController.h"
17 #include "frc/smartdashboard/SendableBase.h"
18 
19 namespace frc {
20 
25  public SpeedController,
26  public MotorSafety {
27  public:
36  NidecBrushless(int pwmChannel, int dioChannel);
37 
38  ~NidecBrushless() override = default;
39 
40  NidecBrushless(NidecBrushless&&) = default;
41  NidecBrushless& operator=(NidecBrushless&&) = default;
42 
43  // SpeedController interface
52  void Set(double speed) override;
53 
59  double Get() const override;
60 
61  void SetInverted(bool isInverted) override;
62 
63  bool GetInverted() const override;
64 
69  void Disable() override;
70 
75  void Enable();
76 
77  // PIDOutput interface
83  void PIDWrite(double output) override;
84 
85  // MotorSafety interface
86  void StopMotor() override;
87  void GetDescription(wpi::raw_ostream& desc) const override;
88 
94  int GetChannel() const;
95 
96  // Sendable interface
97  void InitSendable(SendableBuilder& builder) override;
98 
99  private:
100  bool m_isInverted = false;
101  std::atomic_bool m_disabled{false};
102  DigitalOutput m_dio;
103  PWM m_pwm;
104  double m_speed = 0.0;
105 };
106 
107 } // namespace frc
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
int GetChannel() const
Gets the channel number associated with the object.
Interface for speed controlling devices.
Definition: SpeedController.h:17
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void Enable()
Re-enable the motor after Disable() has been called.
void SetInverted(bool isInverted) override
Common interface for inverting direction of a speed controller.
void Disable() override
Disable the motor.
void PIDWrite(double output) override
Write out the PID value as seen in the PIDOutput base object.
This base class runs a watchdog timer and calls the subclass's StopMotor() function if the timeout ex...
Definition: MotorSafety.h:24
bool GetInverted() const override
Common interface for returning the inversion state of a speed controller.
double Get() const override
Get the recently set value of the PWM.
void Set(double speed) override
Set the PWM value.
Nidec Brushless Motor.
Definition: NidecBrushless.h:24
Definition: SendableBase.h:19
Class to write to digital outputs.
Definition: DigitalOutput.h:24
Definition: SendableBuilder.h:23
Class implements the PWM generation in the FPGA.
Definition: PWM.h:37
NidecBrushless(int pwmChannel, int dioChannel)
Constructor.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.