Fawkes API  Fawkes Development Version
qa_evid100p.cpp
1 
2 /***************************************************************************
3  * qa_evid100p.cpp - QA for Sony EviD100P PTU
4  *
5  * Created: Mon Jun 22 11:12:43 2009
6  * Copyright 2005-2009 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 /// @cond QA
25 
26 #include "../sony/evid100p.h"
27 #include <utils/time/tracker.h>
28 
29 #include <cstdio>
30 #include <unistd.h>
31 
32 using namespace fawkes;
33 
34 int
35 main(int argc, char **argv)
36 {
37  SonyEviD100PVisca ptu("/dev/ttyUSB1", 100, false);
38 
39  for (int i = 0; i < 10; ++i) {
40  ptu.process();
41  usleep(100000);
42  }
43 
44  printf("Min pan: %f max pan: %f min tilt: %f max tilt: %f\n",
47 
48  float pan = 0, tilt = 0;
49  ptu.get_pan_tilt_rad(pan, tilt);
50  printf("Pan: %f, tilt: %f\n", pan, tilt);
51 
52  float panval = SonyEviD100PVisca::MIN_PAN_RAD;
53  float tiltval = SonyEviD100PVisca::MIN_TILT_RAD;
54 
55  float pan_smin, pan_smax, tilt_smin, tilt_smax;
56  ptu.get_speed_limits(pan_smin, pan_smax, tilt_smin, tilt_smax);
57 
58  ptu.set_speed_radsec(pan_smax, tilt_smax);
59  printf("Moving to %f, %f... ", panval, tiltval);
60  ptu.set_pan_tilt_rad(panval, tiltval);
61  while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
62  printf("."); fflush(stdout);
63  usleep(10000);
64  try {
65  ptu.process();
66  } catch (Exception &e) {}
67  }
68  printf("\n");
69 
70  sleep(1);
71 
72  ptu.set_speed_radsec(1.0, 0.8);
73 
74  panval *= -1; tiltval *= -1;
75  printf("Moving to %f, %f... ", panval, tiltval);
76  ptu.set_pan_tilt_rad(panval, tiltval);
77  while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
78  printf("."); fflush(stdout);
79  usleep(10000);
80  try {
81  ptu.process();
82  } catch (Exception &e) {
83  e.print_trace();
84  }
85  }
86 
87  /*
88  TimeTracker tt;
89  unsigned int ttc_full_pan = tt.add_class("Full pan");
90 
91  ptu.set_pan_tilt_rad(panval, tiltval);
92  while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
93  printf("."); fflush(stdout);
94  usleep(10000);
95  ptu.process();
96  }
97 
98  for (unsigned int s = SonyEviD100PVisca::MAX_TILT_SPEED; s > 0; --s) {
99  tt.reset();
100  ptu.set_pan_tilt_speed(SonyEviD100PVisca::MAX_PAN_SPEED, s);
101  for (unsigned int i = 0; i < 6; ++i) {
102  tiltval *= -1.0;
103  tt.ping_start(ttc_full_pan);
104  try {
105  ptu.set_pan_tilt_rad(panval, tiltval);
106  //printf("Waiting for setting of pan=%f tilt=0 to finish... ", panval);
107  fflush(stdout);
108  while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
109  //printf("."); fflush(stdout);
110  usleep(500);
111  ptu.process();
112  }
113  //printf("\n");
114  } catch (Exception &e) {
115  e.print_trace();
116  }
117  tt.ping_end(ttc_full_pan);
118  }
119  printf("Average panning time for speed %u\n", s);
120  tt.print_to_stdout();
121  }
122  ptu.get_pan_tilt_rad(pan, tilt);
123  printf("Pan: %f, tilt: %f\n", pan, tilt);
124  */
125 
126  return 0;
127 }
128 
129 /// @endcond
static const float MIN_TILT_RAD
Min tilt in rad.
Definition: evid100p.h:61
static const unsigned int NONBLOCKING_PANTILT
Non-blocking pan/tilt item.
Definition: visca.h:60
static const float MIN_PAN_RAD
Min pan in rad.
Definition: evid100p.h:59
static const float MAX_PAN_RAD
Max pan in rad.
Definition: evid100p.h:58
Fawkes library namespace.
Base class for exceptions in Fawkes.
Definition: exception.h:36
void print_trace()
Prints trace to stderr.
Definition: exception.cpp:619
static const float MAX_TILT_RAD
Max tilt in rad.
Definition: evid100p.h:60
Sony EviD100P Visca controller.
Definition: evid100p.h:32