Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExamplePanTiltManualControl.cpp

This is an example for steering the PTU manually. Use w, s, a, d to steer camera, <space> or q to exit.

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExamplePanTiltManualControl.cpp
@relates DPPanTiltControl
@ingroup g_examples
@brief This is an example for steering the PTU manually.
Use w, s, a, d to steer camera, <space> or q to exit.
@author MIP
*/
#include <Base/Common/BIASpragma.hh>
#include <PanTilt/DPPanTiltControl.hh>
#ifdef WIN32
#include <conio.h>
#else // WIN32
#include <ncurses.h>
#endif // WIN32
#include <PanTilt/PanTiltControlInterface.hh>
#include <PanTilt/PanTiltManualControl.hh>
#include <PanTilt/PanTiltAutoControl.hh>
using namespace std;
using namespace BIAS;
int main (int argc, char *argv[]){
#ifndef WIN32
initscr();
keypad(stdscr, true);
noecho();
cbreak();
mvprintw(0,0,"PanTilt Manual Control");
mvprintw(2,0,"Use w, s, a, d to steer camera, <space> or q to exit.");
#endif // WIN32
// create a new factory...
// ... which should build automatic controls
// cf = new PanTiltAutoControlFactory();
// factory should produce such control
string device;
#ifdef WIN32
device = "COM1";
#else
device = "/dev/ttyUSB0";
#endif
PanTiltControlInterface *control = cf->Create(device, false);
// start up the produced control
control->StartControl();
bool loop = true;
while (loop) {
char c = getch();
switch(c) {
case 'e':
control->StopControl();
break;
case 'r':
control->ResumeControl();
break;
case 'q':
control->StopControl();
loop = false;
break;
}
}
#ifndef WIN32
endwin();
#endif // WIN32
// shutdown connection to ptu
delete control;
return 0;
}