Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpSimulatorViper850.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
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 https://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 
39 #ifndef vpSimulatorViper850_HH
40 #define vpSimulatorViper850_HH
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/robot/vpRobotWireFrameSimulator.h>
44 #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS)
45 
46 #include <string>
47 
48 #include <visp3/robot/vpViper850.h>
49 
50 BEGIN_VISP_NAMESPACE
209 class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpViper850
210 {
211 public:
212  static const double defaultPositioningVelocity;
213 
214 private:
215  vpColVector q_prev_getdis;
216  bool first_time_getdis;
217 
218  double positioningVelocity;
219 
220  vpColVector zeroPos;
221  vpColVector reposPos;
222 
223  bool toolCustom;
224  std::string arm_dir;
225 
226 public:
227  vpSimulatorViper850();
228  VP_EXPLICIT vpSimulatorViper850(bool display);
229  virtual ~vpSimulatorViper850() VP_OVERRIDE;
230 
231  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
232  void getCameraParameters(vpCameraParameters &cam, const vpImage<unsigned char> &I);
233  void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I);
234 
235  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement) VP_OVERRIDE;
236 
237  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) VP_OVERRIDE;
238  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
239  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
240  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
241  double getPositioningVelocity(void) { return positioningVelocity; }
242 
243  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
244  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
245  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
246  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
247 
248  void get_cMe(vpHomogeneousMatrix &cMe);
249  void get_cVe(vpVelocityTwistMatrix &cVe);
250  void get_eJe(vpMatrix &eJe) VP_OVERRIDE;
251  void get_fJe(vpMatrix &fJe) VP_OVERRIDE;
252 
253  void
256  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
257  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
258 
259  void move(const char *filename);
260 
261  static bool readPosFile(const std::string &filename, vpColVector &q);
262  static bool savePosFile(const std::string &filename, const vpColVector &q);
263 
264  void setCameraParameters(const vpCameraParameters &cam);
265  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
266  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) VP_OVERRIDE;
267  void setPosition(const vpRobot::vpControlFrameType frame, double pos1, double pos2, double pos3, double pos4,
268  double pos5, double pos6);
269  void setPosition(const char *filename);
270  void setPositioningVelocity(double vel) { positioningVelocity = vel; }
271  vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) VP_OVERRIDE;
272 
273  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity) VP_OVERRIDE;
274 
275  void stopMotion();
276 
277 protected:
280  void computeArticularVelocity() VP_OVERRIDE;
281  void compute_fMi();
282  void findHighestPositioningSpeed(vpColVector &q);
283  void getExternalImage(vpImage<vpRGBa> &I);
284 
285  inline void get_fMi(vpHomogeneousMatrix *fMit) VP_OVERRIDE
286  {
287  m_mutex_fMi.lock();
288  for (int i = 0; i < 8; i++) {
289  fMit[i] = fMi[i];
290  }
291  m_mutex_fMi.unlock();
292  }
293  void init() VP_OVERRIDE;
294  void initArms() VP_OVERRIDE;
295  void initDisplay();
296  int isInJointLimit() VP_OVERRIDE;
297  bool singularityTest(const vpColVector &q, vpMatrix &J);
298  void updateArticularPosition() VP_OVERRIDE;
300 };
301 END_VISP_NAMESPACE
302 #endif
303 
304 #endif
Generic class defining intrinsic camera parameters.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Definition: vpImage.h:131
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:203
Definition: vpRGBa.h:65
Class that defines a generic virtual robot.
Definition: vpRobot.h:59
vpControlFrameType
Definition: vpRobot.h:77
vpRobotStateType
Definition: vpRobot.h:65
Modelization of the ADEPT Viper 850 robot.
Definition: vpViper850.h:95
vpToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpViper850.h:120
void init(void)
Definition: vpViper850.cpp:134
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpViper.cpp:921
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpViper.cpp:1158
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpViper.cpp:969
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:937