00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 return 0;
00127 }
00128
00129