Visual Servoing Platform  version 3.1.0
vpSimulatorAfma6.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  * 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 
176 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vpAfma6
177 {
178 public:
179  static const double defaultPositioningVelocity;
180 
181 private:
182  vpColVector q_prev_getdis;
183  bool first_time_getdis;
184 
185  double positioningVelocity;
186 
187  vpColVector zeroPos;
188  vpColVector reposPos;
189 
190  bool toolCustom;
191  std::string arm_dir;
192 
193 public:
195  explicit vpSimulatorAfma6(bool display);
196  virtual ~vpSimulatorAfma6();
197 
198  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
201  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement);
203  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
204  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
205  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
206  double getPositioningVelocity(void) { return positioningVelocity; }
207  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
208  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
209  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
210  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
211 
212  void get_cMe(vpHomogeneousMatrix &cMe);
213  void get_cVe(vpVelocityTwistMatrix &cVe);
214  void get_eJe(vpMatrix &eJe);
215  void get_fJe(vpMatrix &fJe);
216 
217  void
220  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
221  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
222 
223  void move(const char *filename);
224 
225  static bool readPosFile(const std::string &filename, vpColVector &q);
226  static bool savePosFile(const std::string &filename, const vpColVector &q);
227  void setCameraParameters(const vpCameraParameters &cam);
228  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
229 
230  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q);
231  void setPosition(const vpRobot::vpControlFrameType frame, const double pos1, const double pos2, const double pos3,
232  const double pos4, const double pos5, const double pos6);
233  void setPosition(const char *filename);
234  void setPositioningVelocity(const double vel) { positioningVelocity = vel; }
235  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint = NULL, const double &errMax = 0.001);
237 
238  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity);
239 
240  void stopMotion();
241 
242 protected:
246  void compute_fMi();
247  void findHighestPositioningSpeed(vpColVector &q);
249  inline void get_fMi(vpHomogeneousMatrix *fMit)
250  {
251 #if defined(_WIN32)
252 #if defined(WINRT_8_1)
253  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
254 #else // pure win32
255  WaitForSingleObject(mutex_fMi, INFINITE);
256 #endif
257  for (int i = 0; i < 8; i++)
258  fMit[i] = fMi[i];
259  ReleaseMutex(mutex_fMi);
260 #elif defined(VISP_HAVE_PTHREAD)
261  pthread_mutex_lock(&mutex_fMi);
262  for (int i = 0; i < 8; i++)
263  fMit[i] = fMi[i];
264  pthread_mutex_unlock(&mutex_fMi);
265 #endif
266  }
267  void init();
268  void initArms();
269  void initDisplay();
270  int isInJointLimit(void);
271  bool singularityTest(const vpColVector &q, vpMatrix &J);
274 };
275 
276 #endif
277 
278 #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:104
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpAfma6.cpp:1190
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_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpAfma6.cpp:842
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
virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get the robot position (frame has to be specified).
virtual void computeArticularVelocity()=0
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpAfma6.cpp:864
Generic class defining intrinsic camera parameters.
Simulator of Irisa&#39;s gantry robot named Afma6.
void getExternalImage(vpImage< unsigned char > &I)
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpAfma6.cpp:934
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:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:92
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpAfma6.cpp:820
void init(void)
Definition: vpAfma6.cpp:153
void get_fMi(vpHomogeneousMatrix *fMit)
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0