Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Class which provides a simulator for the robot Viper850.
32  *
33  * Authors:
34  * Nicolas Melchior
35  *
36  *****************************************************************************/
37 
38 #ifndef vpSimulatorViper850_HH
39 #define vpSimulatorViper850_HH
40 
46 #include <visp3/robot/vpRobotWireFrameSimulator.h>
47 #if defined(VISP_HAVE_MODULE_GUI) && ((defined(_WIN32) && !defined(WINRT_8_0)) || defined(VISP_HAVE_PTHREAD))
48 
49 #include <string>
50 
51 #include <visp3/robot/vpViper850.h>
52 
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  vpSimulatorViper850(bool display);
222  virtual ~vpSimulatorViper850();
223 
225  const unsigned int &image_width,
226  const unsigned int &image_height);
228  const vpImage<unsigned char> &I);
230 
232  vpColVector &displacement);
233 
235  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
236  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
237  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
238  double getPositioningVelocity (void){return positioningVelocity;}
239 
240  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
241  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
242  vpColVector getVelocity (const vpRobot::vpControlFrameType frame);
243  vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double &timestamp);
244 
245  void get_cMe(vpHomogeneousMatrix &cMe);
246  void get_cVe(vpVelocityTwistMatrix &cVe);
247  void get_eJe(vpMatrix &eJe);
248  void get_fJe(vpMatrix &fJe);
249 
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,
263  const double pos1,
264  const double pos2,
265  const double pos3,
266  const double pos4,
267  const double pos5,
268  const double pos6);
269  void setPosition(const char *filename);
270  void setPositioningVelocity (const double vel) {positioningVelocity = vel;}
272 
273  void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity);
274 
275  void stopMotion();
276 
277 protected:
281  void compute_fMi();
282  void findHighestPositioningSpeed(vpColVector &q);
284 
285  inline void get_fMi(vpHomogeneousMatrix *fMit) {
286 #if defined(_WIN32)
287 # if defined(WINRT_8_1)
288  WaitForSingleObjectEx(mutex_fMi, INFINITE, FALSE);
289 # else // pure win32
290  WaitForSingleObject(mutex_fMi, INFINITE);
291 # endif
292  for (int i = 0; i < 8; i++)
293  fMit[i] = fMi[i];
294  ReleaseMutex(mutex_fMi);
295 #elif defined(VISP_HAVE_PTHREAD)
296  pthread_mutex_lock (&mutex_fMi);
297  for (int i = 0; i < 8; i++)
298  fMit[i] = fMi[i];
299  pthread_mutex_unlock (&mutex_fMi);
300 #endif
301  }
302  void init();
303  void initArms();
304  void initDisplay();
305  int isInJointLimit (void);
306  bool singularityTest(const vpColVector q, vpMatrix &J);
309 
310 private:
311  void getArticularDisplacement(vpColVector &displacement);
312  void getCameraDisplacement(vpColVector &displacement);
313 };
314 
315 #endif
316 
317 #endif
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:969
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get a displacement (frame as to ve specified) between two successive position control.
void get_fMi(vpHomogeneousMatrix *fMit)
Perspective projection without distortion model.
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:564
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:76
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
Get the robot Jacobian expressed in the robot reference (or world) frame.
Modelisation of the ADEPT Viper 850 robot.
Definition: vpViper850.h:103
Implementation of a velocity twist matrix and operations on such kind of matrices.
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's Viper S850 robot named Viper850.
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpViper.cpp:948
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:93
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
Set the velocity (frame has to be specified) that will be applied to the velocity controller...
static const double defaultPositioningVelocity
double getPositioningVelocity(void)