Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArVCC4 Class Reference

Driver for the VCC4. More...

#include <ArVCC4.h>

Inheritance diagram for ArVCC4:

ArPTZ List of all members.

Public Types

enum  CameraType { CAMERA_VCC4, CAMERA_C50I }
enum  CommState { COMM_UNKNOWN, COMM_BIDIRECTIONAL, COMM_UNIDIRECTIONAL }

Public Member Functions

void addErrorCB (ArFunctor *functor, ArListPos::Pos position)
 ArVCC4 (ArRobot *robot, bool inverted=false, CommState commDirection=COMM_UNKNOWN, bool autoUpdate=true, bool disableLED=false, CameraType cameraType=CAMERA_VCC4)
 Constructor.
virtual bool autoFocus (void)
virtual bool canGetRealPanTilt (void) const
 If this driver can tell the real pan/tilt angle.
virtual bool canGetRealZoom (void) const
 If this driver can tell the real zoom.
virtual bool canSetFocus (void) const
 If the driver can set the focus on the camera, or not.
virtual bool canZoom (void) const
 Returns true if camera can zoom (or rather, if it is controlled by this).
virtual void connectHandler (void)
 Internal, attached to robot, inits the camera when robot connects.
bool digitalZoom (int deg)
void disableAutoUpdate (void)
void disableIRFilterMode (void)
 Disable IR cutoff filter. This also turns off the LEDs, if they're on.
void disableIRLEDs (void)
 Turn off IR LEDs.
void enableAutoUpdate (void)
 Toggle the state of the auto-update.
void enableIRFilterMode (void)
 Enable physical IR cutoff filter.
void enableIRLEDs (void)
 Turn on IR LEDs. IR-filter must be in place for LEDs to turn on.
virtual bool focusFar (void)
 auto-fovus on a far object
virtual bool focusNear (void)
 auto-focus on a near object
bool getAutoUpdate (void)
int getDigitalZoom (void) const
bool getIRFilterModeEnabled (void)
 Returns true if the IR cutoff filter is in place.
bool getIRLEDsEnabled (void)
 Returns true if the IR LEDs are on.
virtual int getMaxNegPan (void) const
 Gets the lowest negative degree the camera can pan to.
virtual int getMaxNegTilt (void) const
 Gets the lowest negative degree the camera can tilt to.
int getMaxPanSlew (void)
 Gets the maximum pan slew.
virtual int getMaxPosPan (void) const
 Gets the highest positive degree the camera can pan to.
virtual int getMaxPosTilt (void) const
 Gets the highest positive degree the camera can tilt to.
int getMaxTiltSlew (void)
 Gets the maximum tilt slew.
virtual int getMaxZoom (void) const
 Gets the maximum value for the zoom on this camera.
int getMinPanSlew (void)
 Gets the minimum pan slew.
int getMinTiltSlew (void)
 Gets the minimum tilt slew.
virtual int getMinZoom (void) const
 Gets the lowest value for the zoom on this camera.
virtual int getPan (void) const
 The angle the camera was last told to pan to.
int getPanSlew (void)
 Gets the current pan slew.
bool getPower (void)
void getRealPanTilt (void)
void getRealZoomPos (void)
virtual int getTilt (void) const
 The angle the camera was last told to tilt to.
int getTiltSlew (void)
 Gets the current tilt slew.
virtual int getZoom (void) const
 The value the camera was last told to zoom to.
bool haltPanTilt (void)
 Halts all pan-tilt movement.
bool haltZoom (void)
 Halts zoom movement.
virtual bool init (void)
 Initializes the camera.
bool isInitted (void)
 Returns true if the camera has been initialized.
virtual bool packetHandler (ArBasePacket *packet)
 Handles a packet that was read from the device.
virtual bool pan (int deg)
 Pans to the given degrees.
virtual bool panRel (int deg)
 Pans relative to current position by given degrees.
bool panSlew (int deg)
 Sets the rate that the unit pans at.
virtual bool panTilt (int pdeg, int tdeg)
 Pans and tilts to the given degrees.
virtual bool panTiltRel (int pdeg, int tdeg)
 Pans and tilts relatives to the current position by the given degrees.
virtual bool power (bool state)
void preparePacket (ArVCC4Packet *packet)
 Adds device ID and delimeter to packet buffer.
void remErrorCB (ArFunctor *functor)
 Remove an error callback from the callback list.
void setLEDControlMode (int controlMode)
virtual bool tilt (int deg)
 Tilts to the given degrees.
virtual bool tiltRel (int deg)
 Tilts relative to the current position by given degrees.
bool tiltSlew (int deg)
 Sets the rate the unit tilts at.
bool wasError (void)
 Returns true if the error callback list was called during the last cycle.
virtual bool zoom (int deg)
 Zooms to the given value.
virtual ~ArVCC4 ()
 Destructor.

