00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file TiltSensor.cpp 00003 * \brief Implementation of the TiltSensor class 00004 * \author $Author: cakinli $ 00005 * \version $Revision: 1.2 $ 00006 * \date $Date: 2005/03/16 18:08:18 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /*! 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 00013 #include "TiltSensor.h" 00014 00015 ////////////////////////////////////////////////////////////////////// 00016 // Construction/Destruction 00017 ////////////////////////////////////////////////////////////////////// 00018 00019 TiltSensor::TiltSensor() 00020 { 00021 } 00022 00023 TiltSensor::TiltSensor(cfgBody& cfgdat) 00024 { 00025 const char *myCommands[20] = {"Location", "Rotation", "Port"}; 00026 /* "Location" - Sensor location 00027 * "Rotation" - Sensor to body quaternion 00028 * "Port" - String representing sensor com port */ 00029 Vector tmpVec1(3); 00030 Vector tmpVec2(4); 00031 for (int i = 0; cfgdat.keys[i][0]; i++) { 00032 switch(getCmdIndex(myCommands, cfgdat.keys[i])) { 00033 case 0: 00034 for (int j = 0; j < 3 && cfgdat.vals[i][j][0];j++) 00035 tmpVec1(j+1) = atof(cfgdat.vals[i][j]); 00036 m_Location = tmpVec1; 00037 break; 00038 00039 case 1: 00040 for (int j = 0; j < 4 && cfgdat.vals[i][j][0];j++) 00041 tmpVec2(j+1) = atof(cfgdat.vals[i][j]); 00042 m_Q = tmpVec2; 00043 00044 case 2: 00045 m_PhysicalTiltSensor.SetPort(string(cfgdat.vals[i][0])); 00046 break; 00047 00048 default: 00049 break; 00050 00051 } 00052 } 00053 } 00054 00055 TiltSensor::~TiltSensor() 00056 { 00057 } 00058 00059 int TiltSensor::Initialize() 00060 { 00061 return m_PhysicalTiltSensor.Initialize(); 00062 } 00063 00064 Vector TiltSensor::GetSensorToBodyQuaternion() 00065 { 00066 return m_Q; 00067 } 00068 00069 Vector TiltSensor::GetSensorLocation() 00070 { 00071 return m_Location; 00072 } 00073 00074 void TiltSensor::GetAngles(double& pitch, double& roll, double& t) 00075 { 00076 m_PhysicalTiltSensor.GetAngles(pitch,roll,t); 00077 } 00078 00079 int TiltSensor::GetFD() 00080 { 00081 return m_PhysicalTiltSensor.GetFD(); 00082 } 00083 00084 void TiltSensor::SetPort(string Port) 00085 { 00086 m_PhysicalTiltSensor.SetPort(Port); 00087 } 00088 00089 Measurement TiltSensor::GetMeasurement() 00090 { 00091 Measurement M; 00092 return M; 00093 }