WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
CANSpeedController.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2014-2017. 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 <stdint.h>
11 
12 #include "SpeedController.h"
13 
14 namespace frc {
15 
20  public:
21  enum ControlMode {
22  kPercentVbus = 0,
23  kCurrent = 1,
24  kSpeed = 2,
25  kPosition = 3,
26  kVoltage = 4,
27  kFollower = 5,
28  kMotionProfile = 6,
29  };
30 
31  // Helper function for the ControlMode enum
32  virtual bool IsModePID(ControlMode mode) const = 0;
33 
34  enum Faults {
35  kCurrentFault = 1,
36  kTemperatureFault = 2,
37  kBusVoltageFault = 4,
38  kGateDriverFault = 8,
39  /* SRX extensions */
40  kFwdLimitSwitch = 0x10,
41  kRevLimitSwitch = 0x20,
42  kFwdSoftLimit = 0x40,
43  kRevSoftLimit = 0x80,
44  };
45 
46  enum Limits { kForwardLimit = 1, kReverseLimit = 2 };
47 
48  enum NeutralMode {
56  };
57 
58  enum LimitMode {
63  /* SRX extensions */
66  };
67 
68  virtual double Get() const = 0;
69  virtual void Set(double value) = 0;
70  virtual void StopMotor() = 0;
71  virtual void Disable() = 0;
72  virtual void SetP(double p) = 0;
73  virtual void SetI(double i) = 0;
74  virtual void SetD(double d) = 0;
75  virtual void SetPID(double p, double i, double d) = 0;
76  virtual double GetP() const = 0;
77  virtual double GetI() const = 0;
78  virtual double GetD() const = 0;
79  virtual double GetBusVoltage() const = 0;
80  virtual double GetOutputVoltage() const = 0;
81  virtual double GetOutputCurrent() const = 0;
82  virtual double GetTemperature() const = 0;
83  virtual double GetPosition() const = 0;
84  virtual double GetSpeed() const = 0;
85  virtual bool GetForwardLimitOK() const = 0;
86  virtual bool GetReverseLimitOK() const = 0;
87  virtual uint16_t GetFaults() const = 0;
88  virtual void SetVoltageRampRate(double rampRate) = 0;
89  virtual int GetFirmwareVersion() const = 0;
90  virtual void ConfigNeutralMode(NeutralMode mode) = 0;
91  virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) = 0;
92  virtual void ConfigPotentiometerTurns(uint16_t turns) = 0;
93  virtual void ConfigSoftPositionLimits(double forwardLimitPosition,
94  double reverseLimitPosition) = 0;
95  virtual void DisableSoftPositionLimits() = 0;
96  virtual void ConfigLimitMode(LimitMode mode) = 0;
97  virtual void ConfigForwardLimit(double forwardLimitPosition) = 0;
98  virtual void ConfigReverseLimit(double reverseLimitPosition) = 0;
99  virtual void ConfigMaxOutputVoltage(double voltage) = 0;
100  virtual void ConfigFaultTime(double faultTime) = 0;
101  // Hold off on interface until we figure out ControlMode enums.
102  // virtual void SetControlMode(ControlMode mode) = 0;
103  // virtual ControlMode GetControlMode() const = 0;
104 };
105 
106 } // namespace frc
Interface for speed controlling devices.
Definition: SpeedController.h:17
NeutralMode
Definition: CANSpeedController.h:48
virtual void StopMotor()=0
Common interface to stop the motor until Set is called again.
virtual void Set(double value)=0
Common interface for setting the speed of a speed controller.
Use the NeutralMode that is set by the jumper wire on the CAN device.
Definition: CANSpeedController.h:50
Disable switches and disable soft limits.
Definition: CANSpeedController.h:65
Interface for "smart" CAN-based speed controllers.
Definition: CANSpeedController.h:19
virtual double Get() const =0
Common interface for getting the current set speed of a speed controller.
Do not attempt to stop the motor.
Definition: CANSpeedController.h:55
Use both switches and soft limits.
Definition: CANSpeedController.h:62
Only use switches for limits.
Definition: CANSpeedController.h:60
virtual void Disable()=0
Common interface for disabling a motor.
Stop the motor's rotation by applying a force.
Definition: CANSpeedController.h:52
LimitMode
Definition: CANSpeedController.h:58