Protected Types

enum  Error {
  CAM_ERROR_NONE = 0x30, CAM_ERROR_BUSY = 0x31, CAM_ERROR_PARAM = 0x35, CAM_ERROR_MODE = 0x39,
  CAM_ERROR_UNKNOWN = 0xFF
}
enum  Param {
  MAX_PAN = 98, MIN_PAN = -98, MAX_TILT = 88, MIN_TILT = -30,
  MAX_PAN_SLEW = 90, MIN_PAN_SLEW = 1, MAX_TILT_SLEW = 69, MIN_TILT_SLEW = 1,
  MAX_ZOOM_OPTIC = 1960, MIN_ZOOM = 0
}
enum  State {
  UNINITIALIZED, STATE_UNKNOWN, INITIALIZING, SETTING_CONTROL_MODE,
  SETTING_INIT_TILT_RATE, SETTING_INIT_PAN_RATE, SETTING_INIT_RANGE, POWERING_ON,
  POWERING_OFF, POWERED_OFF, POWERED_ON, AWAITING_INITIAL_POWERON,
  AWAITING_INITIAL_INIT, AWAITING_ZOOM_RESPONSE, AWAITING_PAN_TILT_RESPONSE, AWAITING_STOP_PAN_TILT_RESPONSE,
  AWAITING_STOP_ZOOM_RESPONSE, AWAITING_PAN_SLEW_RESPONSE, AWAITING_TILT_SLEW_RESPONSE, AWAITING_POS_REQUEST,
  AWAITING_ZOOM_REQUEST, AWAITING_LED_CONTROL_RESPONSE, AWAITING_IRLEDS_RESPONSE, AWAITING_IRFILTER_RESPONSE,
  AWAITING_PRODUCTNAME_REQUEST, AWAITING_DIGITAL_ZOOM_RESPONSE, AWAITING_FOCUS_RESPONSE, STATE_DELAYED_SWITCH,
  STATE_ERROR
}

Protected Member Functions

void camTask (void)
int invert (int before) const
void processGetPanTiltResponse (void)
void processGetProductNameResponse (void)
void processGetZoomResponse (void)
virtual ArBasePacketreadPacket (void)
 Reads a packet from the device connection, MUST NOT BLOCK.
void requestBytes (int num=6)
bool sendCameraNameRequest (void)
bool sendDigitalZoom (void)
bool sendFocus (void)
bool sendHaltPanTilt (void)
bool sendHaltZoom (void)
bool sendInit (void)
bool sendIRFilterControl (void)
bool sendIRLEDControl (void)
bool sendLEDControlMode (void)
bool sendPanSlew (void)
bool sendPanTilt (void)
bool sendPower (void)
bool sendProductNameRequest (void)
bool sendRealPanTiltRequest (void)
bool sendRealZoomRequest (void)
bool sendTiltSlew (void)
bool sendZoom (void)
bool setControlMode (void)
bool setDefaultRange (void)
void switchState (State state, int delayTime=0)
void throwError ()
bool timeout (int mSec=0)

Protected Attributes

bool myAutoUpdate
int myAutoUpdateCycle
int myBytesLeft
bool myCameraHasBeenInitted
bool myCameraIsInitted
CameraType myCameraType
CommState myCommType
ArDeviceConnectionmyConn
bool myDesiredIRFilterMode
bool myDesiredIRLEDsMode
int myDesiredLEDControlMode
int myDigitalZoom
int myDigitalZoomDesired
unsigned int myError
std::list< ArFunctor * > myErrorCBList
int myFocusMode
int myFocusModeDesired
bool myHaltPanTiltRequested
bool myHaltZoomRequested
ArTime myIdleTime
bool myInitRequested
bool myInverted
bool myIRFilterModeEnabled
bool myIRLEDsEnabled
State myNextState
ArVCC4Packet myPacket
unsigned char myPacketBuf [50]
int myPacketBufLen
ArTime myPacketTime
int myPacketTimeout
int myPan
int myPanDesired
int myPanResponse
int myPanSent
int myPanSlew
int myPanSlewDesired
int myPanSlewSent
bool myPowerState
bool myPowerStateDesired
State myPreviousState
std::string myProductName
char myProductNameResponse [4]
bool myRealPanTiltRequested
bool myRealZoomRequested
bool myRequestProductName
bool myResponseReceived
ArRobotmyRobot
State myState
int myStateDelayTime
ArTime myStateTime
int myStateTimeout
ArFunctorC< ArVCC4myTaskCB
int myTilt
int myTiltDesired
int myTiltResponse
int myTiltSent
int myTiltSlew
int myTiltSlewDesired
int myTiltSlewSent
bool myUsingAuxPort
bool myWaitingOnPacket
bool myWaitingOnStop
bool myWasError
int myZoom
int myZoomDesired
int myZoomResponse
int myZoomSent
ArBasePacketnewPacket

