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