Visual Servoing Platform  version 3.1.0
vpRobotBiclopsController.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 http://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 Biclops robot.
33  *
34  * Authors:
35  * Fabien Spindler
36  *
37  *****************************************************************************/
38 
39 #include <visp3/core/vpConfig.h>
40 
41 #ifndef DOXYGEN_SHOULD_SKIP_THIS
42 #ifdef VISP_HAVE_BICLOPS
43 
44 #ifndef __vpROBOT_BICLOPS_CONTROLLER_H
45 #define __vpROBOT_BICLOPS_CONTROLLER_H
46 
47 /* ------------------------------------------------------------------------ */
48 /* --- INCLUDES ----------------------------------------------------------- */
49 /* ------------------------------------------------------------------------ */
50 
51 /* --- GENERAL --- */
52 #include <iostream> /* Classe std::ostream. */
53 #include <pthread.h> /* Classe std::ostream. */
54 #include <stdio.h> /* Classe std::ostream. */
55 
56 #include <visp3/core/vpConfig.h>
57 
58 #include "Biclops.h" // Contrib for Biclops robot
59 #include "PMDUtils.h" // Contrib for Biclops robot
60 
61 #if defined(_WIN32)
62 class VISP_EXPORT Biclops; // needed for dll creation
63 #endif
64 
65 /* ------------------------------------------------------------------------ */
66 /* --- CLASS ------------------------------------------------------------- */
67 /* ------------------------------------------------------------------------ */
68 
84 class VISP_EXPORT vpRobotBiclopsController
85 {
86 public:
87  typedef enum {
88  STOP,
89  SPEED
90  } vpControllerStatusType;
91 
92 public:
93 #ifndef DOXYGEN_SHOULD_SKIP_THIS
94  // SHM
95  typedef struct /* ControllerShm_struct */ {
96  vpControllerStatusType status[2];
97  double q_dot[2];
98  double actual_q[2];
99  double actual_q_dot[2];
100  bool jointLimit[2];
101  } shmType;
102 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
103 
104  // private:
105  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
106  // vpRobotBiclopsController(const vpRobotBiclopsController &)
107  // : biclops(), axisMask(0), panAxis(NULL), tiltAxis(NULL),
108  // vergeAxis(NULL),
109  // panProfile(), tiltProfile(), vergeProfile(), shm(),
110  // stopControllerThread_(false)
111  // {
112  // throw vpException(vpException::functionNotImplementedError, "Not
113  // implemented!");
114  // }
115  // vpRobotBiclopsController &operator=(const vpRobotBiclopsController &){
116  // throw vpException(vpException::functionNotImplementedError, "Not
117  // implemented!"); return *this;
118  // }
119  //#endif
120 
121 public:
122  vpRobotBiclopsController();
123  virtual ~vpRobotBiclopsController();
124  void init(const std::string &configfile);
125  void setPosition(const vpColVector &q, const double percentVelocity);
126  void setVelocity(const vpColVector &q_dot);
127  vpColVector getPosition();
128  vpColVector getActualPosition();
129  vpColVector getVelocity();
130  vpColVector getActualVelocity();
131  PMDAxisControl *getPanAxis() { return panAxis; };
132  PMDAxisControl *getTiltAxis() { return tiltAxis; };
133  PMDAxisControl *getVergeAxis() { return vergeAxis; };
134  void writeShm(shmType &shm);
135  shmType readShm();
136  bool isStopRequested() { return stopControllerThread_; }
137 
138  void stopRequest(bool stop) { stopControllerThread_ = stop; }
139 
140 private:
141  Biclops biclops; // THE interface to Biclops.
142  int axisMask;
143 
144  // Pointers to each axis (populated once controller is initialized).
145  PMDAxisControl *panAxis;
146  PMDAxisControl *tiltAxis;
147  PMDAxisControl *vergeAxis;
148 
149  PMDAxisControl::Profile panProfile;
150  PMDAxisControl::Profile tiltProfile;
151  PMDAxisControl::Profile vergeProfile;
152 
153  shmType shm;
154  bool stopControllerThread_;
155 };
156 
157 #endif /* #ifndef __vpROBOT_BICLOPS_CONTROLLER_H */
158 
159 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
160 
161 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72