Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpRobotCamera.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Defines the simplest robot : a free flying camera.
32  *
33  * Authors:
34  * Eric Marchand
35  *
36  *****************************************************************************/
37 
38 
44 #include <visp3/robot/vpRobotCamera.h>
45 
46 #if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
47 
48 #include <visp3/core/vpHomogeneousMatrix.h>
49 #include <visp3/robot/vpRobotException.h>
50 #include <visp3/core/vpDebug.h>
51 #include <visp3/core/vpExponentialMap.h>
52 
73  : cMw_()
74 {
75  init() ;
76 }
77 
85 void vpRobotCamera::init()
86 {
87  nDof = 6;
88  eJe.eye(6,6) ;
89  eJeAvailable = true;
90  fJeAvailable = false;
92  qmin = NULL;
93  qmax = NULL;
94 
95  setMaxTranslationVelocity(1.); // vx, vy and vz max set to 1 m/s
96  setMaxRotationVelocity(vpMath::rad(90)); // wx, wy and wz max set to 90 deg/s
97 }
98 
99 
105 {
106 }
107 
118 void
120 {
122  cVe = cVe_;
123 }
124 
132 void
134 {
135  eJe_ = this->eJe ;
136 }
137 
166 void
168  const vpColVector &v)
169 {
170  switch (frame)
171  {
173  case vpRobot::CAMERA_FRAME: {
176  }
177 
178  vpColVector v_max(6);
179 
180  for (unsigned int i=0; i<3; i++)
181  v_max[i] = getMaxTranslationVelocity();
182  for (unsigned int i=3; i<6; i++)
183  v_max[i] = getMaxRotationVelocity();
184 
185  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
186 
187  this->cMw_ = vpExponentialMap::direct(v_sat, delta_t_).inverse()*this->cMw_ ;
188  break ;
189  }
191  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
192  "functionality not implemented");
194  "Cannot set a velocity in the reference frame:"
195  "functionality not implemented");
196  break ;
197  case vpRobot::MIXT_FRAME:
198  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
199  "functionality not implemented");
201  "Cannot set a velocity in the mixt frame:"
202  "functionality not implemented");
203 
204  break ;
205  }
206 }
207 
208 
212 void
214 {
215  cMw = this->cMw_ ;
216 }
217 
218 /*
219  Get the current position of the robot.
220 
221  \param frame : Control frame type in which to get the position, either :
222  - in the camera cartesien frame,
223  - joint (articular) coordinates of each axes
224  - in a reference or fixed cartesien frame attached to the robot base
225  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
226 
227  \param position : Measured position of the robot:
228  - in camera cartesien frame, a 6 dimension vector, set to 0.
229 
230  - in articular, a 6 dimension vector corresponding to the articular
231  position of each dof, first the 3 translations, then the 3
232  articular rotation positions represented by a vpRxyzVector.
233 
234  - in reference frame, a 6 dimension vector, the first 3 values correspond to
235  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
236  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
237 */
239 {
240  q.resize (6);
241 
242  switch (frame) {
243  case vpRobot::CAMERA_FRAME :
244  q = 0;
245  break;
246 
248  case vpRobot::REFERENCE_FRAME : {
249  // Convert wMc_ to a position
250  // From fMc extract the pose
251  vpRotationMatrix cRw;
252  this->cMw_.extract(cRw);
253  vpRxyzVector rxyz;
254  rxyz.buildFrom(cRw);
255 
256  for (unsigned int i=0; i < 3; i++) {
257  q[i] = this->cMw_[i][3]; // translation x,y,z
258  q[i+3] = rxyz[i]; // Euler rotation x,y,z
259  }
260 
261  break;
262  }
263  case vpRobot::MIXT_FRAME :
264  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
265  }
266 }
267 
271 void
273 {
276  }
277 
278  this->cMw_ = cMw ;
279 }
280 
281 #elif !defined(VISP_BUILD_SHARED_LIBS)
282 // Work arround to avoid warning: libvisp_robot.a(vpRobotCamera.cpp.o) has no symbols
283 void dummy_vpRobotCamera() {};
284 #endif
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
vpRxyzVector buildFrom(const vpRotationMatrix &R)
Error that can be emited by the vpRobot class and its derivates.
void setMaxTranslationVelocity(const double maxVt)
Definition: vpRobot.cpp:238
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setPosition(const vpHomogeneousMatrix &cMw)
double * qmax
Definition: vpRobot.h:111
#define vpERROR_TRACE
Definition: vpDebug.h:391
double getMaxTranslationVelocity(void) const
Definition: vpRobot.cpp:250
Initialize the position controller.
Definition: vpRobot.h:69
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition: vpRobot.cpp:163
vpControlFrameType
Definition: vpRobot.h:76
double getMaxRotationVelocity(void) const
Definition: vpRobot.cpp:275
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:201
Implementation of a rotation matrix and operations on such kind of matrices.
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition: vpRobot.h:103
Initialize the velocity controller.
Definition: vpRobot.h:68
virtual ~vpRobotCamera()
void extract(vpRotationMatrix &R) const
Implementation of a velocity twist matrix and operations on such kind of matrices.
int areJointLimitsAvailable
Definition: vpRobot.h:109
static double rad(double deg)
Definition: vpMath.h:104
void setMaxRotationVelocity(const double maxVr)
Definition: vpRobot.cpp:262
int nDof
number of degrees of freedom
Definition: vpRobot.h:99
void getPosition(vpHomogeneousMatrix &cMw) const
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition: vpRobot.h:101
void get_cVe(vpVelocityTwistMatrix &cVe) const
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
void get_eJe(vpMatrix &eJe)
vpHomogeneousMatrix inverse() const
virtual vpRobotStateType getRobotState(void) const
Definition: vpRobot.h:141
static vpHomogeneousMatrix direct(const vpColVector &v)
double * qmin
Definition: vpRobot.h:110
Implementation of a rotation vector as Euler angle minimal representation.
Definition: vpRxyzVector.h:154
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:107
vpHomogeneousMatrix cMw_
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)
void eye()
Definition: vpMatrix.cpp:194
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:225