Visual Servoing Platform  version 3.6.1 under development (2024-04-20)
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 
34 #ifndef vpSimulatorViper850_HH
35 #define vpSimulatorViper850_HH
36 
42 #include <visp3/robot/vpRobotWireFrameSimulator.h>
43 #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS)
44 
45 #include <string>
46 
47 #include <visp3/robot/vpViper850.h>
48 
195 class VISP_EXPORT vpSimulatorViper850 : public vpRobotWireFrameSimulator, public vpViper850
196 {
197 public:
198  static const double defaultPositioningVelocity;
199 
200 private:
201  vpColVector q_prev_getdis;
202  bool first_time_getdis;
203 
204  double positioningVelocity;
205 
206  vpColVector zeroPos;
207  vpColVector reposPos;
208 
209  bool toolCustom;
210  std::string arm_dir;
211 
212 public:
214  explicit vpSimulatorViper850(bool display);
215  virtual ~vpSimulatorViper850() vp_override;
216 
217  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
218  void getCameraParameters(vpCameraParameters &cam, const vpImage<unsigned char> &I);
219  void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I);
220 
221  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement) vp_override;
222 
223  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) vp_override;
224  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
225  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
226  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
227  double getPositioningVelocity(void) { return positioningVelocity; }
228 
229  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
230  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
231  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
232  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
233 
234  void get_cMe(vpHomogeneousMatrix &cMe);
235  void get_cVe(vpVelocityTwistMatrix &cVe);
236  void get_eJe(vpMatrix &eJe) vp_override;
237  void get_fJe(vpMatrix &fJe) vp_override;
238 
239  void
242  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
243  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
244 
245  void move(const char *filename);
246 
247  static bool readPosFile(const std::string &filename, vpColVector &q);
248  static bool savePosFile(const std::string &filename, const vpColVector &q);
249 
250  void setCameraParameters(const vpCameraParameters &cam);
251  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
252  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) vp_override;
253  void setPosition(const vpRobot::vpControlFrameType frame, double pos1, double pos2, double pos3, double pos4,
254  double pos5, double pos6);
255  void setPosition(const char *filename);
256  void setPositioningVelocity(double vel) { positioningVelocity = vel; }
258 
259  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity) vp_override;
260 
261  void stopMotion();
262 
263 protected:
266  void computeArticularVelocity() vp_override;
267  void compute_fMi();
268  void findHighestPositioningSpeed(vpColVector &q);
269  void getExternalImage(vpImage<vpRGBa> &I);
270 
271  inline void get_fMi(vpHomogeneousMatrix *fMit) vp_override
272  {
273  m_mutex_fMi.lock();
274  for (int i = 0; i < 8; i++) {
275  fMit[i] = fMi[i];
276  }
277  m_mutex_fMi.unlock();
278  }
279  void init() vp_override;
280  void initArms() vp_override;
281  void initDisplay();
282  int isInJointLimit() vp_override;
283  bool singularityTest(const vpColVector &q, vpMatrix &J);
284  void updateArticularPosition() vp_override;
286 };
287 
288 #endif
289 
290 #endif
Generic class defining intrinsic camera parameters.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition of the vpImage class member functions.
Definition: vpImage.h:69
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Implementation of a pose vector and operations on poses.
Definition: vpPoseVector.h:189
Definition: vpRGBa.h:61
This class aims to be a basis used to create all the simulators of robots.
virtual void computeArticularVelocity()=0
Class that defines a generic virtual robot.
Definition: vpRobot.h:57
vpControlFrameType
Definition: vpRobot.h:75
virtual void get_eJe(vpMatrix &_eJe)=0
Get the robot Jacobian expressed in the end-effector frame.
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
vpRobotStateType
Definition: vpRobot.h:63
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:198
virtual void init()=0
virtual void get_fJe(vpMatrix &_fJe)=0
virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.
Simulator of Irisa's Viper S850 robot named Viper850.
static const double defaultPositioningVelocity
void setPositioningVelocity(double vel)
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 get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpViper.cpp:904
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpViper.cpp:920