Visual Servoing Platform  version 3.6.1 under development (2024-04-20)
vpSimulatorAfma6.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 Afma6.
32  */
33 
34 #ifndef vpSimulatorAfma6_HH
35 #define vpSimulatorAfma6_HH
36 
42 #include <visp3/robot/vpAfma6.h>
43 #include <visp3/robot/vpRobotWireFrameSimulator.h>
44 
45 #include <string>
46 
47 #if defined(VISP_HAVE_MODULE_GUI) && defined(VISP_HAVE_THREADS)
48 
170 class VISP_EXPORT vpSimulatorAfma6 : public vpRobotWireFrameSimulator, public vpAfma6
171 {
172 public:
173  static const double defaultPositioningVelocity;
174 
175 private:
176  vpColVector q_prev_getdis;
177  bool first_time_getdis;
178 
179  double positioningVelocity;
180 
181  vpColVector zeroPos;
182  vpColVector reposPos;
183 
184  bool toolCustom;
185  std::string arm_dir;
186 
187 public:
189  explicit vpSimulatorAfma6(bool display);
190  virtual ~vpSimulatorAfma6() vp_override;
191 
192  void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height);
193  void getCameraParameters(vpCameraParameters &cam, const vpImage<unsigned char> &I);
194  void getCameraParameters(vpCameraParameters &cam, const vpImage<vpRGBa> &I);
195  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &displacement) vp_override;
196  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) vp_override;
197  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
198  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position);
199  void getPosition(const vpRobot::vpControlFrameType frame, vpPoseVector &position, double &timestamp);
200  double getPositioningVelocity(void) { return positioningVelocity; }
201  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q);
202  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q, double &timestamp);
203  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
204  vpColVector getVelocity(const vpRobot::vpControlFrameType frame, double &timestamp);
205 
206  void get_cMe(vpHomogeneousMatrix &cMe);
207  void get_cVe(vpVelocityTwistMatrix &cVe);
208  void get_eJe(vpMatrix &eJe) vp_override;
209  void get_fJe(vpMatrix &fJe) vp_override;
210 
211  void
214  bool initialiseCameraRelativeToObject(const vpHomogeneousMatrix &cMo);
215  void initialiseObjectRelativeToCamera(const vpHomogeneousMatrix &cMo);
216 
217  void move(const char *filename);
218 
219  static bool readPosFile(const std::string &filename, vpColVector &q);
220  static bool savePosFile(const std::string &filename, const vpColVector &q);
221  void setCameraParameters(const vpCameraParameters &cam);
222  void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax);
223 
224  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) vp_override;
225  void setPosition(const vpRobot::vpControlFrameType frame, double pos1, double pos2, double pos3, double pos4,
226  double pos5, double pos6);
227  void setPosition(const char *filename);
228  void setPositioningVelocity(double vel) { positioningVelocity = vel; }
229  bool setPosition(const vpHomogeneousMatrix &cdMo, vpImage<unsigned char> *Iint = nullptr, const double &errMax = 0.001);
231 
232  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity) vp_override;
233 
234  void stopMotion();
235 
236 protected:
239  void computeArticularVelocity() vp_override;
240  void compute_fMi();
241  void findHighestPositioningSpeed(vpColVector &q);
242  void getExternalImage(vpImage<vpRGBa> &I);
243  inline void get_fMi(vpHomogeneousMatrix *fMit) vp_override
244  {
245  m_mutex_fMi.lock();
246  for (int i = 0; i < 8; i++) {
247  fMit[i] = fMi[i];
248  }
249 
250  m_mutex_fMi.unlock();
251  }
252  void init() vp_override;
253  void initArms() vp_override;
254  void initDisplay();
255  int isInJointLimit() vp_override;
256  bool singularityTest(const vpColVector &q, vpMatrix &J);
257  void updateArticularPosition() vp_override;
259 };
260 
261 #endif
262 
263 #endif
Modelization of Irisa's gantry robot named Afma6.
Definition: vpAfma6.h:76
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition: vpAfma6.cpp:915
void init(void)
Definition: vpAfma6.cpp:157
void get_cMe(vpHomogeneousMatrix &cMe) const
Definition: vpAfma6.cpp:893
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Definition: vpAfma6.cpp:937
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Definition: vpAfma6.cpp:1007
vpAfma6ToolType
List of possible tools that can be attached to the robot end-effector.
Definition: vpAfma6.h:123
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 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 setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.
Simulator of Irisa's gantry robot named Afma6.
void setPositioningVelocity(double vel)
static const double defaultPositioningVelocity