Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExamplePanTiltManualControl.cpp
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 /** @example ExamplePanTiltManualControl.cpp
26  @relates DPPanTiltControl
27  @ingroup g_examples
28  @brief This is an example for steering the PTU manually.
29  Use w, s, a, d to steer camera, <space> or q to exit.
30  @author MIP
31 */
32 
33 #include <Base/Common/BIASpragma.hh>
34 #include <PanTilt/DPPanTiltControl.hh>
35 #ifdef WIN32
36 #include <conio.h>
37 #else // WIN32
38 #include <ncurses.h>
39 #endif // WIN32
40 #include <PanTilt/PanTiltControlInterface.hh>
41 #include <PanTilt/PanTiltManualControl.hh>
42 #include <PanTilt/PanTiltAutoControl.hh>
43 
44 using namespace std;
45 using namespace BIAS;
46 
47 int main (int argc, char *argv[]){
48 
49 
50 #ifndef WIN32
51  initscr();
52  keypad(stdscr, true);
53  noecho();
54  cbreak();
55  mvprintw(0,0,"PanTilt Manual Control");
56  mvprintw(2,0,"Use w, s, a, d to steer camera, <space> or q to exit.");
57 #endif // WIN32
58 
59  // create a new factory...
61  cf = new PanTiltManualControlFactory();
62  // ... which should build automatic controls
63  // cf = new PanTiltAutoControlFactory();
64  // factory should produce such control
65  string device;
66 #ifdef WIN32
67  device = "COM1";
68 #else
69  device = "/dev/ttyUSB0";
70 #endif
71 
72  PanTiltControlInterface *control = cf->Create(device, false);
73  // start up the produced control
74  control->StartControl();
75 
76  bool loop = true;
77 
78  while (loop) {
79  char c = getch();
80  switch(c) {
81  case 'e':
82  control->StopControl();
83  break;
84  case 'r':
85  control->ResumeControl();
86  break;
87  case 'q':
88  control->StopControl();
89  loop = false;
90  break;
91  }
92  }
93 
94 #ifndef WIN32
95  endwin();
96 #endif // WIN32
97 
98  // shutdown connection to ptu
99  delete control;
100  return 0;
101 }
virtual void ResumeControl()=0
Resumes control.
abstract control class for control of Directed Perception Pan Tilt Unit.
virtual void StopControl()=0
Stops/pauses control.
virtual void StartControl()=0
Starts controlling the PTU.
Factory to create a PanTiltManualControl.
virtual PanTiltControlInterface * Create(std::string device, bool heavyDutyMode)=0
Abstract controller factory used to create all different kinds of PTU controls.