Main Page   Class Hierarchy   Compound List   Compound Members  

ArPTZ Class Reference

Base class which handles the PTZ cameras. More...

#include <ArPTZ.h>

Inheritance diagram for ArPTZ::

ArAMPTU ArDPPTU ArSonyPTZ ArVCC4 List of all members.

Public Methods

 ArPTZ (ArRobot *robot)
virtual ~ArPTZ (void)
 Destructor.

virtual bool init (void)=0
 Initializes the camera.

virtual bool pan (int degrees)=0
 Pans to the given degrees.

virtual bool panRel (int degrees)=0
 Pans relative to current position by given degrees.

virtual bool tilt (int degrees)=0
 Tilts to the given degrees.

virtual bool tiltRel (int degrees)=0
 Tilts relative to the current position by given degrees.

virtual bool panTilt (int degreesPan, int degreesTilt)=0
 Pans and tilts to the given degrees.

virtual bool panTiltRel (int degreesPan, int degreesTilt)=0
 Pans and tilts relatives to the current position by the given degrees.

virtual bool canZoom (void)=0
 Returns true if camera can zoom (or rather, if it is controlled by this).

virtual bool zoom (int zoomValue)
 Zooms to the given value.

virtual bool zoomRel (int zoomValue)
 Zooms relative to the current value, by the given value.

virtual int getPan (void)=0
 The angle the camera was last told to pan to.

virtual int getTilt (void)=0
 The angle the camera was last told to tilt to.

virtual int getZoom (void)
 The value the camera was last told to zoom to.

virtual bool canGetRealPanTilt (void)
 If this driver can tell the real pan/tilt angle.

virtual int getRealPan (void)
 The angle the camera says its at.

virtual int getRealTilt (void)
 The angle the camera says its at.

virtual bool canGetRealZoom (void)
 If this driver can tell the real zoom.

virtual int getRealZoom (void)
 The zoom the camera says its at.

virtual int getMaxPosPan (void)=0
 Gets the highest positive degree the camera can pan to.

virtual int getMaxNegPan (void)=0
 Gets the lowest negative degree the camera can pan to.

virtual int getMaxPosTilt (void)=0
 Gets the highest positive degree the camera can tilt to.

virtual int getMaxNegTilt (void)=0
 Gets the lowest negative degree the camera can tilt to.

virtual int getMaxZoom (void)
 Gets the maximum value for the zoom on this camera.

virtual int getMinZoom (void)
 Gets the lowest value for the zoom on this camera.

virtual bool setDeviceConnection (ArDeviceConnection *connection, bool driveFromRobotLoop=true)
 Sets the device connection to be used by this PTZ camera, if set this camera will send commands via this connection, otherwise its via robot. More...

virtual ArDeviceConnectiongetDeviceConnection (void)
 Gets the device connection used by this PTZ camera.

virtual ArBasePacketreadPacket (void)
 Reads a packet from the device connection, MUST NOT BLOCK. More...

virtual bool sendPacket (ArBasePacket *packet)
 Sends a given packet to the camera (via robot or serial port, depending). More...

virtual bool packetHandler (ArBasePacket *packet)
 Handles a packet that was read from the device. More...

virtual bool robotPacketHandler (ArRobotPacket *packet)
 Handles a packet that was read by the robot. More...

virtual void connectHandler (void)
 Internal, attached to robot, inits the camera when robot connects.

virtual void sensorInterpHandler (void)
 Internal, for attaching to the robots sensor interp to read serial port.


Detailed Description

Base class which handles the PTZ cameras.

This class is mainly concerned with making all the cameras look the same for outgoing data, it is also set up to facilitate the acquisition of incoming data but that is described in the following paragraphs. There are two ways this can be used. The first is the simplest and default behavior and should be used by those whose cameras are attached to their robot's microcontroller, a ArRobot pointer is passed in to the contructor, this is where the commands will be sent to the robot via the robot's connection which will then send it along over the second serial port. The second way is to pass an ArDeviceConnection to setDeviceConnection, if this is done commands will be sent along the given serial port, this should ONLY be done if the camera is attached straight to a serial port on the computer this program is running on.

The next two paragraphs describe how to get data back from the cameras, but this base class is set up so that by default it won't try to get data back and assumes you're not trying to do that. If you are trying to get data back the important functions are packetHandler, robotPacketHandler and readPacket and you should read the docs on those.

If the camera is attached to the robot (and you are thus using the first method described in the first paragraph) then the only way to get data back is to send an ArCommands::GETAUX, then set up a robotPacketHandler for the AUX id and have it call the packetHandler you set up in in the class.

If the camera is attached to the serial port on the computer (and thus the second method described in the first paragraph was used) then its more complicated... the default way is to just pass in an ArDeviceConnection to setDeviceConnection and implement the readPacket method (which MUST not block), and every time through the robot loop readPacket (with the sensorInterpHandler) will be called and any packets will be given to the packetHandler (which you need to implement in your class) to be processed. The other way to do this method is to pass both an ArDefaultConnection and false to setDeviceConnection, this means the camera will not be read at all by default, and you're on your own for reading the data in (ie like your own thread).


Constructor & Destructor Documentation

ArPTZ::ArPTZ ArRobot   robot
 

Parameters:
robot  The robot this camera is attached to, can be NULL


Member Function Documentation

virtual bool ArPTZ::packetHandler ArBasePacket   packet [inline, virtual]
 

Handles a packet that was read from the device.

This should work for the robot packet handler or for packets read in from readPacket (the joys of OO), but it can't deal with the need to check the id on robot packets, so you should check the id from robotPacketHandler and then call this one so that your stuff can be used by both robot and serial port connections.

Parameters:
packet  the packet to handle
Returns:
true if this packet was handled (ie this knows what it is), false otherwise

virtual ArBasePacket* ArPTZ::readPacket void    [inline, virtual]
 

Reads a packet from the device connection, MUST NOT BLOCK.

This should read in a packet from the myConn connection and return a pointer to a packet if there was on to read in, or NULL if there wasn't one... this MUST not block if it is used with the default mode of being driven from the sensorInterpHandler, since that is on the robot loop.

Returns:
packet read in, or NULL if there was no packet read

virtual bool ArPTZ::robotPacketHandler ArRobotPacket   packet [inline, virtual]
 

Handles a packet that was read by the robot.

This handles packets read in from the robot, this function should just check the ID of the robot packet and then return what packetHandler thinks of the packet.

Parameters:
packet  the packet to handle
Returns:
true if the packet was handled (ie this konws what it is), false otherwise

bool ArPTZ::sendPacket ArBasePacket   packet [virtual]
 

Sends a given packet to the camera (via robot or serial port, depending).

Parameters:
packet  the packet to send
Returns:
true if the packet could be sent, false otherwise

bool ArPTZ::setDeviceConnection ArDeviceConnection   connection,
bool    driveFromRobotLoop = true
[virtual]
 

Sets the device connection to be used by this PTZ camera, if set this camera will send commands via this connection, otherwise its via robot.

Parameters:
connection  the device connection the camera is connected to, normally a serial port
driveFromRobotLoop  if this is true then a sensor interp callback wil be set and that callback will read packets and call the packet handler on them
Returns:
true if the serial port is opened or can be opened, false otherwise


The documentation for this class was generated from the following files:
Generated on Tue Nov 12 17:44:00 2002 for Aria by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001