Aria  2.8.0
ArPTZConnector Class Reference

Factory for creating and configuring interfaces for pan/tilt units or camera pan/tilt/zoom control based on robot parameter file and command-line arguments. More...

#include <ArPTZConnector.h>

Public Types

typedef ArGlobalRetFunctor4< ArPTZ *, size_t, ArPTZParams, ArArgumentParser *, ArRobot * > GlobalPTZCreateFunc
 
typedef ArRetFunctor4< ArPTZ *, size_t, ArPTZParams, ArArgumentParser *, ArRobot * > PTZCreateFunc
 Arguments passed to function are PTZ index, parameters, parser (may be null) and robot object (may be null)
 

Public Member Functions

 ArPTZConnector (ArArgumentParser *argParser, ArRobot *robot=NULL)
 
bool connect ()
 For each PTZ specified in program arguments, and in robot parameters with PTZAutoConnect set to true, create the appropriate PTZ object (based on type name) and connect to it. More...
 
bool connectPTZs ()
 For each PTZ specified in program arguments, and in robot parameters with PTZAutoConnect set to true, create the appropriate PTZ object (based on type name) and connect to it. More...
 
ArPTZfindPTZ (size_t i) const
 
size_t getMaxNumPTZs ()
 
size_t getNumPTZs () const
 
ArPTZgetPTZ (size_t i=0) const
 
std::vector< ArPTZ * > getPTZs () const
 
ArRobotgetRobot ()
 Return robot that PTZs are or will be attached to (may be NULL)
 
void setMaxNumPTZs (size_t n)
 Change limit on number of PTZ devices. More...
 
 ~ArPTZConnector ()
 

Static Public Member Functions

static void registerPTZType (const std::string &typeName, ArPTZConnector::PTZCreateFunc *func)
 Register a new PTZ type. More...
 

Protected Member Functions

void logOptions () const
 
bool parseArgs ()
 
bool parseArgs (ArArgumentParser *parser)
 
bool parseArgsFor (ArArgumentParser *parser, int which)
 
void populateRobotParams (ArRobotParams *params)
 

Protected Attributes

ArArgumentParsermyArgParser
 
std::vector< ArPTZParamsmyArguments
 from program command-line options (via the parseArgs() callback called by Aria::parseArgs())
 
std::vector< ArPTZ * > myConnectedPTZs
 ArPTZ objects created and initialized in connect().
 
ArConstFunctorC< ArPTZConnectormyLogOptionsCallback
 
std::vector< ArPTZParamsmyParams
 copied from ArRobotParams (via myRobot), then in connect() parameters given from command line arguments (myArguments) are merged in.
 
ArRetFunctorC< bool, ArPTZConnectormyParseArgsCallback
 
ArFunctor1C< ArPTZConnector, ArRobotParams * > myPopulateRobotParamsCB
 
ArRobotmyRobot
 

Static Protected Attributes

static std::map< std::string, PTZCreateFunc *> ourPTZCreateFuncs
 

Detailed Description

Factory for creating and configuring interfaces for pan/tilt units or camera pan/tilt/zoom control based on robot parameter file and command-line arguments.

First, create an ArPTZConnector object before calling Aria::parseArgs(). After connecting to the robot, call Aria::parseArgs() to check arguments and parameters from the parameter file(s). Then, call connect() to connect to all configured and enabled PTZs. To get access to a PTZ objects, use getPTZ(int i) and getNumPTZs(), or getPTZs(). ArPTZ provides an interface to functions that most PTZ implementations (ArPTZ subclasses) implement. Some PTZ implementations have additional features. Use those subclasse directly to use these additional features (use dynamic_cast to cast an ArPTZ pointer to a subclass pointer, if possible.)

ArPTZConnector has built in support for all the PTZ types with support included in the ARIA library, and other libraries or programs may register new types as well. (For example, the ArVideo library contains support for additional camera PTZ types.)

The following command-line arguments are checked:

Common PTU and Camera PTZ options:

	-ptzType <type>	Select PTZ/PTU type. Required.  Available types are:
		dpptu
		rvision
		sony
		vcc
		vcc4
		vcc50i
	-ptzInverted <true|false>	If true, reverse tilt and pan axes for cameras mounted upside down.

Only one of the following sets of connection parameters may be given:

For computer serial port connections:
	-ptzSerialPort <port>	Serial port name.

For Pioneer robot auxilliary serial port connections:
	-ptzRobotAuxSerialPort <1|2|3>	Use specified Pioneer robot auxilliary serial port.

For network connections:
	-ptzAddress <address>	Network address or hostname for network connection.
	-ptzTcpPort <port>	TCP port number for network connections.

Parameters for multiple cameras/units may be given like: -ptz1Type, -ptz2Type, -ptz3Type, etc.
Some PTZ/PTU types may accept additional type-specific options. Refer to option documentation text specific to those types.

PTZs are 0-indexed internally in this class, however, argument names, parameter names and log messages displayed to users are 1-indexed.

Since
2.7.6
Examples:
cameraPTZExample.cpp.

Constructor & Destructor Documentation

◆ ~ArPTZConnector()

ArPTZConnector::~ArPTZConnector ( )

Member Function Documentation

◆ connect()

bool ArPTZConnector::connect ( )

For each PTZ specified in program arguments, and in robot parameters with PTZAutoConnect set to true, create the appropriate PTZ object (based on type name) and connect to it.

Returns
false on first error, true if all PTZ connections were successful.
Examples:
cameraPTZExample.cpp.

◆ connectPTZs()

bool ArPTZConnector::connectPTZs ( )
inline

For each PTZ specified in program arguments, and in robot parameters with PTZAutoConnect set to true, create the appropriate PTZ object (based on type name) and connect to it.

Returns
false on first error, true if all PTZ connections were successful.

◆ findPTZ()

ArPTZ* ArPTZConnector::findPTZ ( size_t  i) const
inline

◆ getNumPTZs()

size_t ArPTZConnector::getNumPTZs ( ) const
inline
Returns
number of PTZ objects that were created and connected to.
Examples:
cameraPTZExample.cpp.

◆ getPTZ()

ArPTZ* ArPTZConnector::getPTZ ( size_t  i = 0) const
inline
Returns
a specific PTZ object that was connected by connect() or connectPTZs(), or NULL if none exists. These are 0-indexed.
Examples:
cameraPTZExample.cpp.

◆ getPTZs()

std::vector<ArPTZ*> ArPTZConnector::getPTZs ( ) const
inline
Returns
list of connected PTZs. 0-indexed. Pointers in the vector may be NULL if no parameters or command line arguments were given for them or that PTZ was disabled. These should be skipped when iterating on this list and not accessed.

◆ registerPTZType()

void ArPTZConnector::registerPTZType ( const std::string &  typeName,
ArPTZConnector::PTZCreateFunc func 
)
static

Register a new PTZ type.

Aria::init() registers PTZ types built in to ARIA. ArVideo::init() registers new PTZ types implemented in the ArVideo library. You may also add any new PTZ types you create.

◆ setMaxNumPTZs()

void ArPTZConnector::setMaxNumPTZs ( size_t  n)
inline

Change limit on number of PTZ devices.

You must call this before creating an ArPTZConnector, parsing command line arguments, connecting to a robot or loading a parameter file, or using ArPTZconnecor to connect to PTZ devices.


The documentation for this class was generated from the following files: