Visual Servoing Platform  version 3.2.0 under development (2019-01-22)
vpSimulatorViper850.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 Viper850.
33  *
34  * Authors:
35  * Nicolas Melchior
36  *
37  *****************************************************************************/
38 
39 #ifndef vpSimulatorViper850_HH
40 #define vpSimulatorViper850_HH
41 
47 #include <visp3/robot/vpRobotWireFrameSimulator.h>
48 #if defined(VISP_HAVE_MODULE_GUI) && ((defined(_WIN32) && !defined(WINRT_8_0)) || defined(VISP_HAVE_PTHREAD))
49 
50 #include <string>
51 
52 #include <visp3/robot/vpViper850.h>
53 
204 class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpViper850
205 {
206 public:
207  static const double defaultPositioningVelocity;
208 
209 private:
210  vpColVector q_prev_getdis;
211  bool first_time_getdis;
212 
213  double positioningVelocity;
214 
215  vpColVector zeroPos;
216  vpColVector reposPos;
217 
218  bool toolCustom;
219  std::string arm_dir;
220 
221 public:
223  explicit vpSimulatorViper850(bool display);
224  virtual ~vpSimulatorViper850();
225 
226  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
229 
230  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement);
231 
233  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
234  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
235  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
236  double getPositioningVelocity(void) { return positioningVelocity; }
237 
238  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
239  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
240  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
241  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
242 
243  void get_cMe(vpHomogeneousMatrix &cMe);
244  void get_cVe(vpVelocityTwistMatrix &cVe);
245  void get_eJe(vpMatrix &eJe);
246  void get_fJe(vpMatrix &fJe);
247 
248  void
251  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
252  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
253 
254  void move(const char *filename);
255 
256  static bool readPosFile(const std::string &filename, vpColVector &q);
257  static bool savePosFile(const std::string &filename, const vpColVector &q);
258 
259  void setCameraParameters(const vpCameraParameters &cam);
260  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
261  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q);
262  void setPosition(const vpRobot::vpControlFrameType frame, const double pos1, const double pos2, const double pos3,
263  const double pos4, const double pos5, const double pos6);
264  void setPosition(const char *filename);
265  void setPositioningVelocity(const double vel) { positioningVelocity = vel; }
267 
268  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity);
269 
270  void stopMotion();
271 
272 protected:
276  void compute_fMi();
277  void findHighestPositioningSpeed(vpColVector &q);
279 
280  inline void get_fMi(vpHomogeneousMatrix *fMit)
281  {
282 #if defined(_WIN32)
283 #if defined(WINRT_8_1)
284  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
285 #else // pure win32
286  WaitForSingleObject(mutex_fMi, INFINITE);
287 #endif
288  for (int i = 0; i < 8; i++)
289  fMit[i] = fMi[i];
290  ReleaseMutex(mutex_fMi);
291 #elif defined(VISP_HAVE_PTHREAD)
292  pthread_mutex_lock(&mutex_fMi);
293  for (int i = 0; i < 8; i++)
294  fMit[i] = fMi[i];
295  pthread_mutex_unlock(&mutex_fMi);
296 #endif
297  }
298  void init();
299  void initArms();
300  void initDisplay();
301  int isInJointLimit(void);
302  bool singularityTest(const vpColVector &q, vpMatrix &J);
305 };
306 
307 #endif
308 
309 #endif
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:938
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:104
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
void get_fMi(vpHomogeneousMatrix *fMit)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpViper850.cpp:540
virtual void initArms()=0
virtual void get_eJe(vpMatrix &_eJe)=0
Get the robot Jacobian expressed in the end-effector frame.
virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.
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).
vpToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpViper850.h:128
virtual void computeArticularVelocity()=0
Generic class defining intrinsic camera parameters.
virtual void get_fJe(vpMatrix &_fJe)=0
Modelisation of the ADEPT Viper 850 robot.
Definition: vpViper850.h:103
void getExternalImage(vpImage< unsigned char > &I)
void setPositioningVelocity(const double vel)
This class aims to be a basis used to create all the simulators of robots.
Simulator of Irisa&#39;s Viper S850 robot named Viper850.
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpViper.cpp:922
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
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
static const double defaultPositioningVelocity
double getPositioningVelocity(void)