Visual Servoing Platform  version 3.2.1 under development (2019-05-20)
vpSimulatorAfma6.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 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  * Class which provides a simulator for the robot Afma6.
33  *
34  * Authors:
35  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
39 #ifndef vpSimulatorAfma6_HH
40 #define vpSimulatorAfma6_HH
41 
47 #include <visp3/robot/vpAfma6.h>
48 #include <visp3/robot/vpRobotWireFrameSimulator.h>
49 
50 #include <string>
51 
52 #if defined(VISP_HAVE_MODULE_GUI) && ((defined(_WIN32) && !defined(WINRT_8_0)) || defined(VISP_HAVE_PTHREAD))
53 
178 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vpAfma6
179 {
180 public:
181  static const double defaultPositioningVelocity;
182 
183 private:
184  vpColVector q_prev_getdis;
185  bool first_time_getdis;
186 
187  double positioningVelocity;
188 
189  vpColVector zeroPos;
190  vpColVector reposPos;
191 
192  bool toolCustom;
193  std::string arm_dir;
194 
195 public:
197  explicit vpSimulatorAfma6(bool display);
198  virtual ~vpSimulatorAfma6();
199 
200  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
203  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement);
205  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
206  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
207  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
208  double getPositioningVelocity(void) { return positioningVelocity; }
209  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
210  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
211  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
212  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
213 
214  void get_cMe(vpHomogeneousMatrix &cMe);
215  void get_cVe(vpVelocityTwistMatrix &cVe);
216  void get_eJe(vpMatrix &eJe);
217  void get_fJe(vpMatrix &fJe);
218 
219  void
222  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
223  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
224 
225  void move(const char *filename);
226 
227  static bool readPosFile(const std::string &filename, vpColVector &q);
228  static bool savePosFile(const std::string &filename, const vpColVector &q);
229  void setCameraParameters(const vpCameraParameters &cam);
230  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
231 
232  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q);
233  void setPosition(const vpRobot::vpControlFrameType frame, const double pos1, const double pos2, const double pos3,
234  const double pos4, const double pos5, const double pos6);
235  void setPosition(const char *filename);
236  void setPositioningVelocity(const double vel) { positioningVelocity = vel; }
237  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint = NULL, const double &errMax = 0.001);
239 
240  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity);
241 
242  void stopMotion();
243 
244 protected:
248  void compute_fMi();
249  void findHighestPositioningSpeed(vpColVector &q);
251  inline void get_fMi(vpHomogeneousMatrix *fMit)
252  {
253 #if defined(_WIN32)
254 #if defined(WINRT_8_1)
255  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
256 #else // pure win32
257  WaitForSingleObject(mutex_fMi, INFINITE);
258 #endif
259  for (int i = 0; i < 8; i++)
260  fMit[i] = fMi[i];
261  ReleaseMutex(mutex_fMi);
262 #elif defined(VISP_HAVE_PTHREAD)
263  pthread_mutex_lock(&mutex_fMi);
264  for (int i = 0; i < 8; i++)
265  fMit[i] = fMi[i];
266  pthread_mutex_unlock(&mutex_fMi);
267 #endif
268  }
269  void init();
270  void initArms();
271  void initDisplay();
272  int isInJointLimit(void);
273  bool singularityTest(const vpColVector &q, vpMatrix &J);
276 };
277 
278 #endif
279 
280 #endif
Modelisation of Irisa&#39;s gantry robot named Afma6.
Definition: vpAfma6.h:78
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:164
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpAfma6.cpp:1190
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpAfma6.cpp:842
void setPositioningVelocity(const double vel)
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Implementation of an homogeneous matrix and operations on such kind of matrices.
virtual void initArms()=0
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpAfma6.cpp:864
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpAfma6.h:118
virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.
static const double defaultPositioningVelocity
vpControlFrameType
Definition: vpRobot.h:75
virtual int isInJointLimit()=0
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:201
vpRobotStateType
Definition: vpRobot.h:64
virtual void updateArticularPosition()=0
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpAfma6.cpp:820
virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get the robot position (frame has to be specified).
virtual void computeArticularVelocity()=0
Generic class defining intrinsic camera parameters.
Simulator of Irisa&#39;s gantry robot named Afma6.
void getExternalImage(vpImage< unsigned char > &I)
This class aims to be a basis used to create all the simulators of robots.
double getPositioningVelocity(void)
Implementation of column vector and the associated operations.
Definition: vpColVector.h:130
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:151
void init(void)
Definition: vpAfma6.cpp:153
void get_fMi(vpHomogeneousMatrix *fMit)
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpAfma6.cpp:934