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

sensorMonitor.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file sensorMonitor.cpp
00003 *  \brief Access measurements from accelerometer, gyros, and magnetometer. 
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.2 $
00006 *  \date    $Date: 2007/08/31 15:45:13 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*! 
00009 */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 #include <iostream>
00013 #include "Base/Whorl.h"
00014 #include "dsacssinterface.h"
00015 #include "rotation/Rotation.h"
00016 
00017 using namespace std;
00018 using namespace O_SESSAME;
00019 
00020 int main()
00021 {
00022         /* Specify Configuration Document */
00023         TiXmlDocument config("DSACSSConfig.xml");
00024         /* Load Configuration Document */
00025         bool loadOk = config.LoadFile();
00026         checkLoadFile(loadOk, "DSACSSConfig.xml", config);
00027         /* Create Configuation Handle */
00028         TiXmlHandle handle(&config);
00029 
00030         /* Create whorl object */
00031         Whorl whorl;
00032 
00033         /* Initialize Whorl Object */
00034         whorl.Initialize(handle);
00035         
00036         /* Create measurement Vectors */
00037         Vector accel(3);
00038         Vector rates(3); 
00039         Vector mag(3);  
00040 
00041         /* Endless loop */
00042         // Todo: Allow user to terminate program from key stroke. (not 'cntrl c') Perhaps multiple threads. 
00043         while(1)
00044         {
00045         sleep(2);
00046 
00047                 /* Get Accelerometer measurements [m/s^2] */
00048                 accel(1) = whorl.GetAccelerometer("ACC_X") -> GetMeasurement().GetAsDouble();
00049                 accel(2) = whorl.GetAccelerometer("ACC_Y") -> GetMeasurement().GetAsDouble();
00050                 accel(3) = whorl.GetAccelerometer("ACC_Z") -> GetMeasurement().GetAsDouble();
00051 
00052                 /* Get angular rate gyro measurements [rad/s] */
00053                 rates(1) = whorl.GetRateGyro("RATE_GYRO_X") -> GetMeasurement().GetAsDouble();
00054                 rates(2) = whorl.GetRateGyro("RATE_GYRO_Y") -> GetMeasurement().GetAsDouble();
00055                 rates(3) = whorl.GetRateGyro("RATE_GYRO_Z") -> GetMeasurement().GetAsDouble();
00056 
00057                 /* Get Magnetometer measurements [counts] */
00058                 mag = whorl.GetMagnetometer() -> GetVectorMeasurement();
00059 
00060                 /* Output Values to Screen */
00061                 cerr << "Acceleration: " << ~accel << endl;
00062                 cerr << "Angular Rates: " << ~rates << endl;
00063                 cerr << "Magnetometer reading: " << ~mag << endl;
00064 
00065                 /* Get angular rate gyro measurements [rad/s] */
00066                 rates(1) = whorl.GetRateGyro("RATE_GYRO_X") -> GetMeasurement().GetAsDouble();
00067                 rates(2) = whorl.GetRateGyro("RATE_GYRO_Y") -> GetMeasurement().GetAsDouble();
00068                 rates(3) = whorl.GetRateGyro("RATE_GYRO_Z") -> GetMeasurement().GetAsDouble();
00069                 cerr << "Angular Rates: " << ~rates << endl;
00070                 
00071                 /* Pause */
00072                 usleep(100000);
00073         }
00074         return( 0 );    
00075 }
00076 
00077 // Do not change the comments below - they will be added automatically by CVS
00078 /*****************************************************************************
00079 *       $Log: sensorMonitor.cpp,v $
00080 *       Revision 1.2  2007/08/31 15:45:13  jayhawk_hokie
00081 *       Updated
00082 *
00083 *       Revision 1.1  2007/07/24 09:57:42  jayhawk_hokie
00084 *       Initial Submission.
00085 *
00086 *       
00087 *
00088 ******************************************************************************/

Generated on Wed Sep 5 12:54:25 2007 for DSACSS Operational Code by  doxygen 1.3.9.1