Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Magnetometer Class Reference

#include <Magnetometer.h>

Inheritance diagram for Magnetometer:

Inheritance graph
[legend]
Collaboration diagram for Magnetometer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Magnetometer ()
 Default Constructor.
 Magnetometer (TiXmlHandle handle)
 Primary constructor.
virtual ~Magnetometer ()
 Deinitialize.
Measurement GetMeasurement ()
 Function to return scalar measurement (not currently used).
Vector GetRawVectorMeasurement ()
 Function to return magnetometer measurement in the form of a vector in the Sensor Frame.
Vector GetVectorMeasurement ()
 Function to return magnetometer measurement in the form of a vector in Body frame.
virtual int Initialize (const string &magfn)
 Magnetometer initialization function.
void AsciiParser ()
 Parse the ascii magnetometer string into x, y, z components. The magnetometer does not seem to always return the correct format. Recommend using binary parser.
void BinaryParser ()
 Binary parser- return string has the following format return = Xh | Xl | Yh | Yl | Zh | Zl | CR where h and l are high and low bytes respectively and CR is a carriage return. The high byte is a signed int, the low unsigned. output is parsed by converting each byte to integer, left shifting the high byte 8 times and adding the two together. The high byte is left shifted since the high and low byte comprise a single 16 bit integer and the first bit of the high byte must be multiplied by 2^8 instead of 2^0, and so on for the other bits The high byte is casted straight to an int, but for the low byte, the char must first be casted to unsigned char, then to int since that byte is unsigned.
void DefaultConfiguration ()
 Set Magnetometer to factory defaults.
void SetBaud19200Configuration ()
 Set Baud Rate to 19,200.
void PolledDataConfiguration ()
 Set Magnetometer to Polled data.
void ContinuousDataConfiguration ()
 Set Magnetometer to Continuous data.
void SetAsciiConfiguration ()
 Set to Ascii. Note: code not setup for Ascii parsing.
void SetBinaryConfiguration ()
void SetSampleRateConfiguration ()
 Set Sample Rate ( 10, 20 , 25, 30, 40, 50, 60, 100, 123, 154 ) Note: Check HMR2300 manual for Output Sample rate restrictions. Recommended < 60 sps.
void SetResetOnConfiguration ()
 Set/Reset ON.
void SetResetOffConfiguration ()
 Set/Reset Off.
void SetAveragingOnConfiguration ()
 Set Averaging On.
void SetAveragingOffConfiguration ()
 Set Averaging OFF.
void ReEnterOnConfiguration ()
 Re-Enter Response On.
void ReEnterOffConfiguration ()
 Re-Enter Response OFF.
void QuerryConfiguration ()
 Querry parameters.
bool IsActive ()
 Returns the current state of m_bActiveState.
Vector GetLocation () const
 Returns the physical location of the device with respect to whorl body coordinates.
void SetLocation (const Vector &newDeviceLocation)
 Specify the physical location of the device with respect to whorl body coordinates.

Static Public Attributes

const bool c_bNotActive = false
 a constant bool that is equal to false.
const bool c_bActive = true
 a constant bool that is equal to true.

Protected Member Functions

virtual int Initialize ()
 Initializes the device for use.
virtual int Deinitialize ()
 Deinitializes the device from further use.

Protected Attributes

char * name

Private Attributes

int m_magfd
 Member variable for magnetometer file descriptor.
Matrix m_Rmb
 Member variable for rotation matrix.
char * buffer
 Member variable for response from magnetometer.
char * magread
 Member variable for magnetometer counts.
Vector m_magCountsSensor
 Member variable for magnetometer counts in the Sensor Frame.
Vector m_magCountsBody
 Member variable for magnetometer counts in the Body Frame.
int m_sampleRate
 Member variable to specify sample rate. Not implemented yet.
double m_xOff
 x offset
double m_yOff
 y offset
double m_majorA
 Major axis.
double m_minorA
 Minor axis.
double m_phi
 Angle between x-axis and major axis.

Constructor & Destructor Documentation

Magnetometer::Magnetometer  ) 
 

Default Constructor.

Definition at line 22 of file Magnetometer.cpp.

Magnetometer::Magnetometer TiXmlHandle  handle  ) 
 

Primary constructor.

Parameters:
handle XML handle with current simulator as starting node

Definition at line 29 of file Magnetometer.cpp.

References _, buffer, checkResponse(), TiXmlHandle::Child(), O_SESSAME::Deg2Rad(), TiXmlHandle::Element(), TiXmlHandle::FirstChild(), Device::Initialize(), CAMdoubleMatrix::initialize(), CAMdoubleVector::initialize(), m_magCountsSensor, m_majorA, m_minorA, m_phi, m_Rmb, m_xOff, m_yOff, magread, and O_SESSAME::Vector.

Magnetometer::~Magnetometer  )  [virtual]
 

Deinitialize.

Definition at line 109 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().


Member Function Documentation

void Magnetometer::AsciiParser  ) 
 

Parse the ascii magnetometer string into x, y, z components. The magnetometer does not seem to always return the correct format. Recommend using binary parser.

Definition at line 357 of file Magnetometer.cpp.

References hear(), m_magCountsSensor, m_magfd, magread, and say().

void Magnetometer::BinaryParser  ) 
 

Binary parser- return string has the following format return = Xh | Xl | Yh | Yl | Zh | Zl | CR where h and l are high and low bytes respectively and CR is a carriage return. The high byte is a signed int, the low unsigned. output is parsed by converting each byte to integer, left shifting the high byte 8 times and adding the two together. The high byte is left shifted since the high and low byte comprise a single 16 bit integer and the first bit of the high byte must be multiplied by 2^8 instead of 2^0, and so on for the other bits The high byte is casted straight to an int, but for the low byte, the char must first be casted to unsigned char, then to int since that byte is unsigned.

Definition at line 411 of file Magnetometer.cpp.

References hear(), m_magCountsSensor, m_magfd, magread, and say().

Referenced by GetRawVectorMeasurement().

void Magnetometer::ContinuousDataConfiguration  ) 
 

Set Magnetometer to Continuous data.

Definition at line 217 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

void Magnetometer::DefaultConfiguration  ) 
 

Set Magnetometer to factory defaults.

Definition at line 178 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

int Device::Deinitialize  )  [protected, virtual, inherited]
 

Deinitializes the device from further use.

Author:
Andrew Turner
Date:
March 25, 1999 Prevents the device from being used. External Methods Called: SetActive(bool) Assumptions: None

Reimplemented in ControlMomentGyro, LinearActuator, MomentumWheel, PhysicalControlMomentGyro, and PhysicalMomentumWheel.

Definition at line 113 of file Device.cpp.

References Device::c_bNotActive, and Device::SetActive().

Referenced by Device::~Device(), Relay::~Relay(), and Thruster::~Thruster().

Vector Device::GetLocation  )  const [inherited]
 

Returns the physical location of the device with respect to whorl body coordinates.

Returns:
Physical center of the device [x,y,z]^T (meters).

Definition at line 75 of file Device.cpp.

References O_SESSAME::Vector.

Measurement Magnetometer::GetMeasurement  )  [virtual]
 

Function to return scalar measurement (not currently used).

Implements Sensor.

Definition at line 334 of file Magnetometer.cpp.

Vector Magnetometer::GetRawVectorMeasurement  ) 
 

Function to return magnetometer measurement in the form of a vector in the Sensor Frame.

Returns:
m_magCountsSensor vector containing magnetometer measurements in counts

Definition at line 344 of file Magnetometer.cpp.

References BinaryParser(), and O_SESSAME::Vector.

Referenced by GetVectorMeasurement().

Vector Magnetometer::GetVectorMeasurement  ) 
 

