Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpServolens.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Interface for the Servolens lens attached to the camera fixed on the
33  * Afma4 robot.
34  *
35 *****************************************************************************/
36 
46 #ifndef _vpServolens_h_
47 #define _vpServolens_h_
48 
49 #include <visp3/core/vpConfig.h>
50 
51 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
52 
53 #include <visp3/core/vpCameraParameters.h>
54 #include <visp3/core/vpConfig.h>
55 #include <visp3/core/vpImage.h>
56 
57 BEGIN_VISP_NAMESPACE
94 class VISP_EXPORT vpServolens
95 {
96 public:
97  typedef enum { ZOOM = 1, FOCUS = 2, IRIS = 3 } vpServoType;
98  typedef enum
99  {
100  ZOOM_MAX = 10000, // Valeur maxi zoom (mm/100)
101  ZOOM_MIN = 1000, // Valeur mini zoom (mm/100)
102  FOCUS_MAX = 1500, // Valeur maxi focus (metres/100)
103  FOCUS_MIN = 100, // Valeur mini focus (metres/100)
104  IRIS_MAX = 1000, // Valeur maxi diaph (ouverture/100)
105  IRIS_MIN = 160 // Valeur mini disph (ouverture/100)
106  } vpLimitsType;
107  typedef enum { AUTO = 1, CONTROLLED = 2, RELEASED = 3 } vpControllerType;
108 
109  vpServolens();
110  VP_EXPLICIT vpServolens(const char *port);
111  virtual ~vpServolens();
112 
113  void open(const char *port = "/dev/ttyS0");
114  void close();
115  void reset() const;
116 
117  void setController(vpControllerType controller) const;
118  void setAutoIris(bool enable) const;
119  void setPosition(vpServoType servo, unsigned int position) const;
120  bool getPosition(vpServoType servo, unsigned int &position) const;
121  vpCameraParameters getCameraParameters(vpImage<unsigned char> &I) const;
122 
123  void enablePrompt(bool active) const;
124 
125 private:
126  void init() const;
127 
128  char wait() const;
129  void wait(vpServoType servo) const;
130 
131  bool read(char *c, long timeout_s) const;
132  void write(const char *s) const;
133 
134  bool clean(const char *in, char *out) const;
135 
136  int remfd; // file pointer of the host's tty
137  bool isinit;
138 };
139 END_VISP_NAMESPACE
140 #endif
141 #endif
Generic class defining intrinsic camera parameters.
VISP_EXPORT int wait(double t0, double t)