ViSP  2.8.0
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 - 2013 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/vpRobotWireFrameSimulator.h>
51 #include <visp/vpAfma6.h>
52 
53 #include <string>
54 
55 #if defined(WIN32) || defined(VISP_HAVE_PTHREAD)
56 
181 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vpAfma6
182 {
183  public:
184  static const double defaultPositioningVelocity;
185 
186  private:
187  vpColVector q_prev_getdis;
188  bool first_time_getdis;
189 
190  double positioningVelocity;
191 
192  vpColVector zeroPos;
193  vpColVector reposPos;
194 
195  bool toolCustom;
196  std::string arm_dir;
197 
198 public:
200  vpSimulatorAfma6(bool display);
201  virtual ~vpSimulatorAfma6();
202 
204  const unsigned int &image_width,
205  const unsigned int &image_height);
207  const vpImage<unsigned char> &I);
210  vpColVector &displacement);
212  void getPosition (const vpRobot::vpControlFrameType frame,
213  vpPoseVector &position);
214  double getPositioningVelocity (void){return positioningVelocity;}
215  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
216  vpColVector getVelocity (const vpRobot::vpControlFrameType frame);
217 
218  void get_cMe(vpHomogeneousMatrix &cMe);
219  void get_cVe(vpVelocityTwistMatrix &cVe);
220  void get_eJe(vpMatrix &eJe);
221  void get_fJe(vpMatrix &fJe);
222 
224  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
225  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
226 
227  void move(const char *filename) ;
228 
229  static bool readPosFile(const char *filename, vpColVector &q);
230  static bool savePosFile(const char *filename, const vpColVector &q);
231  void setCameraParameters(const vpCameraParameters &cam) ;
232  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
233 
234  void setPosition(const vpRobot::vpControlFrameType frame,const vpColVector &q);
235  void setPosition (const vpRobot::vpControlFrameType frame,
236  const double pos1,
237  const double pos2,
238  const double pos3,
239  const double pos4,
240  const double pos5,
241  const double pos6);
242  void setPosition(const char *filename);
243  void setPositioningVelocity (const double velocity) {positioningVelocity = velocity;}
244  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint=NULL, const double &errMax = 0.001);
246 
247  void setVelocity (const vpRobot::vpControlFrameType frame, const vpColVector & velocity);
248 
249  void stopMotion();
250 
251 
252 protected:
254  void compute_fMi();
255  void findHighestPositioningSpeed(vpColVector &q);
257  inline void get_fMi(vpHomogeneousMatrix *fMit) {
258 #if defined(WIN32)
259  WaitForSingleObject(mutex_fMi,INFINITE);
260  for (int i = 0; i < 8; i++)
261  fMit[i] = fMi[i];
262  ReleaseMutex(mutex_fMi);
263 #elif defined(VISP_HAVE_PTHREAD)
264  pthread_mutex_lock (&mutex_fMi);
265  for (int i = 0; i < 8; i++)
266  fMit[i] = fMi[i];
267  pthread_mutex_unlock (&mutex_fMi);
268 #endif
269  }
270  void init();
271  void initArms();
272  void initDisplay();
273  int isInJointLimit (void);
274  bool singularityTest(const vpColVector q, vpMatrix &J);
276 
277 private:
278  void getCameraDisplacement(vpColVector &displacement);
279  void getArticularDisplacement(vpColVector &displacement);
280 };
281 
282 #endif
283 
284 #endif
Modelisation of Irisa's gantry robot named Afma6.
Definition: vpAfma6.h:69
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
Get a displacement (frame as to ve specified) between two successive position control.
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 get_cVe(vpVelocityTwistMatrix &cVe)
Definition: vpAfma6.cpp:869
virtual void initArms()=0
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height)
Definition: vpAfma6.cpp:1234
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:78
virtual int isInJointLimit()=0
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:154
void get_cMe(vpHomogeneousMatrix &cMe)
Definition: vpAfma6.cpp:854
void get_eJe(const vpColVector &q, vpMatrix &eJe)
Definition: vpAfma6.cpp:892
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).
virtual void computeArticularVelocity()=0
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...
void getExternalImage(vpImage< unsigned char > &I)
This class aims to be a basis used to create all the simulators of robots.
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:959
void init(void)
Definition: vpAfma6.cpp:196
void get_fMi(vpHomogeneousMatrix *fMit)
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...