ViSP  2.10.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 - 2014 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  : cMw_()
76 {
77  init() ;
78 }
79 
87 void vpRobotCamera::init()
88 {
89  nDof = 6;
90  eJe.resize(6,6) ;
91  eJe.setIdentity() ;
92  eJeAvailable = true;
93  fJeAvailable = false;
95  qmin = NULL;
96  qmax = NULL;
97 
98  setMaxTranslationVelocity(1.); // vx, vy and vz max set to 1 m/s
99  setMaxRotationVelocity(vpMath::rad(90)); // wx, wy and wz max set to 90 deg/s
100 }
101 
102 
108 {
109 }
110 
121 void
123 {
125  cVe = cVe_;
126 }
127 
135 void
137 {
138  eJe_ = this->eJe ;
139 }
140 
169 void
171  const vpColVector &v)
172 {
173  switch (frame)
174  {
176  case vpRobot::CAMERA_FRAME: {
179  }
180 
181  vpColVector v_max(6);
182 
183  for (unsigned int i=0; i<3; i++)
184  v_max[i] = getMaxTranslationVelocity();
185  for (unsigned int i=3; i<6; i++)
186  v_max[i] = getMaxRotationVelocity();
187 
188  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
189 
190  this->cMw_ = vpExponentialMap::direct(v_sat, delta_t_).inverse()*this->cMw_ ;
191  break ;
192  }
194  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
195  "functionality not implemented");
197  "Cannot set a velocity in the reference frame:"
198  "functionality not implemented");
199  break ;
200  case vpRobot::MIXT_FRAME:
201  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
202  "functionality not implemented");
204  "Cannot set a velocity in the mixt frame:"
205  "functionality not implemented");
206 
207  break ;
208  }
209 }
210 
211 
215 void
217 {
218  cMw = this->cMw_ ;
219 }
220 
221 /*
222  Get the current position of the robot.
223 
224  \param frame : Control frame type in which to get the position, either :
225  - in the camera cartesien frame,
226  - joint (articular) coordinates of each axes
227  - in a reference or fixed cartesien frame attached to the robot base
228  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
229 
230  \param position : Measured position of the robot:
231  - in camera cartesien frame, a 6 dimension vector, set to 0.
232 
233  - in articular, a 6 dimension vector corresponding to the articular
234  position of each dof, first the 3 translations, then the 3
235  articular rotation positions represented by a vpRxyzVector.
236 
237  - in reference frame, a 6 dimension vector, the first 3 values correspond to
238  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
239  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
240 */
242 {
243  q.resize (6);
244 
245  switch (frame) {
246  case vpRobot::CAMERA_FRAME :
247  q = 0;
248  break;
249 
251  case vpRobot::REFERENCE_FRAME : {
252  // Convert wMc_ to a position
253  // From fMc extract the pose
254  vpRotationMatrix cRw;
255  this->cMw_.extract(cRw);
256  vpRxyzVector rxyz;
257  rxyz.buildFrom(cRw);
258 
259  for (unsigned int i=0; i < 3; i++) {
260  q[i] = this->cMw_[i][3]; // translation x,y,z
261  q[i+3] = rxyz[i]; // Euler rotation x,y,z
262  }
263 
264  break;
265  }
266  case vpRobot::MIXT_FRAME :
267  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
268  }
269 }
270 
274 void
276 {
279  }
280 
281  this->cMw_ = cMw ;
282 }
283 
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Definition: vpMatrix.cpp:199
Error that can be emited by the vpRobot class and its derivates.
void setMaxTranslationVelocity(const double maxVt)
Definition: vpRobot.cpp:242
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:395
void setPosition(const vpHomogeneousMatrix &cMw)
double * qmax
Definition: vpRobot.h:113
double getMaxTranslationVelocity(void) const
Definition: vpRobot.cpp:254
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:167
vpControlFrameType
Definition: vpRobot.h:78
double getMaxRotationVelocity(void) const
Definition: vpRobot.cpp:279
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:205
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 setIdentity(const double &val=1.0)
Definition: vpMatrix.cpp:1230
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:266
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
void get_cVe(vpVelocityTwistMatrix &cVe) const
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
virtual vpRobotStateType getRobotState(void) const
Definition: vpRobot.h:140
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:184
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:98