ViSP  2.8.0

#include <vpServolens.h>

Public Types

enum  vpServoType { ZOOM = 1, FOCUS = 2, IRIS = 3 }
 
enum  vpLimitsType {
  ZOOM_MAX = 10000, ZOOM_MIN = 1000, FOCUS_MAX = 1500, FOCUS_MIN = 100,
  IRIS_MAX = 1000, IRIS_MIN = 160
}
 
enum  vpControllerType { AUTO = 1, CONTROLLED = 2, RELEASED = 3 }
 

Public Member Functions

 vpServolens ()
 
 vpServolens (const char *port)
 
 ~vpServolens ()
 
void open (const char *port="/dev/ttyS0")
 
void close ()
 
void reset ()
 
void setController (vpControllerType controller)
 
void setAutoIris (bool enable)
 
void setPosition (vpServoType servo, unsigned int position)
 
bool getPosition (vpServoType servo, unsigned int &position)
 
vpCameraParameters getCameraParameters (vpImage< unsigned char > &I)
 
void enablePrompt (bool active)
 

Detailed Description

Interface for the Servolens lens attached to the camera fixed on the Afma4 robot.

The code below shows how to manipulate this class to get and modify the position of the focal lens.

#include <iostream>
#include <visp/vpServolens.h>
int main()
{
// Open the serial device to communicate with the Servolens lens
vpServolens servolens("/dev/ttyS0");
// Get the current zoom position
unsigned zoom;
servolens.getPosition(vpServolens::ZOOM, zoom);
std::cout << "Actual zoom value: " << zoom << std::endl;
// Set a new zoom value
servolens.setPosition(vpServolens::ZOOM, zoom+1000);
}

Definition at line 95 of file vpServolens.h.

Member Enumeration Documentation

Enumerator
AUTO 
CONTROLLED 
RELEASED 

Definition at line 111 of file vpServolens.h.

Enumerator
ZOOM_MAX 
ZOOM_MIN 
FOCUS_MAX 
FOCUS_MIN 
IRIS_MAX 
IRIS_MIN 

Definition at line 103 of file vpServolens.h.

Enumerator
ZOOM 
FOCUS 
IRIS 

Definition at line 98 of file vpServolens.h.

Constructor & Destructor Documentation

vpServolens::vpServolens ( )

Default constructor. Does nothing.

See also
open()

Definition at line 74 of file vpServolens.cpp.

vpServolens::vpServolens ( const char *  port)

Open and initialize the Servolens serial link at 9600 bauds, 7 data bits, even parity, 1 stop bit. The cariage return mode is not active, that means that each character is directly read without waitong for a cariage return.

See also
open()

Definition at line 87 of file vpServolens.cpp.

References open().

vpServolens::~vpServolens ( )

Destructor.

Close the Servolens serial link.

See also
close()

Definition at line 101 of file vpServolens.cpp.

References close().

Member Function Documentation

void vpServolens::close ( )

Close the Servolens serial link.

See also
open()

Definition at line 197 of file vpServolens.cpp.

Referenced by open(), and ~vpServolens().

void vpServolens::enablePrompt ( bool  active)

Enable or disable the emission of the Servolens prompt "SERVOLENS>".

Parameters
active: true to activate the emission of the prompy. false to disable this functionality.
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 334 of file vpServolens.cpp.

References vpRobotException::communicationError, and vpERROR_TRACE.

vpCameraParameters vpServolens::getCameraParameters ( vpImage< unsigned char > &  I)

These parameters are computed from the Dragonfly2 DR2-COL camera sensor pixel size (7.4 um) and from the servolens zoom position.

Parameters
I: An image coming from the Dragonfly2 camera attached to the servolens.
#include <visp/vpServolens.h>
int main()
{
#ifdef UNIX
vpServolens servolens("/dev/ttyS0");
vpCameraParameters cam = servolens.getCameraParameters(I);
std::cout << "Camera parameters: " << cam << std::endl;
#endif
}
\exception vpRobotException::communicationError : If cannot dial
with Servolens.

Definition at line 652 of file vpServolens.cpp.

References vpRobotException::communicationError, vpImage< Type >::getHeight(), getPosition(), vpImage< Type >::getWidth(), vpCameraParameters::initPersProjWithoutDistortion(), vpERROR_TRACE, and ZOOM.

bool vpServolens::getPosition ( vpServoType  servo,
unsigned int &  position 
)

Get the Servolens current servo position.

Parameters
servo: Servolens servo motor to actuate.
position: Measured position of the servo.
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 514 of file vpServolens.cpp.

References vpRobotException::communicationError, FOCUS, IRIS, vpERROR_TRACE, and ZOOM.

Referenced by getCameraParameters(), and open().

void vpServolens::open ( const char *  port = "/dev/ttyS0")

Open and initialize the Servolens serial link at 9600 bauds, 7 data bits, even parity, 1 stop bit. The cariage return mode is not active, that means that each character is directly read without waitong for a cariage return.

Parameters
port: Serial device like /dev/ttyS0 or /dev/ttya.
Exceptions
vpRobotException::communicationError: If cannot open Servolens serial port or intialize the serial link.
See also
close()

Definition at line 121 of file vpServolens.cpp.

References close(), vpRobotException::communicationError, getPosition(), vpERROR_TRACE, and ZOOM.

Referenced by vpServolens().

void vpServolens::reset ( )

Reset the Servolens.

Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 213 of file vpServolens.cpp.

References vpRobotException::communicationError, vpERROR_TRACE, and vpTime::wait().

void vpServolens::setAutoIris ( bool  enable)

Activates the auto iris mode of the Servolens.

Parameters
enable: true to activate the auto iris.

Definition at line 402 of file vpServolens.cpp.

References vpRobotException::communicationError, and vpERROR_TRACE.

void vpServolens::setController ( vpControllerType  controller)

Set the controller type.

Parameters
controller: Controller type.
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 361 of file vpServolens.cpp.

References AUTO, vpRobotException::communicationError, CONTROLLED, RELEASED, and vpERROR_TRACE.

void vpServolens::setPosition ( vpServoType  servo,
unsigned int  position 
)

Set the Servolens servo to the desired position.

Parameters
servo: Servolens servo motor to actuate.
position: Desired position of the servo.
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 430 of file vpServolens.cpp.

References vpRobotException::communicationError, FOCUS, FOCUS_MAX, IRIS, IRIS_MAX, vpERROR_TRACE, ZOOM, and ZOOM_MIN.