Visual Servoing Platform  version 3.2.0 under development (2018-10-19)
vpServolens Class Reference

#include <visp3/robot/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 () const
 
void setController (vpControllerType controller) const
 
void setAutoIris (bool enable) const
 
void setPosition (vpServoType servo, unsigned int position) const
 
bool getPosition (vpServoType servo, unsigned int &position) const
 
vpCameraParameters getCameraParameters (vpImage< unsigned char > &I) const
 
void enablePrompt (bool active) const
 

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 <visp3/vs/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 92 of file vpServolens.h.

Member Enumeration Documentation

Enumerator
AUTO 
CONTROLLED 
RELEASED 

Definition at line 104 of file vpServolens.h.

Enumerator
ZOOM_MAX 
ZOOM_MIN 
FOCUS_MAX 
FOCUS_MIN 
IRIS_MAX 
IRIS_MIN 

Definition at line 96 of file vpServolens.h.

Enumerator
ZOOM 
FOCUS 
IRIS 

Definition at line 95 of file vpServolens.h.

Constructor & Destructor Documentation

vpServolens::vpServolens ( )

Default constructor. Does nothing.

See also
open()

Definition at line 71 of file vpServolens.cpp.

vpServolens::vpServolens ( const char *  port)
explicit

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 81 of file vpServolens.cpp.

References open().

vpServolens::~vpServolens ( )

Destructor.

Close the Servolens serial link.

See also
close()

Definition at line 90 of file vpServolens.cpp.

References close().

Member Function Documentation

void vpServolens::close ( )

Close the Servolens serial link.

See also
open()

Definition at line 178 of file vpServolens.cpp.

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

void vpServolens::enablePrompt ( bool  active) const

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 260 of file vpServolens.cpp.

References vpRobotException::communicationError, and vpERROR_TRACE.

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

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 <visp3/vs/vpServolens.h>
int main()
{
// UNIX vpServolens servolens("/dev/ttyS0");
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
vpCameraParameters cam = servolens.getCameraParameters(I);
std::cout << "Camera parameters: " << cam << std::endl;
#endif
}
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 569 of file vpServolens.cpp.

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

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

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 434 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 106 of file vpServolens.cpp.

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

Referenced by vpServolens().

void vpServolens::reset ( ) const

Reset the Servolens.

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

Definition at line 193 of file vpServolens.cpp.

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

void vpServolens::setAutoIris ( bool  enable) const

Activates the auto iris mode of the Servolens.

Parameters
enable: true to activate the auto iris.

Definition at line 323 of file vpServolens.cpp.

References vpRobotException::communicationError, and vpERROR_TRACE.

void vpServolens::setController ( vpControllerType  controller) const

Set the controller type.

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

Definition at line 285 of file vpServolens.cpp.

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

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

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 349 of file vpServolens.cpp.

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