This is an example showing how to connect to and use a camera's PTZ control (or DPPTU)This program can control PTZ cameras with support built in to the ARIA library: Canon VCC 4/5, Sony PTZ, RVision, and DPPTU. To control the Axis network cameras, see example programs in the ArVideo library instead.
PTZ type and connection parameters are read from robot parameter file if available, or use command-line arguments to override the robot parameter file. Run with –help for a complete list of command-line options available.
For example, to connect to Canon VCC on robot auxilliary serial port, use: ./cameraPTZExample -ptzType vcc4
To connect to Canon VCC on serial port COM4, use: ./cameraPTZExample -ptzType vcc4 -ptzSerialPort COM4 or on Linux this works too: ./cameraPTZExample -ptzType vcc4 -ptzSerialPort /dev/ttyS3
To connect to RVision camera, use: ./cameraPTZExample -ptzType rvision
To connect to DPPTU use: ./cameraPTZExample -ptzType dpptu
Canon VCC defaults to use the microcontroller port Aux1. Use -ptzRobotAuxSerialPort or -ptzSerialPort arguments to change.
#include "Aria.h"
int main(int argc, char **argv)
{
{
ArLog::log(
ArLog::Terse,
"cameraPTZExample: Warning, Could not connect to the robot. Won't use robot parameter file for defaults");
}
{
}
const int PauseTime = 3500;
for(
size_t i = 0; i < ptzConnector.
getNumPTZs(); ++i)
{
if(!ptz)
{
continue;
}
if(!ArMath::compareFloats(ptz->
getPan(), -90, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: pan position is more than one degree different from command -90.");
if(!ArMath::compareFloats(ptz->
getPan(), 90, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: pan position is more than one degree different from command 90.");
if(!ArMath::compareFloats(ptz->
getPan(), 0, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: pan position is more than one degree different from command 0.");
if(!ArMath::compareFloats(ptz->
getTilt(), 90, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: tilt position is more than one degree different from command 90.");
if(!ArMath::compareFloats(ptz->
getTilt(), -20, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: tilt position is more than one degree different from command -20.");
if(!ArMath::compareFloats(ptz->
getTilt(), 0, 1))
ArLog::log(
ArLog::Normal,
"cameraPTZExample: Warning: tilt position is more than one degree different from command 0.");
}
return 0;
}