ViSP  2.6.2
vpSimulatorAfma6.h
1 /****************************************************************************
2  *
3  * $Id: vpSimulatorAfma6.h 2598 2010-06-02 09:20:22Z nmelchio $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 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 Afma6.
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
42 #ifndef vpSimulatorAfma6_HH
43 #define vpSimulatorAfma6_HH
44 
50 #include <visp/vpRobotSimulator.h>
51 #include <visp/vpAfma6.h>
52 
53 #include <string>
54 
55 #if defined(WIN32) || defined(VISP_HAVE_PTHREAD)
56 
177 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotSimulator, 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  vpSimulatorAfma6(bool display);
197  virtual ~vpSimulatorAfma6();
198 
200 
202 
204  const unsigned int &image_width,
205  const unsigned int &image_height);
207  const vpImage<unsigned char> &I);
209  void setCameraParameters(const vpCameraParameters cam) ;
210 
211  void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity);
214 
215  void setPositioningVelocity (const double velocity) {positioningVelocity = velocity;}
216  void setPosition(const vpRobot::vpControlFrameType frame,const vpColVector &q);
217  void setPosition (const vpRobot::vpControlFrameType frame,
218  const double pos1,
219  const double pos2,
220  const double pos3,
221  const double pos4,
222  const double pos5,
223  const double pos6);
224  void setPosition(const char *filename);
225  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint=NULL, const double &errMax = 0.001);
226 
227  void setJointLimit(vpColVector limitMin, vpColVector limitMax);
228 
229  double getPositioningVelocity (void){return positioningVelocity;}
230 
232  void getPosition (const vpRobot::vpControlFrameType frame,
233  vpPoseVector &position);
234 
235  void getCameraDisplacement(vpColVector &displacement);
236  void getArticularDisplacement(vpColVector &displacement);
238  vpColVector &displacement);
239 
240  static bool readPosFile(const char *filename, vpColVector &q);
241  static bool savePosFile(const char *filename, const vpColVector &q);
242  void move(const char *filename) ;
243 
244  void get_cMe(vpHomogeneousMatrix &cMe);
245  void get_cVe(vpVelocityTwistMatrix &cVe);
246  void get_eJe(vpMatrix &eJe);
247  void get_fJe(vpMatrix &fJe);
248 
249  void stopMotion();
250 
251  void initialiseCameraRelativeToObject(vpHomogeneousMatrix cMo);
252  void initialiseObjectRelativeToCamera(vpHomogeneousMatrix cMo);
253 
254  protected:
257  void findHighestPositioningSpeed(vpColVector &q);
258  void init();
259  bool singularityTest(const vpColVector q, vpMatrix &J);
260  int isInJointLimit (void);
261 
262  void initDisplay();
263  void initArms();
265 
266  inline void get_fMi(vpHomogeneousMatrix *fMit) {
267  #if defined(WIN32)
268  WaitForSingleObject(mutex_fMi,INFINITE);
269  for (int i = 0; i < 8; i++)
270  fMit[i] = fMi[i];
271  ReleaseMutex(mutex_fMi);
272  #elif defined(VISP_HAVE_PTHREAD)
273  pthread_mutex_lock (&mutex_fMi);
274  for (int i = 0; i < 8; i++)
275  fMit[i] = fMi[i];
276  pthread_mutex_unlock (&mutex_fMi);
277  #endif
278  }
279 
280  void compute_fMi();
281 };
282 
283 #endif
284 
285 #endif
Modelisation of Irisa's gantry robot named Afma6.
Definition: vpAfma6.h:69
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
virtual void getCameraDisplacement(vpColVector &v)=0
Perspective projection without distortion model.
virtual void updateArticularPosition()=0
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void get_cVe(vpVelocityTwistMatrix &cVe)
Definition: vpAfma6.cpp:860
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height)
Definition: vpAfma6.cpp:1226
virtual void computeArticularVelocity()=0
virtual void getArticularDisplacement(vpColVector &qdot)=0
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpAfma6.h:108
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
void setPositioningVelocity(const double velocity)
vpControlFrameType
Definition: vpRobot.h:83
virtual void initArms()=0
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:152
void get_cMe(vpHomogeneousMatrix &cMe)
Definition: vpAfma6.cpp:845
This class aims to be a basis used to create all the simulators of robots.
void get_eJe(const vpColVector &q, vpMatrix &eJe)
Definition: vpAfma6.cpp:883
vpRobotStateType
Definition: vpRobot.h:66
virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get the robot position (frame has to be specified).
Generic class defining intrinsic camera parameters.
Simulator of Irisa's gantry robot named Afma6.
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
vpColVector velocity
virtual void setVelocity(const vpRobot::vpControlFrameType, const vpColVector &)=0
virtual int isInJointLimit()=0
double getPositioningVelocity(void)
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
void get_fJe(const vpColVector &q, vpMatrix &fJe)
Definition: vpAfma6.cpp:950
void init(void)
Definition: vpAfma6.cpp:196
void get_fMi(vpHomogeneousMatrix *fMit)
void getExternalImage(vpImage< vpRGBa > &I)
virtual void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0