Visual Servoing Platform  version 3.6.1 under development (2024-10-01)
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 ()
 
VP_EXPLICIT vpServolens (const char *port)
 
virtual ~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>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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);
}
Interface for the Servolens lens attached to the camera fixed on the Afma4 robot.
Definition: vpServolens.h:95

Definition at line 94 of file vpServolens.h.

Member Enumeration Documentation

◆ vpControllerType

Enumerator
AUTO 
CONTROLLED 
RELEASED 

Definition at line 107 of file vpServolens.h.

◆ vpLimitsType

Enumerator
ZOOM_MAX 
ZOOM_MIN 
FOCUS_MAX 
FOCUS_MIN 
IRIS_MAX 
IRIS_MIN 

Definition at line 98 of file vpServolens.h.

◆ vpServoType

Enumerator
ZOOM 
FOCUS 
IRIS 

Definition at line 97 of file vpServolens.h.

Constructor & Destructor Documentation

◆ vpServolens() [1/2]

BEGIN_VISP_NAMESPACE vpServolens::vpServolens ( )

Default constructor. Does nothing.

See also
open()

Definition at line 69 of file vpServolens.cpp.

◆ vpServolens() [2/2]

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

References open().

◆ ~vpServolens()

vpServolens::~vpServolens ( )
virtual

Destructor.

Close the Servolens serial link.

See also
close()

Definition at line 88 of file vpServolens.cpp.

References close().

Member Function Documentation

◆ close()

void vpServolens::close ( )

Close the Servolens serial link.

See also
open()

Definition at line 176 of file vpServolens.cpp.

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

◆ enablePrompt()

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

References vpRobotException::communicationError, and vpERROR_TRACE.

◆ getCameraParameters()

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>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
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
}
Generic class defining intrinsic camera parameters.
Exceptions
vpRobotException::communicationError: If cannot dial with Servolens.

Definition at line 574 of file vpServolens.cpp.

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

◆ getPosition()

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

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

Referenced by getCameraParameters(), and open().

◆ 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 initialize the serial link.
See also
close()

Definition at line 104 of file vpServolens.cpp.

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

Referenced by vpServolens().

◆ reset()

void vpServolens::reset ( ) const

Reset the Servolens.

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

Definition at line 191 of file vpServolens.cpp.

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

◆ setAutoIris()

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

References vpRobotException::communicationError, and vpERROR_TRACE.

◆ setController()

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

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

◆ setPosition()

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

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