ViSP  2.9.0
vpSimulatorViper850.h
1 /****************************************************************************
2  *
3  * $Id: vpSimulatorViper850.h 4649 2014-02-07 14:57:11Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Class which provides a simulator for the robot Viper850.
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
42 #ifndef vpSimulatorViper850_HH
43 #define vpSimulatorViper850_HH
44 
52 #include <visp/vpRobotWireFrameSimulator.h>
53 #include <visp/vpViper850.h>
54 #include <string>
55 #if defined(_WIN32) || defined(VISP_HAVE_PTHREAD)
56 
206 class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpViper850
207 {
208  public:
209  static const double defaultPositioningVelocity;
210 
211  private:
212  vpColVector q_prev_getdis;
213  bool first_time_getdis;
214 
215  double positioningVelocity;
216 
217  vpColVector zeroPos;
218  vpColVector reposPos;
219 
220  bool toolCustom;
221  std::string arm_dir;
222 
223  public:
225  vpSimulatorViper850(bool display);
226  virtual ~vpSimulatorViper850();
227 
229  const unsigned int &image_width,
230  const unsigned int &image_height);
232  const vpImage<unsigned char> &I);
234 
236  vpColVector &displacement);
237 
239  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
240  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
241  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
242  double getPositioningVelocity (void){return positioningVelocity;}
243 
244  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
245  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
246  vpColVector getVelocity (const vpRobot::vpControlFrameType frame);
247  vpColVector getVelocity (const vpRobot::vpControlFrameType frame, double &timestamp);
248 
249  void get_cMe(vpHomogeneousMatrix &cMe);
250  void get_cVe(vpVelocityTwistMatrix &cVe);
251  void get_eJe(vpMatrix &eJe);
252  void get_fJe(vpMatrix &fJe);
253 
255  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
256  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
257 
258  void move(const char *filename) ;
259 
260  static bool readPosFile(const char *filename, vpColVector &q);
261  static bool savePosFile(const char *filename, const vpColVector &q);
262 
263  void setCameraParameters(const vpCameraParameters &cam) ;
264  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
265  void setPosition(const vpRobot::vpControlFrameType frame,const vpColVector &q);
266  void setPosition (const vpRobot::vpControlFrameType frame,
267  const double pos1,
268  const double pos2,
269  const double pos3,
270  const double pos4,
271  const double pos5,
272  const double pos6);
273  void setPosition(const char *filename);
274  void setPositioningVelocity (const double vel) {positioningVelocity = vel;}
276 
277  void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity);
278 
279  void stopMotion();
280 
281 protected:
283  void compute_fMi();
284  void findHighestPositioningSpeed(vpColVector &q);
286 
287  inline void get_fMi(vpHomogeneousMatrix *fMit) {
288 #if defined(_WIN32)
289  WaitForSingleObject(mutex_fMi,INFINITE);
290  for (int i = 0; i < 8; i++)
291  fMit[i] = fMi[i];
292  ReleaseMutex(mutex_fMi);
293 #elif defined(VISP_HAVE_PTHREAD)
294  pthread_mutex_lock (&mutex_fMi);
295  for (int i = 0; i < 8; i++)
296  fMit[i] = fMi[i];
297  pthread_mutex_unlock (&mutex_fMi);
298 #endif
299  }
300  void init();
301  void initArms();
302  void initDisplay();
303  int isInJointLimit (void);
304  bool singularityTest(const vpColVector q, vpMatrix &J);
306 
307 private:
308  void getArticularDisplacement(vpColVector &displacement);
309  void getCameraDisplacement(vpColVector &displacement);
310 };
311 
312 #endif
313 
314 #endif
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:952
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
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.
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height) const
Definition: vpViper850.cpp:580
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:78
virtual int isInJointLimit()=0
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:190
vpRobotStateType
Definition: vpRobot.h:66
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:91
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:66
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
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:931
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
The pose is a complete representation of every rigid motion in the euclidian space.
Definition: vpPoseVector.h:92
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)