#include <ArVCC4.h>
Inheritance diagram for ArVCC4:
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.
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.
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 |
|
|
|
Constructor.
|
|
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. |
|
Set autofocus mode: 0 = Autofocus, 1 = manual focus |
|
adjust the digital zoom amount. Has four states, takes 0-3 for: 1x, 2x, 4x, 8x |
|
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. |
|
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. |
|
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 |
|
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 |