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
28#include <utils/time/tracker.h>
29
30#include <cstdio>
31#include <unistd.h>
32
33using namespace fawkes;
34
35int
36main(int argc, char **argv)
37{
38 SonyEviD100PVisca ptu("/dev/ttyUSB1", 100, false);
39
40 for (int i = 0; i < 10; ++i) {
41 ptu.process();
42 usleep(100000);
43 }
44
45 printf("Min pan: %f max pan: %f min tilt: %f max tilt: %f\n",
50
51 float pan = 0, tilt = 0;
52 ptu.get_pan_tilt_rad(pan, tilt);
53 printf("Pan: %f, tilt: %f\n", pan, tilt);
54
55 float panval = SonyEviD100PVisca::MIN_PAN_RAD;
56 float tiltval = SonyEviD100PVisca::MIN_TILT_RAD;
57
58 float pan_smin, pan_smax, tilt_smin, tilt_smax;
59 ptu.get_speed_limits(pan_smin, pan_smax, tilt_smin, tilt_smax);
60
61 ptu.set_speed_radsec(pan_smax, tilt_smax);
62 printf("Moving to %f, %f... ", panval, tiltval);
63 ptu.set_pan_tilt_rad(panval, tiltval);
64 while (!ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
65 printf(".");
66 fflush(stdout);
67 usleep(10000);
68 try {
69 ptu.process();
70 } catch (Exception &e) {
71 }
72 }
73 printf("\n");
74
75 sleep(1);
76
77 ptu.set_speed_radsec(1.0, 0.8);
78
79 panval *= -1;
80 tiltval *= -1;
81 printf("Moving to %f, %f... ", panval, tiltval);
82 ptu.set_pan_tilt_rad(panval, tiltval);
83 while (!ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
84 printf(".");
85 fflush(stdout);
86 usleep(10000);
87 try {
88 ptu.process();
89 } catch (Exception &e) {
90 e.print_trace();
91 }
92 }
93
94 /*
95 TimeTracker tt;
96 unsigned int ttc_full_pan = tt.add_class("Full pan");
97
98 ptu.set_pan_tilt_rad(panval, tiltval);
99 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
100 printf("."); fflush(stdout);
101 usleep(10000);
102 ptu.process();
103 }
104
105 for (unsigned int s = SonyEviD100PVisca::MAX_TILT_SPEED; s > 0; --s) {
106 tt.reset();
107 ptu.set_pan_tilt_speed(SonyEviD100PVisca::MAX_PAN_SPEED, s);
108 for (unsigned int i = 0; i < 6; ++i) {
109 tiltval *= -1.0;
110 tt.ping_start(ttc_full_pan);
111 try {
112 ptu.set_pan_tilt_rad(panval, tiltval);
113 //printf("Waiting for setting of pan=%f tilt=0 to finish... ", panval);
114 fflush(stdout);
115 while (! ptu.is_nonblocking_finished(SonyEviD100PVisca::NONBLOCKING_PANTILT)) {
116 //printf("."); fflush(stdout);
117 usleep(500);
118 ptu.process();
119 }
120 //printf("\n");
121 } catch (Exception &e) {
122 e.print_trace();
123 }
124 tt.ping_end(ttc_full_pan);
125 }
126 printf("Average panning time for speed %u\n", s);
127 tt.print_to_stdout();
128 }
129 ptu.get_pan_tilt_rad(pan, tilt);
130 printf("Pan: %f, tilt: %f\n", pan, tilt);
131 */
132
133 return 0;
134}
135
136/// @endcond
Sony EviD100P Visca controller.
Definition: evid100p.h:33
static const float MIN_TILT_RAD
Min tilt in rad.
Definition: evid100p.h:61
static const float MAX_TILT_RAD
Max tilt in rad.
Definition: evid100p.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
static const unsigned int NONBLOCKING_PANTILT
Non-blocking pan/tilt item.
Definition: visca.h:60
Base class for exceptions in Fawkes.
Definition: exception.h:36
void print_trace() noexcept
Prints trace to stderr.
Definition: exception.cpp:601
Fawkes library namespace.