Function to return magnetometer measurement in the form of a vector in Body frame.

Returns:
m_magCountsBody vector containing magnetometer measurements in counts

Definition at line 433 of file Magnetometer.cpp.

References GetRawVectorMeasurement(), m_magCountsBody, m_minorA, m_phi, m_Rmb, and O_SESSAME::Vector.

Referenced by triadObserver::Run().

int Device::Initialize  )  [protected, virtual, inherited]
 

Initializes the device for use.

Author:
Andrew Turner
Date:
March 25, 1999 Allows the device to be used now that it is Active External Methods Called: SetActive(bool) Assumptions: None

Reimplemented in ControlMomentGyro, PhysicalControlMomentGyro, PhysicalMomentumWheel, Thruster, Actuator, Relay, DMUAccelerometer, DMURateGyro, PhysicalTiltSensor, and TiltSensor.

Definition at line 100 of file Device.cpp.

References Device::c_bActive, and Device::SetActive().

Referenced by Actuator::Initialize(), and Magnetometer().

int Magnetometer::Initialize const string &  magfn  )  [virtual]
 

Magnetometer initialization function.

Parameters:
magfn magnetometer port file name
mtob vector containing magnetometer to body 3-2-1 Euler Angles

Definition at line 132 of file Magnetometer.cpp.

References DefaultConfiguration(), init_serial(), m_magfd, PolledDataConfiguration(), QuerryConfiguration(), ReEnterOnConfiguration(), SetAveragingOnConfiguration(), SetBaud19200Configuration(), SetBinaryConfiguration(), SetResetOnConfiguration(), and SetSampleRateConfiguration().

bool Device::IsActive  )  [inherited]
 

Returns the current state of m_bActiveState.

Author:
Andrew Turner
Date:
March 25, 1999 This member function is used to inspect the state of the device External Methods Called: None Assumptions: None

Definition at line 59 of file Device.cpp.

Referenced by Device::Device().

void Magnetometer::PolledDataConfiguration  ) 
 

Set Magnetometer to Polled data.

Definition at line 207 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::QuerryConfiguration  ) 
 

Querry parameters.

Definition at line 324 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::ReEnterOffConfiguration  ) 
 

Re-Enter Response OFF.

Definition at line 313 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

void Magnetometer::ReEnterOnConfiguration  ) 
 

Re-Enter Response On.

Definition at line 302 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::SetAsciiConfiguration  ) 
 

Set to Ascii. Note: code not setup for Ascii parsing.

Definition at line 237 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

void Magnetometer::SetAveragingOffConfiguration  ) 
 

Set Averaging OFF.

Definition at line 291 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

void Magnetometer::SetAveragingOnConfiguration  ) 
 

Set Averaging On.

Definition at line 280 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::SetBaud19200Configuration  ) 
 

Set Baud Rate to 19,200.

Definition at line 193 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::SetBinaryConfiguration  ) 
 

Definition at line 225 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Device::SetLocation const Vector newDeviceLocation  )  [inherited]
 

Specify the physical location of the device with respect to whorl body coordinates.

Parameters:
newDeviceLocation Physical center of the device [x,y,z]^T (meters).

Definition at line 67 of file Device.cpp.

References Device::m_Location, and O_SESSAME::Vector.

void Magnetometer::SetResetOffConfiguration  ) 
 

Set/Reset Off.

Definition at line 269 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

void Magnetometer::SetResetOnConfiguration  ) 
 

Set/Reset ON.

Definition at line 258 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().

void Magnetometer::SetSampleRateConfiguration  ) 
 

Set Sample Rate ( 10, 20 , 25, 30, 40, 50, 60, 100, 123, 154 ) Note: Check HMR2300 manual for Output Sample rate restrictions. Recommended < 60 sps.

Definition at line 249 of file Magnetometer.cpp.

References buffer, hear(), m_magfd, and say().

