LRAUV  revA
PNI_TCM.h
Go to the documentation of this file.
1 
13 #ifndef PNI_TCM_H
14 #define PNI_TCM_H
15 
17 #include "io/LoadControl.h"
18 #include "io/UartStream.h"
19 #include "logger/Logger.h"
20 
23 
35 {
36 public:
37 
38  PNI_TCM( const Module* module );
39 
40  virtual ~PNI_TCM();
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  virtual void uninitialize();
81 
83  virtual ConfigURI getConfigURI( ConfigOption configOption ) const;
84 
85 private:
86 
87  // Note that the copy constructor below is private and not given a body.
88  // Any attempt to call it will return a compiler error.
89  PNI_TCM( const PNI_TCM& old ); // disallow copy constructor
90 
91  // scan configuraiton settings
92  void readConfig();
93 
95  static PNI_TCM* Instance_;
96 
97  // Slate inputs
101 
102  // Slate outputs
108 
114 
119 
120 // DEBUG : These need to be replaced by real frame IDs with a calculated CRC after EcoHAB spring is finished. For now they remain hard coded.
121  static const unsigned int CMD_SIZE = 24;
122  static const unsigned int DATA_RESP_SIZE = 41; // byte count (2), Frame ID (1), payload (36), CRC (2)
123  // Commands
129  static char setBigEndian_[CMD_SIZE];
134  static char setAcqParams_[CMD_SIZE];
135  static char save_[CMD_SIZE];
136 
137  static const float HEADING_LIMIT[];
138  static const float PITCH_LIMIT[];
139  static const float ROLL_LIMIT[];
140 
141  typedef enum
142  {
143  SETDATA, // Sets the data to be output from the device
144  MOUNTING, // Sets the mounting reference
145  ENDIAN, // Sets the endian
146  PARAMS, // Sets the aquisition parameters
148  DONE, // Ready to run
149  } StartupSequence;
150 
152 
153  // returns true if data is requested from one of the readers
154  bool isDataRequested();
155 
156  // Debugging outputs
157  bool debug_;
159 
160  // Instance of load controller
162 
164  float heading_, pitch_, roll_, magHeading_, trueHeading_; // TODO: make rotation matrix member variable
165  float mX_, mY_, mZ_; // TODO: make vector member variable
168 
174 
177  float rollOffset_;
178 
181 
184 
185  // Stores the current response from the modem
186  char deviceResponse_[96];
187 
188  // Holds the communications device
190 
191 
192  // getDataResp returning Heading (magnetic), Pitch, Roll, MagX, MagY, MagZ, Temperature. Values are float32
193  bool receiveGetDataResp( void );
194 
195  void processData( void );
196 
197  // Writes the data
198  void writeData( void );
199 
200  // Parses the calibration score which may take > 1 minute to be calculated.
201  bool parseCalScore( float &magScore, float &distError, float &tiltError, float &tiltRange );
202 
203  unsigned short CRC( const char* data, unsigned int len );
204 
205  // Flips endian and converts 4 bytes to floating point
206  float extractFloat( char * convertFloat );
207 
208  // Flips endian and converts 2 bytes to short
209  unsigned short extractShort( char * convertFloat );
210 
211  // Sets the writer's validity to valid or invalid
212  void setWritersInvalid( bool invalid );
213 
214  // Gets the magnetic variation
215  void getMagneticVariation();
216 
217 };
218 
219 #endif /*PNI_TCM_H*/
UniversalDataWriter * magneticHeadingWriter_
Definition: PNI_TCM.h:109
Contains a 3x3 array of double precision floating point numbers, along with methods for performing co...
Definition: Matrix3x3.h:27
Contains the SyncComponent class definition.
StartupSequence
Definition: PNI_TCM.h:141
virtual RunState runnable()
Should eventually follow a START request or RESETTING.
Definition: PNI_TCM.cpp:376
Contains the LoadControl class declaration.
UniversalDataReader * longitudeReader_
Definition: PNI_TCM.h:99
ConfigReader * magDeviationCfgReader_
Definition: PNI_TCM.h:116
A DataAccessor that reads values from the Slate Contains a default dataValue that must not be NULL...
Definition: UniversalDataReader.h:26
virtual void run()
The actual "payload" of the component.
Definition: PNI_TCM.cpp:144
virtual RunState resuming()
Might follow a PAUSE...RESUME sequence.
Definition: PNI_TCM.cpp:351
Abstract Base class for components that collect data for use later in the computation cycle...
Definition: SyncComponent.h:172
static char setConfigCalNumPts_[CMD_SIZE]
Definition: PNI_TCM.h:125
static char save_[CMD_SIZE]
Definition: PNI_TCM.h:135
static char setDataComponents_[CMD_SIZE]
Definition: PNI_TCM.h:130
int verbosity_
Definition: PNI_TCM.h:158
static char startContinuousMode_[CMD_SIZE]
Definition: PNI_TCM.h:132
float temperature_
Definition: PNI_TCM.h:166
void getMagneticVariation()
Definition: PNI_TCM.cpp:713
Definition: PNI_TCM.h:146
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: UniversalDataWriter.h:24
static char stopContinuousMode_[CMD_SIZE]
Definition: PNI_TCM.h:133
RunState
Definition: Component.h:115
static char setConfigBaudRate_[CMD_SIZE]
Definition: PNI_TCM.h:128
virtual RunState start()
Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence.
Definition: PNI_TCM.cpp:178
Contains the UartStream class declaration.
PNI_TCM(const Module *module)
Definition: PNI_TCM.cpp:79
virtual RunState stopping()
Might follow a STOP request.
Definition: PNI_TCM.cpp:443
unsigned short extractShort(char *convertFloat)
Definition: PNI_TCM.cpp:672
Timespan class, represents a delta of time.
Definition: Timestamp.h:248
Timespan validTimeout_
Definition: PNI_TCM.h:179
int readAccelerationsCfg_
Definition: PNI_TCM.h:182
unsigned short CRC(const char *data, unsigned int len)
Definition: PNI_TCM.cpp:639
void writeData(void)
Definition: PNI_TCM.cpp:606
float roll_
Definition: PNI_TCM.h:164
virtual RunState stopped()
Initial state – can be later followed by START.
Definition: PNI_TCM.cpp:464
Implements both InStream and OutStream for the LPC3XXX Standard UART.
Definition: UartStream.h:26
static char setBigEndian_[CMD_SIZE]
Definition: PNI_TCM.h:129
static const unsigned int DATA_RESP_SIZE
Definition: PNI_TCM.h:122
A DataAccessor that writes values to the Slate via its associated DataElement.
Definition: DataWriter.h:27
Definition: ElementURI.h:166
void readConfig()
Definition: PNI_TCM.cpp:149
LoadControl loadControl_
Definition: PNI_TCM.h:161
float pitchOffset_
Offset for mounting. In degrees.
Definition: PNI_TCM.h:176
static const unsigned int CMD_SIZE
Definition: PNI_TCM.h:121
float heading_
Definition: PNI_TCM.h:164
static char setConfigAutoCal_[CMD_SIZE]
Definition: PNI_TCM.h:124
UniversalDataWriter * rollWriter_
Definition: PNI_TCM.h:112
virtual ~PNI_TCM()
Definition: PNI_TCM.cpp:138
virtual RunState stop()
Initial state – can be later followed by START.
Definition: PNI_TCM.cpp:434
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
float pitch_
Definition: PNI_TCM.h:164
DataWriter * compassTemperatureWriter_
Definition: PNI_TCM.h:104
bool isDataRequested()
Definition: PNI_TCM.cpp:488
Timestamp startTime_
Definition: PNI_TCM.h:180
Definition: PNI_TCM.h:148
static const float PITCH_LIMIT[]
Definition: PNI_TCM.h:138
Definition: PNI_TCM.h:143
Definition: PNI_TCM.h:145
void setWritersInvalid(bool invalid)
Definition: PNI_TCM.cpp:699
virtual RunState resume()
Resume from PAUSE.
Definition: PNI_TCM.cpp:325
This class allows one to control loads on a load controller channel.
Definition: LoadControl.h:24
int readMagneticsCfg_
Definition: PNI_TCM.h:183
static char setConfigMountingRef_[CMD_SIZE]
Definition: PNI_TCM.h:127
static char setAcqParams_[CMD_SIZE]
Definition: PNI_TCM.h:134
Definition: UniversalDataWriter.h:55
Definition: ConfigReader.h:13
UartStream uart_
Definition: PNI_TCM.h:189
bool receiveGetDataResp(void)
Definition: PNI_TCM.cpp:521
bool debug_
Definition: PNI_TCM.h:157
UniversalDataWriter * trueHeadingWriter_
Definition: PNI_TCM.h:110
Timespan poTimeout_
Definition: PNI_TCM.h:179
Definition: PNI_TCM.h:144
bool parseCalScore(float &magScore, float &distError, float &tiltError, float &tiltRange)
Definition: PNI_TCM.cpp:628
virtual void uninitialize()
Provide a space for uninitialization.
Definition: PNI_TCM.cpp:158
Contains the Logger class definition.
char deviceResponse_[96]
Definition: PNI_TCM.h:186
float rollOffset_
Definition: PNI_TCM.h:177
Provides software interface to the PNI TCM compass.
Definition: PNI_TCM.h:34
static PNI_TCM * Instance_
Pointer to the singleton-like instance of this component.
Definition: PNI_TCM.h:95
UniversalDataReader * depthReader_
Definition: PNI_TCM.h:100
UniversalBlobWriter * rotationMatrixWriter_
Definition: PNI_TCM.h:113
ConfigReader * verbosityCfgReader_
Definition: PNI_TCM.h:115
virtual RunState starting()
Might follow a STOP...START sequence.
Definition: PNI_TCM.cpp:209
float trueHeading_
Definition: PNI_TCM.h:164
virtual RunState resetting()
Might occur in case of Error.
Definition: PNI_TCM.h:67
DataWriter * myWriter_
Definition: PNI_TCM.h:106
virtual RunState paused()
Should eventually follow a PAUSE request: should set continueTime.
Definition: PNI_TCM.cpp:314
float mZ_
Definition: PNI_TCM.h:165
void processData(void)
Definition: PNI_TCM.cpp:591
float extractFloat(char *convertFloat)
Definition: PNI_TCM.cpp:657
bool checksum_matches_
Definition: PNI_TCM.h:163
ConfigReader * pitchOffsetCfgReader_
Definition: PNI_TCM.h:117
virtual RunState pause()
Pause for a short period (indicated by pauseTime)
Definition: PNI_TCM.cpp:296
float magDeviation_
Deviation of this compass in the vehicle.
Definition: PNI_TCM.h:172
float mX_
Definition: PNI_TCM.h:165
static const float ROLL_LIMIT[]
Definition: PNI_TCM.h:139
StartupSequence startup_
Definition: PNI_TCM.h:151
static char startCalFullRange_[CMD_SIZE]
Definition: PNI_TCM.h:131
virtual ConfigURI getConfigURI(ConfigOption configOption) const
Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc.
Definition: PNI_TCM.cpp:685
ConfigOption
Definition: Component.h:456
UniversalDataReader * latitudeReader_
Definition: PNI_TCM.h:98
float mY_
Definition: PNI_TCM.h:165
DataWriter * mxWriter_
Definition: PNI_TCM.h:105
DataWriter * mzWriter_
Definition: PNI_TCM.h:107
DataWriter * compassHeadingWriter_
Definition: PNI_TCM.h:103
float magVariation_
Definition: PNI_TCM.h:173
Matrix3x3 rotationFromVehicleToNavigationFrame_
Definition: PNI_TCM.h:167
UniversalDataWriter * pitchWriter_
Definition: PNI_TCM.h:111
static const float HEADING_LIMIT[]
Definition: PNI_TCM.h:137
static char setConfigMagCoeff_[CMD_SIZE]
Definition: PNI_TCM.h:126
float magHeading_
Definition: PNI_TCM.h:164
Represents absolute times.
Definition: Timestamp.h:31
ConfigReader * rollOffsetCfgReader_
Definition: PNI_TCM.h:118
Definition: PNI_TCM.h:147