Visual Servoing Platform  version 3.1.0
vpSimulatorViper850.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 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 
202 class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpViper850
203 {
204 public:
205  static const double defaultPositioningVelocity;
206 
207 private:
208  vpColVector q_prev_getdis;
209  bool first_time_getdis;
210 
211  double positioningVelocity;
212 
213  vpColVector zeroPos;
214  vpColVector reposPos;
215 
216  bool toolCustom;
217  std::string arm_dir;
218 
219 public:
221  explicit vpSimulatorViper850(bool display);
222  virtual ~vpSimulatorViper850();
223 
224  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
227 
228  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement);
229 
231  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
232  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
233  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
234  double getPositioningVelocity(void) { return positioningVelocity; }
235 
236  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
237  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
238  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
239  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
240 
241  void get_cMe(vpHomogeneousMatrix &cMe);
242  void get_cVe(vpVelocityTwistMatrix &cVe);
243  void get_eJe(vpMatrix &eJe);
244  void get_fJe(vpMatrix &fJe);
245 
246  void
249  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
250  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
251 
252  void move(const char *filename);
253 
254  static bool readPosFile(const std::string &filename, vpColVector &q);
255  static bool savePosFile(const std::string &filename, const vpColVector &q);
256 
257  void setCameraParameters(const vpCameraParameters &cam);
258  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
259  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q);
260  void setPosition(const vpRobot::vpControlFrameType frame, const double pos1, const double pos2, const double pos3,
261  const double pos4, const double pos5, const double pos6);
262  void setPosition(const char *filename);
263  void setPositioningVelocity(const double vel) { positioningVelocity = vel; }
265 
266  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity);
267 
268  void stopMotion();
269 
270 protected:
274  void compute_fMi();
275  void findHighestPositioningSpeed(vpColVector &q);
277 
278  inline void get_fMi(vpHomogeneousMatrix *fMit)
279  {
280 #if defined(_WIN32)
281 #if defined(WINRT_8_1)
282  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
283 #else // pure win32
284  WaitForSingleObject(mutex_fMi, INFINITE);
285 #endif
286  for (int i = 0; i < 8; i++)
287  fMit[i] = fMi[i];
288  ReleaseMutex(mutex_fMi);
289 #elif defined(VISP_HAVE_PTHREAD)
290  pthread_mutex_lock(&mutex_fMi);
291  for (int i = 0; i < 8; i++)
292  fMit[i] = fMi[i];
293  pthread_mutex_unlock(&mutex_fMi);
294 #endif
295  }
296  void init();
297  void initArms();
298  void initDisplay();
299  int isInJointLimit(void);
300  bool singularityTest(const vpColVector &q, vpMatrix &J);
303 };
304 
305 #endif
306 
307 #endif
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)
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpViper850.cpp:540
Implementation of an homogeneous matrix and operations on such kind of matrices.
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 get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpViper.cpp:922
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.
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_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:938
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
static const double defaultPositioningVelocity
double getPositioningVelocity(void)