00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file WheelTest_Whorl2.cpp 00003 * \brief Runs momentum wheels on Whorl-II. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.1 $ 00006 * \date $Date: 2005/09/18 17:14:30 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /*! 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 00013 #include <Actuators/MomentumWheel.h> 00014 #include <fstream> 00015 #include <utils/Time.h> 00016 #include <matrix/Matrix.h> 00017 00018 int main() 00019 { 00020 //Sample Program for new wheel initialization and 00021 // velocity reading procedures. 00022 //ifstream infile("OpenLoopInputs.txt", ios::in); 00023 //ofstream outfile("QuerySpeed.txt", ios::out); 00024 00025 // Create 3 momentum wheels 00026 MomentumWheel WheelX; 00027 MomentumWheel WheelY; 00028 MomentumWheel WheelZ; 00029 00030 //Set the communications port for each wheel 00031 // can be done manually or in a config file 00032 WheelX.SetPort("USB1"); 00033 WheelY.SetPort("USB2"); 00034 WheelZ.SetPort("USB3"); 00035 00036 // Each wheel needs to be initialized individually 00037 WheelX.Initialize(); 00038 WheelY.Initialize(); 00039 WheelZ.Initialize(); 00040 00041 // Run wheel.StartSpeedQuery() for every wheel you need to have speeds of. 00042 // The current configuration reads a speed every 0.75 sec, so the program 00043 // performs best if the threads created by StartSpeedQuery() are staggered 00044 // over that time. 00045 //WheelX.StartSpeedQuery(); 00046 usleep(250000); 00047 //WheelY.StartSpeedQuery(); 00048 usleep(250000); 00049 //WheelZ.StartSpeedQuery(); 00050 00051 // Run wheel.SetWheelSpeed(s) to set wheel to a speed of s (in rad/s) 00052 usleep(25000); 00053 WheelX.SetWheelSpeed(60); 00054 sleep(1); 00055 //WheelY.SetWheelSpeed(60); 00056 sleep(1); 00057 //WheelZ.SetWheelSpeed(60); 00058 sleep(10); 00059 00060 /* 00061 int brett = 0; 00062 double stampx; 00063 double stampy; 00064 double stampz; 00065 double speedx; 00066 double speedy; 00067 double speedz; 00068 double epoch = Now(); 00069 00070 cout << "# X-speed X-time Y-speed Y-time Z-speed Z-time\n"; 00071 00072 while(brett < 10) 00073 { 00074 usleep(1000000); 00075 tick(); 00076 00077 // To retrieve the most current speed of the wheel run wheel.GetWheelSpeed(speed, time) 00078 // where speed is set to the most recent wheel speed, and time is set to the timestamp 00079 // on that measurement. 00080 WheelX.GetWheelSpeed(speedx,stampx); 00081 WheelY.GetWheelSpeed(speedy,stampy); 00082 WheelZ.GetWheelSpeed(speedz,stampz); 00083 cout << brett << " " << speedx << " " << stampx-epoch << " "; 00084 cout << speedy << " " << stampy-epoch << " " << speedz << " " << stampz-epoch << " \n"; 00085 00086 brett++; 00087 } 00088 return 0; 00089 */ 00090 } 00091 00092 // Do not change the comments below - they will be added automatically by CVS 00093 /***************************************************************************** 00094 * $Log: WheelTest_Whorl2.cpp,v $ 00095 * Revision 1.1 2005/09/18 17:14:30 jayhawk_hokie 00096 * Initial Addition of Test programs 00097 * 00098 * Revision 1.1 2005/06/17 18:07:28 jayhawk_hokie 00099 * Initial submission. 00100 * 00101 * 00102 ******************************************************************************/ 00103 00104