This is an example using the RVision pan/tilt/zoom camera used on Seekur and Seekur Jr.
This program uses key commands to control the pan, tilt, and zoom of the camera.
It defaults to use COM3.
UP,DOWN – tilt up/down by 1 degree LEFT,RIGHT – pan left/right by 1 degree X,C – zoom in/out by 10 units (80 total) I – initialize PTU to default settings >,< – increase/decrease the positional increment by one 1 degree +,- – increase/decrease the slew by 5 degrees/sec Z – move pan and tilt axes to zero H – Halt all motion S – Status of camera position and variable values P – Power on/off the camera ESC – Exit program
#include "Aria.h"
#include "ArRVisionPTZ.h"
class KeyPTU
{
public:
~KeyPTU(void) {}
void up(void);
void down(void);
void left(void);
void right(void);
void greater(void);
void less(void);
void question(void);
void status(void);
void c(void);
void h(void);
void i(void);
void p(void);
void x(void);
void z(void);
void r(void);
void drive(void);
void power(bool p);
protected:
int myPosIncrement;
int myZoomIncrement;
bool myMonitor;
bool myInit;
bool myAbsolute;
bool myExercise;
void exercise(void) { myExercise = !myExercise; }
bool myPTUInitRequested;
bool myPowerOn;
};
myUpCB(this, &KeyPTU::up),
myDownCB(this, &KeyPTU::down),
myLeftCB(this, &KeyPTU::left),
myRightCB(this, &KeyPTU::right),
myGreaterCB(this, &KeyPTU::greater),
myLessCB(this, &KeyPTU::less),
myQuestionCB(this, &KeyPTU::question),
mySCB(this, &KeyPTU::status),
myECB(this, &KeyPTU::exercise),
myCCB(this, &KeyPTU::c),
myICB(this, &KeyPTU::i),
myPCB(this, &KeyPTU::p),
myXCB(this, &KeyPTU::x),
myZCB(this, &KeyPTU::z),
myRCB(this, &KeyPTU::r),
myPTU(robot),
myDriveCB(this, &KeyPTU::drive)
{
myRobot = robot;
myExerciseTime.setToNow();
myExercise = false;
{
myRobot->attachKeyHandler(keyHandler);
}
"The key handler already has a key for left, keydrive will not work correctly.");
"The key handler already has a key for right, keydrive will not work correctly.");
"The key handler already has a key for '>', keydrive will not work correctly.");
"The key handler already has a key for '<', keydrive will not work correctly.");
"The key handler already has a key for '?', keydrive will not work correctly.");
"The key handler already has a key for 'C', keydrive will not work correctly.");
"The key handler already has a key for 'I', keydrive will not work correctly.");
"The key handler already has a key for 'P', keydrive will not work correctly.");
"The key handler already has a key for 'R', keydrive will not work correctly.");
"The key handler already has a key for 'S', keydrive will not work correctly.");
"The key handler already has a key for 'X', keydrive will not work correctly.");
"The key handler already has a key for 'Z', keydrive will not work correctly.");
myPTUInitRequested = false;
myPosIncrement = 1;
myZoomIncrement = 50;
myPowerOn = false;
}
void KeyPTU::power(bool state)
{
if(state)
{
myRobot->com2Bytes(116, 12, 1);
myPowerOn = true;
}
else
{
myRobot->com2Bytes(116, 12, 0);
myPowerOn = false;
}
}
void KeyPTU::right(void)
{
myPTU.panRel(myPosIncrement);
}
void KeyPTU::left(void)
{
myPTU.panRel(-myPosIncrement);
}
void KeyPTU::up(void)
{
myPTU.tiltRel(myPosIncrement);
}
void KeyPTU::down(void)
{
myPTU.tiltRel(-myPosIncrement);
}
void KeyPTU::x(void)
{
myPTU.zoom(myPTU.getZoom() + myZoomIncrement);
}
void KeyPTU::c(void)
{
myPTU.zoom(myPTU.getZoom() - myZoomIncrement);
}
void KeyPTU::i(void)
{
myPTU.init();
}
void KeyPTU::greater(void)
{
myPosIncrement += 1;
if (myPosIncrement > myPTU.getMaxPosPan())
myPosIncrement = myPTU.getMaxPosPan();
status();
}
void KeyPTU::less(void)
{
myPosIncrement -= 1;
if (myPosIncrement < 0)
myPosIncrement = 0;
status();
}
void KeyPTU::z(void)
{
myPTU.panTilt(0,0);
myPTU.zoom(0);
status();
}
void KeyPTU::r(void)
{
myPTU.reset();
}
void KeyPTU::question(void)
{
}
void KeyPTU::status(void)
{
if (myPowerOn)
else
}
void KeyPTU::p(void)
{
power(!myPowerOn);
status();
}
void KeyPTU::drive(void)
{
if (!myPTUInitRequested && myRobot->isConnected())
{
printf("\nInitializing ArRVision\n");
myAbsolute = true;
myPTUInitRequested = true;
myPTU.init();
question();
}
if (myExerciseTime.secSince() > 5 && myExercise)
{
int pan,tilt;
else
else
myPTU.panTilt(pan, tilt);
myExerciseTime.setToNow();
}
}
int main(int argc, char **argv)
{
std::string str;
KeyPTU ptu(&robot);
if (!con.connectRobot())
{
if(parser.checkHelpAndWarnUnparsed())
return 1;
}
{
}
ptu.power(true);
printf("Press '?' for available commands\r\n");
}