Aria
2.8.0
|
Control the pan, tilt, and zoom mechanisms of the Canon VC-C4 and VC-C50i cameras. More...
#include <ArVCC4.h>
Inherits ArPTZ.
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) |
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. More... | |
ArVCC4 (ArRobot *robot, bool inverted=false, CommState commDirection=COMM_UNKNOWN, bool autoUpdate=true, bool disableLED=false, CameraType cameraType=CAMERA_VCC4) | |
Constructor. More... | |
virtual bool | autoFocus (void) |
Set autofocus mode: 0 = Autofocus, 1 = manual focus. | |
virtual bool | canGetFOV (void) |
virtual bool | canGetRealPanTilt (void) const |
virtual bool | canGetRealZoom (void) const |
virtual bool | canSetFocus (void) const |
bool | canSetPanTiltSlew () |
virtual bool | canZoom (void) const |
virtual void | connectHandler (void) |
bool | digitalZoom (int deg) |
adjust the digital zoom amount. More... | |
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. | |
double | getMaxPanSlew (void) |
Gets the maximum pan slew. | |
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 |
double | getPanSlew (void) |
Gets the current pan slew. | |
bool | getPower (void) |
void | getRealPanTilt (void) |
Requests that a packet be sent to the camera to retrieve what the camera thinks are its pan/tilt positions. More... | |
void | getRealZoomPos (void) |
Requests that a packet be sent to the camera to retrieve what the camera thinks is its zoom position. More... | |
double | getTiltSlew (void) |
Gets the current tilt slew. | |
virtual const char * | getTypeName () |
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) |
bool | panSlew (double deg) |
Sets the rate that the unit pans at. | |
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) |
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. | |
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. | |
Public Member Functions inherited from ArPTZ | |
ArPTZ (ArRobot *robot) | |
virtual bool | canPanTiltSlew () |
Can pan and tilt speed (slew rates) be set to move device? | |
virtual bool | canSetGain (void) const |
If the driver can set gain on the camera, or not. | |
virtual int | getAuxPort (void) |
Gets the port the device is set to communicate on. | |
virtual ArDeviceConnection * | getDeviceConnection (void) |
Gets the device connection used by this PTZ camera. | |
virtual double | getFocus (double focus) const |
Get the focus the camera is set to. 0 if not supported. | |
virtual double | getGain (double gain) const |
Get the gain the camera is set to. 0 if not supported. | |
bool | getInverted () |
Get whether the camera is inverted (upside down). If true, pan and tilt axes will be reversed. | |
virtual double | getMaxNegPan (void) const |
Gets the lowest negative degree the camera can pan to (inverted if camera is inverted) | |
virtual double | getMaxNegTilt (void) const |
Gets the lowest negative degree the camera can tilt to (inverted if camera is inverted) | |
double | getMaxPan () const |
Gets the highest positive degree the camera can pan to (inverted if camera is inverted) More... | |
virtual double | getMaxPosPan (void) const |
Gets the highest positive degree the camera can pan to (inverted if camera is inverted) | |
virtual double | getMaxPosTilt (void) const |
Gets the highest positive degree the camera can tilt to (inverted if camera is inverted) | |
double | getMaxTilt () const |
Gets the highest positive degree the camera can tilt to (inverted if camera is inverted) More... | |
double | getMinPan () const |
Gets the lowest negative degree the camera can pan to (inverted if camera is inverted) More... | |
double | getMinTilt () const |
Gets the lowest negative degree the camera can tilt to (inverted if camera is inverted) More... | |
virtual double | getPan (void) const |
The angle the camera is panned to (or last commanded value sent, if unable to obtain real pan position) More... | |
ArRobot * | getRobot () |
Return ArRobot object this PTZ is associated with. May be NULL. | |
virtual double | getTilt (void) const |
The angle the camera is tilted to (or last commanded value sent, if unable to obtain real pan position) More... | |
virtual bool | pan (double degrees) |
Pans to the given degrees. 0 is straight ahead, - is to the left, + to the right. | |
virtual bool | panRel (double degrees) |
Pans relative to current position by given degrees. | |
virtual bool | panTilt (double degreesPan, double degreesTilt) |
Pans and tilts to the given degrees. | |
virtual bool | panTiltRel (double degreesPan, double degreesTilt) |
Pans and tilts relatives to the current position by the given degrees. | |
virtual bool | robotPacketHandler (ArRobotPacket *packet) |
Handles a packet that was read by the robot. More... | |
virtual bool | sendPacket (ArBasePacket *packet) |
Sends a given packet to the camera (via robot or serial port, depending) More... | |
virtual void | sensorInterpHandler (void) |
Internal, for attaching to the robots sensor interp to read serial port. | |
virtual bool | setAuxPort (int auxPort) |
Sets the aux port on the robot to be used to communicate with this device. More... | |
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 aux. More... | |
virtual bool | setFocus (double focus) const |
Set focus on camera, range of 1-100. More... | |
virtual bool | setGain (double gain) const |
Set gain on camera, range of 1-100. More... | |
void | setInverted (bool inv) |
Set whether the camera is inverted (upside down). If true, pan and tilt axes will be reversed. | |
virtual bool | tilt (double degrees) |
Tilts to the given degrees. 0 is middle, - is downward, + is upwards. | |
virtual bool | tiltRel (double degrees) |
Tilts relative to the current position by given degrees. | |
virtual bool | zoomRel (int zoomValue) |
Zooms relative to the current value, by the given value. | |
virtual | ~ArPTZ () |
Destructor. | |
Static Public Member Functions | |
static void | registerPTZType () |
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) |
virtual double | getPan_i (void) const |
virtual double | getTilt_i (void) const |
virtual bool | pan_i (double deg) |
virtual bool | panRel_i (double deg) |
virtual bool | panTilt_i (double pdeg, double tdeg) |
virtual bool | panTiltRel_i (double pdeg, double tdeg) |
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) |
This controls the status of the LED. More... | |
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 () |
virtual bool | tilt_i (double deg) |
virtual bool | tiltRel_i (double deg) |
bool | timeout (int mSec=0) |
Protected Member Functions inherited from ArPTZ | |
void | setLimits (double maxPosPan, double maxNegPan, double maxPosTilt, double maxNegTilt, int maxZoom=0, int minZoom=0) |
Subclasses call this to set extents (limits) returned by getMaxPosPan(), getMaxNegPan(), getMaxPosTilt(), getMaxNegTilt(), getMaxZoom(), and getMinZoom(). More... | |
virtual double | getMaxPosPan_i (void) const |
Versions of the pan and tilt limit accessors where inversion is not applied, for use by subclasses to check when given pan/tilt commands. More... | |
double | getMaxPan_i () const |
virtual double | getMaxPosTilt_i (void) const |
double | getMinPan_i () const |
virtual double | getMaxNegPan_i (void) const |
double | getMaxTilt_i () const |
virtual double | getMaxNegTilt_i (void) const |
double | getMinTilt_i () const |
Static Protected Member Functions | |
static ArPTZ * | create (size_t index, ArPTZParams params, ArArgumentParser *parser, ArRobot *robot) |
Used by ArPTZConnector to create an ArVCC4 object based on robot parameters and program options. More... | |
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 | 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 |
Protected Attributes inherited from ArPTZ | |
int | myAuxPort |
ArCommands::Commands | myAuxRxCmd |
ArCommands::Commands | myAuxTxCmd |
ArDeviceConnection * | myConn |
ArFunctorC< ArPTZ > | myConnectCB |
bool | myInverted |
double | myMaxNegPan |
double | myMaxNegTilt |
double | myMaxPosPan |
double | myMaxPosTilt |
int | myMaxZoom |
int | myMinZoom |
ArRobot * | myRobot |
ArRetFunctor1C< bool, ArPTZ, ArRobotPacket * > | myRobotPacketHandlerCB |
ArFunctorC< ArPTZ > | mySensorInterpCB |
Static Protected Attributes | |
static ArPTZConnector::GlobalPTZCreateFunc | ourCreateFunc |
Used by ArPTZConnector to create an ArVCC4 object based on robot parameters and program options. More... | |
Control the pan, tilt, and zoom mechanisms of the Canon VC-C4 and VC-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.
Programmer's manuals for the VC-C45 and VC-C50i, detailing the communications protocol (including commands not implemented by ArVCC4), as well as user manuals containing specifications and hardware information, are available at http://robots.mobilerobots.com. ArVCC4 sends commands to the camera using the ArVCC4Packet class to construct the command, and using either the ArRobot pointer or an internal ArDeviceConnection, depending on whether the camera is connected to the robot microcontroller's auxilliary serial port (the usual connection method for most robots) or a computer serial port.
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.
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.
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.
|
protected |
ArVCC4::ArVCC4 | ( | ArRobot * | robot, |
bool | inverted = false , |
||
CommState | commDirection = COMM_UNKNOWN , |
||
bool | autoUpdate = true , |
||
bool | disableLED = false , |
||
CameraType | cameraType = CAMERA_VCC4 |
||
) |
Constructor.
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. |
autoUpdate | 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 |
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.
|
staticprotected |
Used by ArPTZConnector to create an ArVCC4 object based on robot parameters and program options.
bool ArVCC4::digitalZoom | ( | int | deg | ) |
adjust the digital zoom amount.
Has four states, takes 0-3 for: 1x, 2x, 4x, 8x
|
inline |
|
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.
|
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
|
staticprotected |
Used by ArPTZConnector to create an ArVCC4 object based on robot parameters and program options.