Visual Servoing Platform  version 3.4.0
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 
177 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vpAfma6
178 {
179 public:
180  static const double defaultPositioningVelocity;
181 
182 private:
183  vpColVector q_prev_getdis;
184  bool first_time_getdis;
185 
186  double positioningVelocity;
187 
188  vpColVector zeroPos;
189  vpColVector reposPos;
190 
191  bool toolCustom;
192  std::string arm_dir;
193 
194 public:
196  explicit vpSimulatorAfma6(bool display);
197  virtual ~vpSimulatorAfma6();
198 
199  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
202  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement);
204  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
205  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
206  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
207  double getPositioningVelocity(void) { return positioningVelocity; }
208  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
209  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
210  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
211  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
212 
213  void get_cMe(vpHomogeneousMatrix &cMe);
214  void get_cVe(vpVelocityTwistMatrix &cVe);
215  void get_eJe(vpMatrix &eJe);
216  void get_fJe(vpMatrix &fJe);
217 
218  void
221  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
222  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
223 
224  void move(const char *filename);
225 
226  static bool readPosFile(const std::string &filename, vpColVector &q);
227  static bool savePosFile(const std::string &filename, const vpColVector &q);
228  void setCameraParameters(const vpCameraParameters &cam);
229  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
230 
231  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q);
232  void setPosition(const vpRobot::vpControlFrameType frame, double pos1, double pos2, double pos3,
233  double pos4, double pos5, double pos6);
234  void setPosition(const char *filename);
235  void setPositioningVelocity(double vel) { positioningVelocity = vel; }
236  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint = NULL, const double &errMax = 0.001);
238 
239  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity);
240 
241  void stopMotion();
242 
243 protected:
247  void compute_fMi();
248  void findHighestPositioningSpeed(vpColVector &q);
250  inline void get_fMi(vpHomogeneousMatrix *fMit)
251  {
252 #if defined(_WIN32)
253 #if defined(WINRT_8_1)
254  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
255 #else // pure win32
256  WaitForSingleObject(mutex_fMi, INFINITE);
257 #endif
258  for (int i = 0; i < 8; i++)
259  fMit[i] = fMi[i];
260  ReleaseMutex(mutex_fMi);
261 #elif defined(VISP_HAVE_PTHREAD)
262  pthread_mutex_lock(&mutex_fMi);
263  for (int i = 0; i < 8; i++)
264  fMit[i] = fMi[i];
265  pthread_mutex_unlock(&mutex_fMi);
266 #endif
267  }
268  void init();
269  void initArms();
270  void initDisplay();
271  int isInJointLimit(void);
272  bool singularityTest(const vpColVector &q, vpMatrix &J);
275 };
276 
277 #endif
278 
279 #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:153
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpAfma6.cpp:1256
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpAfma6.cpp:910
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:932
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpAfma6.h:126
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:888
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:160
void setPositioningVelocity(double vel)
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:1002