Detailed Description

Driver for the VCC4.

Definition at line 132 of file ArVCC4.h.


Member Enumeration Documentation

enum ArVCC4::Error [protected]
 

Enumeration values:
CAM_ERROR_NONE  No error.
CAM_ERROR_BUSY  Camera busy, will not execute the command.
CAM_ERROR_PARAM  Illegal parameters to function call.
CAM_ERROR_MODE  Not in host control mode.
CAM_ERROR_UNKNOWN  Unknown error condition. Should never happen.

Definition at line 286 of file ArVCC4.h.


Constructor & Destructor Documentation

ArVCC4::ArVCC4 ArRobot robot,
bool  inverted = false,
CommState  commDirection = COMM_UNKNOWN,
bool  autoUpdate = true,
bool  disableLED = false,
CameraType  cameraType = CAMERA_VCC4
 

Constructor.

Parameters:
robot the robot this camera is attached to
inverted if this camera is inverted or not, the only time a camera will normally be inverted is on a robot where it's mounted on the underside of something, ie like in a peoplebot
commDirection this is the type of communications that the camera should use. It can be unidirectional, bidirectional, or unknown. If unidirectional it sends packets without knowing if the camera has received them or not. This results in necessary 300 ms delays between packets, otherwise the packets will get dropped. In bidirectional mode, responses are received from the camera and evaluated for success of receipt of the previous command. In unknown mode, it will use bidirectional communication if a response is received, otherwise it will be unidirectional.
autoUpate this will cause the usertask to periodically query the camera for actual positional information (pan, tilt, zoom). This will happen every 1 sec idle time, and will switch between pan/tilt info and zoom info.
disableLED if set to true this will force the LED, on the front of the camera, to turn off. Otherwise it will function normally
cameraType used to discriminate between VC-C4 and C50i

Definition at line 114 of file ArVCC4.cpp.

References ArRobot::addUserTask(), CAM_ERROR_NONE, getMaxPanSlew(), getMaxTiltSlew(), ArLog::log(), and ArTime::setToNow().


Member Function Documentation

void ArVCC4::addErrorCB ArFunctor functor,
ArListPos::Pos  position
 

Adds an error callback to a list of callbacks to be called when there is a serious error in communicating - either the parameters were incorrect, the mode was incorrect, or there was an unknown error.

Definition at line 1924 of file ArVCC4.cpp.

References ArLog::log().

virtual bool ArVCC4::autoFocus void   )  [inline, virtual]
 

Set autofocus mode: 0 = Autofocus, 1 = manual focus

Definition at line 223 of file ArVCC4.h.

bool ArVCC4::digitalZoom int  deg  ) 
 

adjust the optical zoom amount. Has four states, takes 0-3 for: 1x, 2x, 4x, 8x

Definition at line 1770 of file ArVCC4.cpp.

void ArVCC4::getRealPanTilt void   )  [inline]
 

Requests that a packet be sent to the camera to retrieve what the camera thinks are its pan/tilt positions

Definition at line 178 of file ArVCC4.h.

void ArVCC4::getRealZoomPos void   )  [inline]
 

Requests that a packet be sent to the camera to retrieve what the camera thinks is its zoom position

Definition at line 182 of file ArVCC4.h.

bool ArVCC4::packetHandler ArBasePacket packet  )  [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

Reimplemented from ArPTZ.

Definition at line 1517 of file ArVCC4.cpp.

References CAM_ERROR_BUSY, CAM_ERROR_MODE, CAM_ERROR_NONE, CAM_ERROR_PARAM, CAM_ERROR_UNKNOWN, ArLog::log(), and ArTime::setToNow().

ArBasePacket * ArVCC4::readPacket void   )  [protected, 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

Reimplemented from ArPTZ.

Definition at line 1443 of file ArVCC4.cpp.

References ArBasePacket::dataToBuf(), ArBasePacket::empty(), ArLog::log(), ArDeviceConnection::read(), and ArBasePacket::resetRead().

bool ArVCC4::sendLEDControlMode void   )  [protected]
 

This controls the status of the LED. 0 - disable forced control 1 - green forced on 2 - all forced off 3 - red forced on 4 - orange forced on

Definition at line 2235 of file ArVCC4.cpp.

References ArBasePacket::empty(), ArLog::log(), preparePacket(), ArPTZ::sendPacket(), and ArBasePacket::uByteToBuf().

void ArVCC4::setLEDControlMode int  controlMode  )  [inline]
 

Set the control mode for the status LED on the front of the camera 0 = auto-control, 1 = Green ON, 2 = All OFF, 3 = Red ON, 4 = Orange ON

Definition at line 256 of file ArVCC4.h.


The documentation for this class was generated from the following files:
Generated on Wed Oct 19 12:56:56 2005 for Aria by  doxygen 1.4.0