Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * qa_evid100p.cpp - QA for Sony EviD100P PTU 00004 * 00005 * Created: Mon Jun 22 11:12:43 2009 00006 * Copyright 2005-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 /// @cond QA 00025 00026 #include "../sony/evid100p.h" 00027 #include <utils/time/tracker.h> 00028 00029 #include <cstdio> 00030 #include <unistd.h> 00031 00032 using namespace fawkes; 00033 00034 int 00035 main(int argc, char **argv) 00036 { 00037 SonyEviD100PVisca ptu("/dev/ttyUSB1", 100, false); 00038 00039 for (int i = 0; i < 10; ++i) { 00040 ptu.process(); 00041 usleep(100000); 00042 } 00043 00044 printf("Min pan: %f max pan: %f min tilt: %f max tilt: %f\n", 00045 SonyEviD100PVisca::MIN_PAN_RAD, SonyEviD100PVisca::MAX_PAN_RAD, 00046 SonyEviD100PVisca::MIN_TILT_RAD, SonyEviD100PVisca::MAX_TILT_RAD); 00047 00048 float pan = 0, tilt = 0; 00049 ptu.get_pan_tilt_rad(pan, tilt); 00050 printf("Pan: %f, tilt: %f\n", pan, tilt); 00051 00052 float panval = SonyEviD100PVisca::MIN_PAN_RAD; 00053 float tiltval = SonyEviD100PVisca::MIN_TILT_RAD; 00054 00055 float pan_smin, pan_smax, tilt_smin, tilt_smax; 00056 ptu.get_speed_limits(pan_smin, pan_smax, tilt_smin, tilt_smax); 00057 00058 ptu.set_speed_radsec(pan_smax, tilt_smax); 00059 printf("Moving to %f, %f... ", panval, tiltval); 00060 ptu.set_pan_tilt_rad(panval, tiltval); 00061 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) { 00062 printf("."); fflush(stdout); 00063 usleep(10000); 00064 try { 00065 ptu.process(); 00066 } catch (Exception &e) {} 00067 } 00068 printf("\n"); 00069 00070 sleep(1); 00071 00072 ptu.set_speed_radsec(1.0, 0.8); 00073 00074 panval *= -1; tiltval *= -1; 00075 printf("Moving to %f, %f... ", panval, tiltval); 00076 ptu.set_pan_tilt_rad(panval, tiltval); 00077 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) { 00078 printf("."); fflush(stdout); 00079 usleep(10000); 00080 try { 00081 ptu.process(); 00082 } catch (Exception &e) { 00083 e.print_trace(); 00084 } 00085 } 00086 00087 /* 00088 TimeTracker tt; 00089 unsigned int ttc_full_pan = tt.add_class("Full pan"); 00090 00091 ptu.set_pan_tilt_rad(panval, tiltval); 00092 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) { 00093 printf("."); fflush(stdout); 00094 usleep(10000); 00095 ptu.process(); 00096 } 00097 00098 for (unsigned int s = SonyEviD100PVisca::MAX_TILT_SPEED; s > 0; --s) { 00099 tt.reset(); 00100 ptu.set_pan_tilt_speed(SonyEviD100PVisca::MAX_PAN_SPEED, s); 00101 for (unsigned int i = 0; i < 6; ++i) { 00102 tiltval *= -1.0; 00103 tt.ping_start(ttc_full_pan); 00104 try { 00105 ptu.set_pan_tilt_rad(panval, tiltval); 00106 //printf("Waiting for setting of pan=%f tilt=0 to finish... ", panval); 00107 fflush(stdout); 00108 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) { 00109 //printf("."); fflush(stdout); 00110 usleep(500); 00111 ptu.process(); 00112 } 00113 //printf("\n"); 00114 } catch (Exception &e) { 00115 e.print_trace(); 00116 } 00117 tt.ping_end(ttc_full_pan); 00118 } 00119 printf("Average panning time for speed %u\n", s); 00120 tt.print_to_stdout(); 00121 } 00122 ptu.get_pan_tilt_rad(pan, tilt); 00123 printf("Pan: %f, tilt: %f\n", pan, tilt); 00124 */ 00125 00126 return 0; 00127 } 00128 00129 /// @endcond