LRAUV  revA
MassServo.h
Go to the documentation of this file.
1 
12 #ifndef MASSSERVO_H_
13 #define MASSSERVO_H_
14 
15 #include "EZServoServo.h"
16 #include "io/UartStream.h"
17 
19 
31 class MassServo : public EZServoServo
32 {
33 public:
34  MassServo( const Module* module );
35  virtual ~MassServo();
36 
37  virtual void run();
38 
41  virtual RunState start();
42 
44  virtual RunState starting();
45 
47  virtual RunState pause();
48 
50  virtual RunState paused();
51 
53  virtual RunState resume();
54 
56  virtual RunState resuming();
57 
59  virtual RunState runnable();
60 
62  virtual RunState resetting()
63  {
64  return stop();
65  }
66 
68  virtual RunState stop();
69 
70  virtual RunState stopping();
71 
73  virtual RunState stopped();
74 
75  // Shuts down motor controllers
76  void uninitialize( void );
77 
79  virtual ConfigURI getConfigURI( ConfigOption configOption ) const;
80 
81 private:
82 
83  // Note that the copy constructor below is private and not given a body.
84  // Any attempt to call it will return a compiler error.
85  MassServo( const MassServo& old ); // disallow copy constructor
86 
87  // Instance of load controller
89 
90  // The outputs themselves
92 
93  // The inputs
95 
96  // Configuration readers
97  ConfigReader* totalTksCfgReader_; // Total encoder ticks for full mass shift travel
98  ConfigReader* tksPerMMCfgReader_; // Number of ticks for one rotation (1 mm of travel)
99  ConfigReader* deviationDistanceCfgReader_; // Deviation allowed between expected and actual
101 
102  // returns true if data is requested from one of the readers
103  bool isDataRequested();
104 
105  // returns true if a new position has been commanded
106  bool isNeeded();
107 
108  typedef enum
109  {
110  INITIALIZE, // Program basic initialization into EEPROM
111  WAIT, // Wait for EEPROM write to finish
112  HOME, // Do any centering/homing, etc if needed
113  EXECUTE, // Execute any stored programs
114  VERIFY, // Confirm operable and no errors
115  DONE, // Ready to run
116  } StartupSequence;
117 
119 
120  // indicates whether things are ok to run
121  bool ok_;
122 
123  // Actual and commanded positions
126 
127  // Debugging outputs
128  bool debug_;
129 
130  // Timeouts
132 
133  //------------------- vehicle parameters --------------------------*/
134  // Mass Shift
135  float totalTksCfg_; // Total encoder ticks for full mass shift travel
136  float tksPerMMCfg_; // Number of ticks for 1 mm of travel //*** DEBUG real motor is ~ 272 ticks/mm
137  float deviationDistCfg_; // Number of encoder ticks deviation allowed between expected and actual
139 
140  //-----------------------------------------------------------------*/
141 
142  // Mass shift variables
143  float lastCmdMassPos_; // Stores the previous commanded position from control
144  float lastActMassPos_; // Stores the previous actual position of the mass shifter
145  bool massShiftHomed_; // True = mass shifter is done being initialized and homing
146 
147  // read vehicle config variables
148  virtual bool readConfig( void );
149 
150  // Initialization routines. Returns true if initialization completed without error
151  bool initMass( void );
152 
153  bool massRdy_;
154 
155  // Calls EZServoServo::checkResponse for status and sets errors as applicable.
156  // If error == OVERLOAD_ERROR, calls initMass().
157  bool checkResponse( bool checkForReady );
158 
159  // Waits for the mass to complete a transit
160  bool waitForHoming( void );
161 
162 };
163 
164 #endif /*MASSSERVO_H_*/
ConfigReader * totalTksCfgReader_
Definition: MassServo.h:97
LoadControl loadControl_
Definition: MassServo.h:88
Definition: MassServo.h:112
virtual RunState stopped()
Initial state – can be later followed by START.
Definition: MassServo.cpp:599
DataReader * massPositionReader_
Definition: MassServo.h:94
bool isNeeded()
Definition: MassServo.cpp:626
virtual RunState pause()
Pause for a short period (indicated by pauseTime)
Definition: MassServo.cpp:328
virtual RunState runnable()
Should eventually follow a START request or RESETTING.
Definition: MassServo.cpp:414
virtual void run()
The actual "payload" of the component.
Definition: MassServo.cpp:82
virtual bool readConfig(void)
Definition: MassServo.cpp:87
Definition: MassServo.h:114
UniversalDataWriter * massPositionWriter_
Definition: MassServo.h:91
Definition: MassServo.h:115
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: DataReader.h:30
bool isDataRequested()
Definition: MassServo.cpp:620
Definition: MassServo.h:111
float totalTksCfg_
Definition: MassServo.h:135
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: UniversalDataWriter.h:24
RunState
Definition: Component.h:115
virtual RunState paused()
Should eventually follow a PAUSE request: should set continueTime.
Definition: MassServo.cpp:344
virtual RunState start()
Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence.
Definition: MassServo.cpp:206
virtual RunState resume()
Resume from PAUSE.
Definition: MassServo.cpp:361
Contains the UartStream class declaration.
StartupSequence
Definition: MassServo.h:108
virtual RunState resetting()
Might occur in case of Error.
Definition: MassServo.h:62
Contains the EZServoServo class declaration.
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
virtual ConfigURI getConfigURI(ConfigOption configOption) const
Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc.
Definition: MassServo.cpp:153
bool checkResponse(bool checkForReady)
Definition: MassServo.cpp:191
Definition: ElementURI.h:166
virtual RunState stopping()
Might follow a STOP request.
Definition: MassServo.cpp:580
virtual RunState stop()
Initial state – can be later followed by START.
Definition: MassServo.cpp:569
float tksPerMMCfg_
Definition: MassServo.h:136
This is the device driver for the EZServo that controls the vehicle's movable mass.
Definition: MassServo.h:31
float lastActMassPos_
Definition: MassServo.h:144
Definition: MassServo.h:113
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
float deviationDistCfg_
Definition: MassServo.h:137
bool debug_
Definition: MassServo.h:128
float massDeadbandCfg_
Definition: MassServo.h:138
This class allows one to control loads on a load controller channel.
Definition: LoadControl.h:24
Definition: ConfigReader.h:13
StartupSequence startup_
Definition: MassServo.h:118
bool massRdy_
Definition: MassServo.h:153
virtual RunState starting()
Might follow a STOP...START sequence.
Definition: MassServo.cpp:239
MassServo(const Module *module)
Definition: MassServo.cpp:22
bool waitForHoming(void)
Definition: MassServo.cpp:103
float lastCmdMassPos_
Definition: MassServo.h:143
virtual RunState resuming()
Might follow a PAUSE...RESUME sequence.
Definition: MassServo.cpp:377
bool initMass(void)
Definition: MassServo.cpp:168
ConfigReader * massDeadbandCfgReader_
Definition: MassServo.h:100
bool ok_
Definition: MassServo.h:121
float cmdMassPosition_
Definition: MassServo.h:125
This is the parent class for device drivers that interface with EZServos Since all EZServos shares th...
Definition: EZServoServo.h:23
bool massShiftHomed_
Definition: MassServo.h:145
float actualMassPosition_
Definition: MassServo.h:124
ConfigOption
Definition: Component.h:456
ConfigReader * deviationDistanceCfgReader_
Definition: MassServo.h:99
virtual ~MassServo()
Definition: MassServo.cpp:79
ConfigReader * tksPerMMCfgReader_
Definition: MassServo.h:98
Timespan homingTimeout_
Definition: MassServo.h:131
void uninitialize(void)
Provide a space for uninitialization.
Definition: MassServo.cpp:135
Definition: MassServo.h:110