Aria: ArVCC4 Class Reference

- Main Page
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ArVCC4 Class Reference

`#include <ArVCC4.h>`

Inheritance diagram for ArVCC4:

List of all members.

## Detailed Description

Control the pan, tilt, and zoom mechanisms of the Canon VC-C4 and C50i cameras.

An ArVCC4 object can be used to control the pan, tilt, zoom and some other aspects of the Canon VC-C4 camera. Since the camera is typically connected to the robot microcontroller's auxilliary serial port, and also uses ArRobot task cycle callbacks, a connected and running ArRobot object is required.

Communication with the camera can operate in two modes or directions. In unidirectional mode(COMM_UNIDIRECTIONAL), ArVCC4 simply sends commands to the camera, and waits for some time to allow the camera to process it. However, it will have no way of verifying that a command was successfully received by the cameral. In bidirectional mode (COMM_BIDIRECTIONAL), ArVCC4 waits for a response from the camera. Bidirectinal mode requires that the CTS line (pin 2 on the VISCA port) be connected. When you create an ArVCC4 object, you can request a specific mode, or you can specify COMM_UNKNOWN, and ArVCC4 will switch into bidirectional mode if it receives any responses from the camera.

## Command-Response details:

This camera has a reponse mechanism, whereby each packet sent to the camera generates an answer within 300ms. For the most part, the answer consists of a 6-byte packet which has an error-status within it. Some commands generate longer packets. Receiving the error status is helpful in that you know that the camera will or will not execute the command. However, it doesn't tell you when the command is completed.

In order for the the reponses to work, the CTS line on the camera must be high. This is pin 2 on the visca port. If your camera is not wired in such a fashion, then no answers will be sent to the computer, and the computer will not know whether or not the last packet was processed correctly. Because of this, systems operating without the answer feature will need to run with delays between sending packets. Otherwise, packets will be ignored, but you will have no way of knowing that. To achieve this, there are two types of communication modes that this class will operate under - COMM_UNIDIRECTIONAL or COMM_BIDIRECTIONAL. The default is COMM_UNKNOWN, in which it will use bidirectional commuication if a response is received.

To handle the states and packet processing, this class runs as a user-task, different than the other pan/tilt devices. Because of this, it must have a valid robot connection and a valid serial connection if using a computer serial port. Note that the computer port must be set independently of this class. The aux port can be selected via setAuxPort from the ArPTZ class.

## Unit Conversions:

The camera's pan and tilt commands work on a number of units equal to (degrees / 0.1125). The panTilt function always rounds the conversion closer to zero, so that a magnitude greater than the allowable range of movement is not sent to the camera.

## C50i features:

NEW - There is now limited support for the night-mode version of the C50i. To enable night-mode support, pass the camera type in with the constructor. Night-mode consists of two parts - a phsyical IR-cutoff filter, and IR LEDs. The cutoff filter must be enabled first, then turn on the IR LEDs.

This camera has a digital zoom as well as the optical one. There is an additional function for handling the digital. There is also limited support for the auto-focus mechanism, which may need to be elaborated on for better night-vision. In addition to the focus, there are also gain and backlight adjustments that can be made, but are not yet implemented in this class.

## 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 | canGetFOV (void)
virtual bool | canGetRealPanTilt (void) const
virtual bool | canGetRealZoom (void) const
virtual bool | canSetFocus (void) const
virtual bool | canZoom (void) const
virtual void | connectHandler (void)
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)
double | getDigitalZoom (void) const
virtual double | getFOVAtMaxZoom (void)
| Gets the field of view at maximum zoom.
virtual double | getFOVAtMinZoom (void)
| Gets the field of view at minimum zoom.
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 double | getMaxNegPan (void) const
virtual double | getMaxNegTilt (void) const
double | getMaxPanSlew (void)
| Gets the maximum pan slew.
virtual double | getMaxPosPan (void) const
virtual double | getMaxPosTilt (void) const
double | getMaxTiltSlew (void)
| Gets the maximum tilt slew.
virtual int | getMaxZoom (void) const
double | getMinPanSlew (void)
| Gets the minimum pan slew.
double | getMinTiltSlew (void)
| Gets the minimum tilt slew.
virtual int | getMinZoom (void) const
virtual double | getPan (void) const
double | getPanSlew (void)
| Gets the current pan slew.
bool | getPower (void)
void | getRealPanTilt (void)
void | getRealZoomPos (void)
virtual double | getTilt (void) const
double | getTiltSlew (void)
| Gets the current tilt slew.
virtual int | getZoom (void) const
bool | haltPanTilt (void)
| Halts all pan-tilt movement.
bool | haltZoom (void)
| Halts zoom movement.
virtual bool | init (void)
bool | isInitted (void)
| Returns true if the camera has been initialized.
virtual bool | packetHandler (ArBasePacket *packet)
virtual bool | pan (double deg)
virtual bool | panRel (double deg)
bool | panSlew (double deg)
| Sets the rate that the unit pans at.
virtual bool | panTilt (double pdeg, double tdeg)
virtual bool | panTiltRel (double pdeg, double tdeg)
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.
virtual void | reset (void)
void | setLEDControlMode (int controlMode)
virtual bool | tilt (double deg)
virtual bool | tiltRel (double deg)
bool | tiltSlew (double 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)
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)
double | invert (double before) const
void | processGetPanTiltResponse (void)
void | processGetProductNameResponse (void)
void | processGetZoomResponse (void)
virtual ArBasePacket * | readPacket (void)
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
ArDeviceConnection * | myConn
bool | myDesiredIRFilterMode
bool | myDesiredIRLEDsMode
int | myDesiredLEDControlMode
int | myDigitalZoom
int | myDigitalZoomDesired
unsigned int | myError
std::list< ArFunctor * > | myErrorCBList
int | myFocusMode
int | myFocusModeDesired
double | myFOVAtMaxZoom
double | myFOVAtMinZoom
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
double | myPan
double | myPanDesired
double | myPanResponse
double | myPanSent
double | myPanSlew
double | myPanSlewDesired
double | myPanSlewSent
bool | myPowerState
bool | myPowerStateDesired
State | myPreviousState
std::string | myProductName
char | myProductNameResponse [4]
bool | myRealPanTiltRequested
bool | myRealZoomRequested
bool | myRequestProductName
bool | myResponseReceived
ArRobot * | myRobot
State | myState
int | myStateDelayTime
ArTime | myStateTime
int | myStateTimeout
ArFunctorC< ArVCC4 > | myTaskCB
double | myTilt
double | myTiltDesired
double | myTiltResponse
double | myTiltSent
double | myTiltSlew
double | myTiltSlewDesired
double | myTiltSlewSent
bool | myUsingAuxPort
bool | myWaitingOnPacket
bool | myWaitingOnStop
bool | myWasError
int | myZoom
int | myZoomDesired
int | myZoomResponse
int | myZoomSent
ArBasePacket * | newPacket

## Member Enumeration Documentation

enum ArVCC4::Error`[protected]`

Enumerator:

  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.

## 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.

virtual bool ArVCC4::autoFocus | ( | void |  | ) | `[inline, virtual]`

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

bool ArVCC4::digitalZoom | ( | int | deg | ) |

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

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. getPan() and getTilt() will then return this information instead of your last requested values.

void ArVCC4::getRealZoomPos | ( | void |  | ) | `[inline]`

Requests that a packet be sent to the camera to retrieve what the camera thinks is its zoom position. getZoom() will then return this information instead of your last requested value.

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

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

- ArVCC4.h