ViSP  2.8.0
vpRobotCamera.cpp
1 /****************************************************************************
2  *
3  * $Id: vpRobotCamera.cpp 2456 2010-01-07 10:33:12Z 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  * Defines the simplest robot : a free flying camera.
36  *
37  * Authors:
38  * Eric Marchand
39  *
40  *****************************************************************************/
41 
42 
48 #include <visp/vpHomogeneousMatrix.h>
49 #include <visp/vpRobotCamera.h>
50 #include <visp/vpRobotException.h>
51 #include <visp/vpDebug.h>
52 #include <visp/vpExponentialMap.h>
53 
54 
75 {
76  init() ;
77 }
78 
86 void vpRobotCamera::init()
87 {
88  nDof = 6;
89  eJe.resize(6,6) ;
90  eJe.setIdentity() ;
91  eJeAvailable = true;
92  fJeAvailable = false;
94  qmin = NULL;
95  qmax = NULL;
96 
97  setMaxTranslationVelocity(1.); // vx, vy and vz max set to 1 m/s
98  setMaxRotationVelocity(vpMath::rad(90)); // wx, wy and wz max set to 90 deg/s
99 }
100 
101 
107 {
108 }
109 
120 void
122 {
124  cVe = cVe_;
125 }
126 
134 void
136 {
137  eJe = this->eJe ;
138 }
139 
168 void
170  const vpColVector &v)
171 {
172  switch (frame)
173  {
175  case vpRobot::CAMERA_FRAME: {
178  }
179 
180  vpColVector v_max(6);
181 
182  for (unsigned int i=0; i<3; i++)
183  v_max[i] = getMaxTranslationVelocity();
184  for (unsigned int i=3; i<6; i++)
185  v_max[i] = getMaxRotationVelocity();
186 
187  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
188 
189  this->cMw_ = vpExponentialMap::direct(v_sat, delta_t_).inverse()*this->cMw_ ;
190  break ;
191  }
193  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
194  "functionality not implemented");
196  "Cannot set a velocity in the reference frame:"
197  "functionality not implemented");
198  break ;
199  case vpRobot::MIXT_FRAME:
200  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
201  "functionality not implemented");
203  "Cannot set a velocity in the mixt frame:"
204  "functionality not implemented");
205 
206  break ;
207  }
208 }
209 
210 
214 void
216 {
217  cMw = this->cMw_ ;
218 }
219 
220 /*
221  Get the current position of the robot.
222 
223  \param frame : Control frame type in which to get the position, either :
224  - in the camera cartesien frame,
225  - joint (articular) coordinates of each axes
226  - in a reference or fixed cartesien frame attached to the robot base
227  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
228 
229  \param position : Measured position of the robot:
230  - in camera cartesien frame, a 6 dimension vector, set to 0.
231 
232  - in articular, a 6 dimension vector corresponding to the articular
233  position of each dof, first the 3 translations, then the 3
234  articular rotation positions represented by a vpRxyzVector.
235 
236  - in reference frame, a 6 dimension vector, the first 3 values correspond to
237  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
238  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
239 */
241 {
242  q.resize (6);
243 
244  switch (frame) {
245  case vpRobot::CAMERA_FRAME :
246  q = 0;
247  break;
248 
250  case vpRobot::REFERENCE_FRAME : {
251  // Convert wMc_ to a position
252  // From fMc extract the pose
253  vpRotationMatrix cRw;
254  this->cMw_.extract(cRw);
255  vpRxyzVector rxyz;
256  rxyz.buildFrom(cRw);
257 
258  for (unsigned int i=0; i < 3; i++) {
259  q[i] = this->cMw_[i][3]; // translation x,y,z
260  q[i+3] = rxyz[i]; // Euler rotation x,y,z
261  }
262 
263  break;
264  }
265  case vpRobot::MIXT_FRAME :
266  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
267  }
268 }
269 
273 void
275 {
278  }
279 
280  this->cMw_ = cMw ;
281 }
282 
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:174
Error that can be emited by the vpRobot class and its derivates.
void setMaxTranslationVelocity(const double maxVt)
Definition: vpRobot.cpp:191
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
#define vpERROR_TRACE
Definition: vpDebug.h:379
void setPosition(const vpHomogeneousMatrix &cMw)
double * qmax
Definition: vpRobot.h:113
virtual vpRobotStateType getRobotState(void)
Definition: vpRobot.h:139
double getMaxTranslationVelocity(void) const
Definition: vpRobot.cpp:203
Initialize the position controller.
Definition: vpRobot.h:71
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition: vpRobot.cpp:116
vpControlFrameType
Definition: vpRobot.h:78
double getMaxRotationVelocity(void) const
Definition: vpRobot.cpp:228
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:154
The vpRotationMatrix considers the particular case of a rotation matrix.
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition: vpRobot.h:105
void get_cVe(vpVelocityTwistMatrix &cVe)
void setIdentity(const double &val=1.0)
Definition: vpMatrix.cpp:1110
Initialize the velocity controller.
Definition: vpRobot.h:70
virtual ~vpRobotCamera()
void extract(vpRotationMatrix &R) const
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
int areJointLimitsAvailable
Definition: vpRobot.h:111
static double rad(double deg)
Definition: vpMath.h:100
void setMaxRotationVelocity(const double maxVr)
Definition: vpRobot.cpp:215
int nDof
number of degrees of freedom
Definition: vpRobot.h:101
void getPosition(vpHomogeneousMatrix &cMw) const
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition: vpRobot.h:103
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
void get_eJe(vpMatrix &eJe)
vpHomogeneousMatrix inverse() const
static vpHomogeneousMatrix direct(const vpColVector &v)
double * qmin
Definition: vpRobot.h:112
Class that consider the case of the Euler angle using the x-y-z convention, where are respectively ...
Definition: vpRxyzVector.h:152
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:109
vpHomogeneousMatrix cMw_
void buildFrom(const double phi, const double theta, const double psi)
Definition: vpRxyzVector.h:188
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94