LRAUV  revA
ThrusterServo.h
Go to the documentation of this file.
1 
12 #ifndef THRUSTERSERVO_H_
13 #define THRUSTERSERVO_H_
14 
15 #include "EZServoServo.h"
16 #include "io/UartStream.h"
17 
19 
32 {
33 public:
34 
35  // Note that the copy constructor below is private and not given a body.
36  // Any attempt to call it will return a compiler error.
37  ThrusterServo( const ThrusterServo& old ); // disallow copy constructor
38 
39  ThrusterServo( const Module* module );
40  virtual ~ThrusterServo();
41 
42  virtual void run();
43 
46  virtual RunState start();
47 
49  virtual RunState starting();
50 
52  virtual RunState pause();
53 
55  virtual RunState paused();
56 
58  virtual RunState resume();
59 
61  virtual RunState resuming();
62 
64  virtual RunState runnable();
65 
67  virtual RunState resetting()
68  {
69  return stop();
70  }
71 
73  virtual RunState stop();
74 
75  virtual RunState stopping();
76 
78  virtual RunState stopped();
79 
80  // Shuts down motor controllers
81  void uninitialize( void );
82 
84  virtual ConfigURI getConfigURI( ConfigOption configOption ) const;
85 
86 private:
87 
88  // Instance of load controller
90 
91  // The outputs themselves
93 
94  // The inputs
96 
97  // Configuration readers
98  ConfigReader* encoderTksCfgReader_; // encoder tick/second multiplier
99  ConfigReader* tksPerRevCfgReader_; // encoder ticks/revolution as seen by the controller from HALL A&B
100  ConfigReader* deviationCfgReader_; // Number of encoder ticks deviation allowed between expected and actual
101  ConfigReader* allowableBadVelocityCfgReader_; // Allowable Number of bad velocity reads
102 
103 
104  // returns true if data is requested from one of the readers
105  bool isDataRequested();
106 
107  // returns true if a new position has been commanded
108  bool isNeeded();
109 
110  typedef enum
111  {
112  INITIALIZE, // Program basic initialization into EEPROM
113  WAIT, // Wait for EEPROM write to finish
114  HOME, // Do any centering/homing, etc if needed
115  EXECUTE, // Execute any stored programs
116  VERIFY, // Confirm operable and no errors
117  DONE, // Ready to run
118  } StartupSequence;
119 
121 
122  // indicates whether things are ok to run
123  bool ok_;
124 
125  // Debugging outputs
126  bool debug_;
127 
128  // Stores the commanded propeller rotational velocity
130 
131  // Stores the commanded motor velocity
133 
134  // Stores the commanded velocity
136 
137  //------------------- vehicle parameters --------------------------*/
138  // Thruster
139  float encoderTksCfg_; // encoder tick/second multiplier
140  float tksPerRevCfg_; // encoder ticks/revolution as seen by the controller from HALL A&B
141  float deviationCfg_; // Number of encoder ticks deviation allowed between expected and actual
142  int allowableBadVelocityCfg_; // Allowable Number of bad velocity reads
143 
144  //-----------------------------------------------------------------*/
145 
146  // Number of bad velocity reads
148 
149  // read vehicle config variables
150  bool readConfig( void );
151 
152  // the given motor controller is ready to receive commands
154 
155  // Current speed is within the bounds of what was commanded
157 
158  // Initialization routines. Returns true if initialization completed without error
159  bool initThruster( void );
160 
161  // Velocity good after the command has been issues and the thruster is run this long without fault
163 
164 };
165 
166 #endif /*THRUSTERSERVO_H_*/
virtual ConfigURI getConfigURI(ConfigOption configOption) const
Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc.
Definition: ThrusterServo.cpp:124
virtual RunState starting()
Might follow a STOP...START sequence.
Definition: ThrusterServo.cpp:214
Definition: ThrusterServo.h:112
int allowableBadVelocityCfg_
Definition: ThrusterServo.h:142
float encoderTksCfg_
Definition: ThrusterServo.h:139
bool ok_
Definition: ThrusterServo.h:123
virtual void run()
The actual "payload" of the component.
Definition: ThrusterServo.cpp:100
Definition: ThrusterServo.h:114
ConfigReader * encoderTksCfgReader_
Definition: ThrusterServo.h:98
virtual RunState stop()
Initial state – can be later followed by START.
Definition: ThrusterServo.cpp:507
float deviationCfg_
Definition: ThrusterServo.h:141
virtual RunState resuming()
Might follow a PAUSE...RESUME sequence.
Definition: ThrusterServo.cpp:340
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: DataReader.h:30
virtual RunState start()
Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence.
Definition: ThrusterServo.cpp:180
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: UniversalDataWriter.h:24
bool isNeeded()
Definition: ThrusterServo.cpp:565
float controllerVelocityCmd_
Definition: ThrusterServo.h:135
virtual RunState paused()
Should eventually follow a PAUSE request: should set continueTime.
Definition: ThrusterServo.cpp:308
RunState
Definition: Component.h:115
Contains the UartStream class declaration.
int badVelocityCount_
Definition: ThrusterServo.h:147
Contains the EZServoServo class declaration.
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
void uninitialize(void)
Provide a space for uninitialization.
Definition: ThrusterServo.cpp:105
LoadControl loadControl_
Definition: ThrusterServo.h:89
Timespan velocityTimeout_
Definition: ThrusterServo.h:162
ThrusterServo(const ThrusterServo &old)
bool debug_
Definition: ThrusterServo.h:126
Definition: ElementURI.h:166
Definition: ThrusterServo.h:117
This is the device driver for the EZServo that controls the vehicle's thruster.
Definition: ThrusterServo.h:31
float motorPosCmd_
Definition: ThrusterServo.h:132
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
bool thrustSpdGood_
Definition: ThrusterServo.h:156
ConfigReader * tksPerRevCfgReader_
Definition: ThrusterServo.h:99
Definition: ThrusterServo.h:113
UniversalDataWriter * propOmegaWriter_
Definition: ThrusterServo.h:92
This class allows one to control loads on a load controller channel.
Definition: LoadControl.h:24
float tksPerRevCfg_
Definition: ThrusterServo.h:140
virtual RunState runnable()
Should eventually follow a START request or RESETTING.
Definition: ThrusterServo.cpp:347
Definition: ConfigReader.h:13
virtual RunState stopping()
Might follow a STOP request.
Definition: ThrusterServo.cpp:518
bool readConfig(void)
Definition: ThrusterServo.cpp:84
StartupSequence startup_
Definition: ThrusterServo.h:120
Definition: ThrusterServo.h:115
virtual RunState stopped()
Initial state – can be later followed by START.
Definition: ThrusterServo.cpp:537
virtual ~ThrusterServo()
Definition: ThrusterServo.cpp:79
This is the parent class for device drivers that interface with EZServos Since all EZServos shares th...
Definition: EZServoServo.h:23
bool initThruster(void)
Definition: ThrusterServo.cpp:139
DataReader * propOmegaReader_
Definition: ThrusterServo.h:95
bool thrustRdy_
Definition: ThrusterServo.h:153
virtual RunState resetting()
Might occur in case of Error.
Definition: ThrusterServo.h:67
virtual RunState resume()
Resume from PAUSE.
Definition: ThrusterServo.cpp:319
ConfigOption
Definition: Component.h:456
ConfigReader * allowableBadVelocityCfgReader_
Definition: ThrusterServo.h:101
Definition: ThrusterServo.h:116
StartupSequence
Definition: ThrusterServo.h:110
virtual RunState pause()
Pause for a short period (indicated by pauseTime)
Definition: ThrusterServo.cpp:288
float cmdPropOmega_
Definition: ThrusterServo.h:129
bool isDataRequested()
Definition: ThrusterServo.cpp:559
ConfigReader * deviationCfgReader_
Definition: ThrusterServo.h:100