LRAUV  revA
EZServoServo.h
Go to the documentation of this file.
1 
9 #ifndef EZSERVOSERVO_H_
10 #define EZSERVOSERVO_H_
11 
13 #include "io/LoadControl.h"
14 #include "io/UartStream.h"
15 
24 {
25 public:
26  // EZServo Servos
27  typedef enum
28  {
36 
37  EZServoServo( const Str& name, const ConfigURI& uartCfg, const ConfigURI& baudCfg,
38  const Module* module, EZServoServoType motorServoType,
39  int divisor = 1, int modulo = 0 );
40  virtual ~EZServoServo();
41 
42 protected:
43 
44  // Serial port
46 
47  // Call at start of initialize
48  void initializeStart( void );
49 
50  // Call at start of uninitialize
51  void uninitializeStart( void );
52 
53  // Call at end of uninitialize
54  void uninitializeEnd();
55 
58 
59  // The error set returned by the EZ Servo
60  typedef enum
61  {
62  NO_ERROR = 0x0,
63  INIT_ERROR = 0x1,
66  COMM_ERROR = 0x5,
71  } EZServoError;
72 
73  // Most recent ez servo error;
75 
76  // Timeouts
79 
80  char uartResponse_[30];
81 
82  // The status bitmask
83  static const int RECEIVE_READY = 0x2; // Note: bit 6 is always set. Ready bit is bit 5.
84 
85  // returns absolute position of motor. Checks position against low/high limits
86  float getPosition();
87 
88  // Returns nan if there is no/invalid response.
89  // Otherwise returns the value from the command
90  // send to the EZ Servo
91  float isCommunicating( char *cmd );
92 
93  // returns the current encoder position
94  float getVelocityCmd();
95 
96  // Verify that motor controller position is within physical limits
97  bool checkPosition( float position );
98 
99  // Looks at EZServo status and sets errors as applicable.
100  // If checkForReady is true, returns true if controller is reporting
101  // ready and false if not.
102  virtual bool checkResponse( bool checkForReady );
103 
104  // Limits the value to the range limtLo_+1 to limitHi_-1
105  float limit( float value );
106 
107  // Reads configuration settings
108  virtual bool readConfig();
109 
110  // Configuration settings
111  float powerOnTimeoutCfg_; // Time to allow system to power up before commanding
112  float powerOffTimeoutCfg_; // Time to allow system to fully power down before restarting
113  float currLimitCfg_; // Percent of current allowed
114  float limitHiCfg_; // High physical limit for motor controller
115  float limitLoCfg_; // Low physical limit for motor controller
116  float pidWCfg_; // Proportional gain
117  float pidXCfg_; // Integral gain
118  float pidYCfg_; // Differential gain
119  float overloadTimeoutCfg_; // Timeout to wait before throwing overload error
120  float accelCfg_; // Encoder ticks / 32.768 per second squared
121  float velocityCfg_; // Encoder ticks / 32.768 per second
123  float countsPerDegCfg_; //motor "ticks" per degree of control surface motion
124  float mtrCenterCfg_; // 0 degrees "centered" control surface
125  float deviationAngleCfg_; // Number of degrees deviation allowed between expected and actual
126 
128  ConfigReader* powerOnTimeoutCfgReader_; // Time to allow system to power up before commanding
129  ConfigReader* powerOffTimeoutCfgReader_; // Time to allow system to fully power down before restarting
130  ConfigReader* currLimitCfgReader_; // Percent of current allowed
131 
132  // Config settings shared by all except Thruster:
133  ConfigReader* limitHiCfgReader_; // High physical limit for motor controller
134  ConfigReader* limitLoCfgReader_; // Low physical limit for motor controller
135 
136  // Config settings shared by all except Mass:
137  ConfigReader* pidWCfgReader_; // Proportional gain
138  ConfigReader* pidXCfgReader_; // Integral gain
139  ConfigReader* pidYCfgReader_; // Differential gain
140 
141  // Config settings shared by all except Elevator + Rudder:
142  ConfigReader* overloadTimeoutCfgReader_; // Timeout to wait before throwing overload error
143  ConfigReader* accelCfgReader_; // Encoder ticks / 32.768 per second squared
144 
145  // Config settings shared by Mass + Buoyancy:
146  ConfigReader* velocityCfgReader_; // Encoder ticks / 32.768 per second
147 
148  // Config settings shared by Elevator + Rudder:
150  ConfigReader* countsPerDegCfgReader_; //motor "ticks" per degree of control surface motion
151  ConfigReader* mtrCenterCfgReader_; // 0 degrees "centered" control surface
152  ConfigReader* deviationAngleCfgReader_; // Number of degrees deviation allowed between expected and actual
153 
154 private:
155  // Note that the copy constructor below is private and not given a body.
156  // Any attempt to call it will return a compiler error.
157  EZServoServo( const EZServoServo& old ); // disallow copy constructor
158 
159 };
160 
161 #endif /*EZSERVOSERVO_H_*/
ConfigReader * velocityCfgReader_
Definition: EZServoServo.h:146
Contains the SyncComponent class definition.
ConfigReader * pidXCfgReader_
Definition: EZServoServo.h:138
ConfigReader * powerOffTimeoutCfgReader_
Definition: EZServoServo.h:129
float countsPerDegCfg_
Definition: EZServoServo.h:123
Contains the LoadControl class declaration.
float getPosition()
Definition: EZServoServo.cpp:89
float isCommunicating(char *cmd)
Definition: EZServoServo.cpp:128
ConfigReader * currLimitCfgReader_
Definition: EZServoServo.h:130
float velocityCfg_
Definition: EZServoServo.h:121
void uninitializeEnd()
Definition: EZServoServo.cpp:86
void uninitializeStart(void)
Definition: EZServoServo.cpp:83
Definition: EZServoServo.h:31
bool checkPosition(float position)
Definition: EZServoServo.cpp:191
ConfigReader * pidWCfgReader_
Definition: EZServoServo.h:137
Definition: EZServoServo.h:65
ConfigReader * pidYCfgReader_
Definition: EZServoServo.h:139
ConfigReader * accelCfgReader_
Definition: EZServoServo.h:143
float overloadTimeoutCfg_
Definition: EZServoServo.h:119
EZServoServoType motorServoType_
Definition: EZServoServo.h:57
ConfigReader * overloadTimeoutCfgReader_
Definition: EZServoServo.h:142
Definition: EZServoServo.h:67
char uartResponse_[30]
Definition: EZServoServo.h:80
Definition: EZServoServo.h:62
virtual bool checkResponse(bool checkForReady)
Definition: EZServoServo.cpp:251
Contains the UartStream class declaration.
int controlAddress_
Definition: EZServoServo.h:56
float powerOffTimeoutCfg_
Definition: EZServoServo.h:112
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Timestamp startTime_
Definition: EZServoServo.h:78
Definition: EZServoServo.h:34
ConfigReader * offsetAngleCfgReader_
Definition: EZServoServo.h:149
float powerOnTimeoutCfg_
Definition: EZServoServo.h:111
EZServoServo(const Str &name, const ConfigURI &uartCfg, const ConfigURI &baudCfg, const Module *module, EZServoServoType motorServoType, int divisor=1, int modulo=0)
Definition: EZServoServo.cpp:20
Definition: EZServoServo.h:70
float limitHiCfg_
Definition: EZServoServo.h:114
Implements both InStream and OutStream for the LPC3XXX Standard UART.
Definition: UartStream.h:26
float pidWCfg_
Definition: EZServoServo.h:116
float pidYCfg_
Definition: EZServoServo.h:118
Definition: ElementURI.h:166
EZServoError ezServoError_
Definition: EZServoServo.h:74
static const int RECEIVE_READY
Definition: EZServoServo.h:83
float offsetAngleCfg_
Definition: EZServoServo.h:122
ConfigReader * powerOnTimeoutCfgReader_
Config settings shared by all Servos:
Definition: EZServoServo.h:128
ConfigReader * mtrCenterCfgReader_
Definition: EZServoServo.h:151
float pidXCfg_
Definition: EZServoServo.h:117
Definition: EZServoServo.h:69
float getVelocityCmd()
Definition: EZServoServo.cpp:158
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
ConfigReader * countsPerDegCfgReader_
Definition: EZServoServo.h:150
Definition: EZServoServo.h:33
UartStream uart_
Definition: EZServoServo.h:45
ConfigReader * limitHiCfgReader_
Definition: EZServoServo.h:133
Replacement for standard template class string.
Definition: Str.h:12
EZServoError
Definition: EZServoServo.h:60
float deviationAngleCfg_
Definition: EZServoServo.h:125
virtual ~EZServoServo()
Definition: EZServoServo.cpp:67
Definition: EZServoServo.h:32
Definition: ConfigReader.h:13
float limit(float value)
Definition: EZServoServo.cpp:349
Definition: EZServoServo.h:63
float limitLoCfg_
Definition: EZServoServo.h:115
ConfigReader * deviationAngleCfgReader_
Definition: EZServoServo.h:152
float currLimitCfg_
Definition: EZServoServo.h:113
Definition: EZServoServo.h:29
Definition: EZServoServo.h:68
virtual bool readConfig()
Definition: EZServoServo.cpp:355
Abstract Base class for components that run towards the end of the computation cycle, communicating with controllers.
Definition: SyncComponent.h:252
This is the parent class for device drivers that interface with EZServos Since all EZServos shares th...
Definition: EZServoServo.h:23
ConfigReader * limitLoCfgReader_
Definition: EZServoServo.h:134
Definition: EZServoServo.h:30
float accelCfg_
Definition: EZServoServo.h:120
Definition: EZServoServo.h:66
Definition: EZServoServo.h:64
Timespan eepromWriteTimeout_
Definition: EZServoServo.h:77
float mtrCenterCfg_
Definition: EZServoServo.h:124
Represents absolute times.
Definition: Timestamp.h:31
void initializeStart(void)
Definition: EZServoServo.cpp:69
EZServoServoType
Definition: EZServoServo.h:27