ViSP  2.8.0
vpSimulatorCamera.cpp
1 /****************************************************************************
2  *
3  * $Id: vpSimulatorCamera.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/vpDebug.h>
49 #include <visp/vpExponentialMap.h>
50 #include <visp/vpHomogeneousMatrix.h>
51 #include <visp/vpRobotException.h>
52 #include <visp/vpSimulatorCamera.h>
53 
54 
61 {
62  init() ;
63 }
64 
72 void vpSimulatorCamera::init()
73 {
74  nDof = 6;
75  eJe.resize(6,6) ;
76  eJe.setIdentity() ;
77  eJeAvailable = true;
78  fJeAvailable = false;
80  qmin = NULL;
81  qmax = NULL;
82 
83  setMaxTranslationVelocity(1.); // vx, vy and vz max set to 1 m/s
84  setMaxRotationVelocity(vpMath::rad(90)); // wx, wy and wz max set to 90 deg/s
85 }
86 
87 
93 {
94 }
95 
106 void
108 {
110  cVe = cVe_;
111 }
112 
120 void
122 {
123  eJe = this->eJe ;
124 }
125 
130 void
132 {
133  wMc = this->wMc_ ;
134 }
135 
136 /*
137  Get the current position of the robot.
138 
139  \param frame : Control frame type in which to get the position, either :
140  - in the camera cartesien frame,
141  - joint (articular) coordinates of each axes
142  - in a reference or fixed cartesien frame attached to the robot base
143  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
144 
145  \param position : Measured position of the robot:
146  - in camera cartesien frame, a 6 dimension vector, set to 0.
147 
148  - in articular, a 6 dimension vector corresponding to the articular
149  position of each dof, first the 3 translations, then the 3
150  articular rotation positions represented by a vpRxyzVector.
151 
152  - in reference frame, a 6 dimension vector, the first 3 values correspond to
153  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
154  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
155 */
157 {
158  q.resize (6);
159 
160  switch (frame) {
161  case vpRobot::CAMERA_FRAME :
162  q = 0;
163  break;
164 
166  case vpRobot::REFERENCE_FRAME : {
167  // Convert wMc_ to a position
168  // From fMc extract the pose
169  vpRotationMatrix wRc;
170  this->wMc_.extract(wRc);
171  vpRxyzVector rxyz;
172  rxyz.buildFrom(wRc);
173 
174  for (unsigned int i=0; i < 3; i++) {
175  q[i] = this->wMc_[i][3]; // translation x,y,z
176  q[i+3] = rxyz[i]; // Euler rotation x,y,z
177  }
178 
179  break;
180  }
181  case vpRobot::MIXT_FRAME :
182  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
183  }
184 }
185 
214 void
216  const vpColVector &v)
217 {
220  }
221 
222  switch (frame)
223  {
225  case vpRobot::CAMERA_FRAME: {
226  vpColVector v_max(6);
227 
228  for (unsigned int i=0; i<3; i++)
229  v_max[i] = getMaxTranslationVelocity();
230  for (unsigned int i=3; i<6; i++)
231  v_max[i] = getMaxRotationVelocity();
232 
233  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
234 
236  setRobotFrame(frame);
237  break ;
238  }
240  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
241  "functionality not implemented");
243  "Cannot set a velocity in the reference frame:"
244  "functionality not implemented");
245  break ;
246  case vpRobot::MIXT_FRAME:
247  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
248  "functionality not implemented");
250  "Cannot set a velocity in the mixt frame:"
251  "functionality not implemented");
252 
253  break ;
254  }
255 }
256 
263 {
266  }
267 
268  this->wMc_ = wMc;
269 }
void setPosition(const vpHomogeneousMatrix &wMc)
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
void get_cVe(vpVelocityTwistMatrix &cVe)
Error that can be emited by the vpRobot class and its derivates.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
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
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
vpHomogeneousMatrix wMc_
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 setIdentity(const double &val=1.0)
Definition: vpMatrix.cpp:1110
Initialize the velocity controller.
Definition: vpRobot.h:70
void getPosition(vpHomogeneousMatrix &wMc) const
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
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
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
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition: vpRobot.cpp:161
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:109
void get_eJe(vpMatrix &eJe)
void buildFrom(const double phi, const double theta, const double psi)
Definition: vpRxyzVector.h:188
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94