Referenced by Initialize().


Member Data Documentation

char* Magnetometer::buffer [private]
 

Member variable for response from magnetometer.

Definition at line 89 of file Magnetometer.h.

Referenced by ContinuousDataConfiguration(), DefaultConfiguration(), Magnetometer(), PolledDataConfiguration(), QuerryConfiguration(), ReEnterOffConfiguration(), ReEnterOnConfiguration(), SetAsciiConfiguration(), SetAveragingOffConfiguration(), SetAveragingOnConfiguration(), SetBaud19200Configuration(), SetBinaryConfiguration(), SetResetOffConfiguration(), SetResetOnConfiguration(), SetSampleRateConfiguration(), and ~Magnetometer().

const bool Device::c_bActive = true [static, inherited]
 

a constant bool that is equal to true.

Used for setting the active state

Definition at line 50 of file Device.h.

Referenced by Device::Initialize().

const bool Device::c_bNotActive = false [static, inherited]
 

a constant bool that is equal to false.

Used for setting the active state.

Definition at line 48 of file Device.h.

Referenced by Device::Deinitialize(), and Device::Device().

Vector Magnetometer::m_magCountsBody [private]
 

Member variable for magnetometer counts in the Body Frame.

Definition at line 95 of file Magnetometer.h.

Referenced by GetVectorMeasurement().

Vector Magnetometer::m_magCountsSensor [private]
 

Member variable for magnetometer counts in the Sensor Frame.

Definition at line 93 of file Magnetometer.h.

Referenced by AsciiParser(), BinaryParser(), and Magnetometer().

int Magnetometer::m_magfd [private]
 

Member variable for magnetometer file descriptor.

Definition at line 85 of file Magnetometer.h.

Referenced by AsciiParser(), BinaryParser(), ContinuousDataConfiguration(), DefaultConfiguration(), Initialize(), PolledDataConfiguration(), QuerryConfiguration(), ReEnterOffConfiguration(), ReEnterOnConfiguration(), SetAsciiConfiguration(), SetAveragingOffConfiguration(), SetAveragingOnConfiguration(), SetBaud19200Configuration(), SetBinaryConfiguration(), SetResetOffConfiguration(), SetResetOnConfiguration(), SetSampleRateConfiguration(), and ~Magnetometer().

double Magnetometer::m_majorA [private]
 

Major axis.

Definition at line 103 of file Magnetometer.h.

Referenced by Magnetometer().

double Magnetometer::m_minorA [private]
 

Minor axis.

Definition at line 105 of file Magnetometer.h.

Referenced by GetVectorMeasurement(), and Magnetometer().

double Magnetometer::m_phi [private]
 

Angle between x-axis and major axis.

Definition at line 107 of file Magnetometer.h.

Referenced by GetVectorMeasurement(), and Magnetometer().

Matrix Magnetometer::m_Rmb [private]
 

Member variable for rotation matrix.

Definition at line 87 of file Magnetometer.h.

Referenced by GetVectorMeasurement(), and Magnetometer().

int Magnetometer::m_sampleRate [private]
 

Member variable to specify sample rate. Not implemented yet.

Definition at line 97 of file Magnetometer.h.

double Magnetometer::m_xOff [private]
 

x offset

Definition at line 99 of file Magnetometer.h.

Referenced by Magnetometer().

double Magnetometer::m_yOff [private]
 

y offset

Definition at line 101 of file Magnetometer.h.

Referenced by Magnetometer().

char* Magnetometer::magread [private]
 

Member variable for magnetometer counts.

Definition at line 91 of file Magnetometer.h.

Referenced by AsciiParser(), BinaryParser(), and Magnetometer().

char* Device::name [protected, inherited]
 

Definition at line 56 of file Device.h.


The documentation for this class was generated from the following files:
Generated on Wed Sep 5 12:54:40 2007 for DSACSS Operational Code by  doxygen 1.3.9.1