Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpSimulatorCamera.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/core/vpDebug.h>
45 #include <visp3/core/vpExponentialMap.h>
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 #include <visp3/robot/vpRobotException.h>
48 #include <visp3/robot/vpSimulatorCamera.h>
49 
50 
57 {
58  init() ;
59 }
60 
68 void vpSimulatorCamera::init()
69 {
70  nDof = 6;
71  eJe.eye(6,6) ;
72  eJeAvailable = true;
73  fJeAvailable = false;
75  qmin = NULL;
76  qmax = NULL;
77 
78  setMaxTranslationVelocity(1.); // vx, vy and vz max set to 1 m/s
79  setMaxRotationVelocity(vpMath::rad(90)); // wx, wy and wz max set to 90 deg/s
80 }
81 
82 
88 {
89 }
90 
101 void
103 {
105  cVe = cVe_;
106 }
107 
115 void
117 {
118  eJe_ = this->eJe ;
119 }
120 
125 void
127 {
128  wMc = this->wMc_ ;
129 }
136 {
137  return(this->wMc_);
138 }
139 
140 /*
141  Get the current position of the camera.
142 
143  \param frame : Control frame type in which to get the position, either :
144  - in the camera cartesien frame,
145  - joint (articular) coordinates of each axes
146  - in a reference or fixed cartesien frame attached to the robot base
147  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
148 
149  \param position : Measured position of the robot:
150  - in camera cartesien frame, a 6 dimension vector, set to 0.
151 
152  - in articular, a 6 dimension vector corresponding to the articular
153  position of each dof, first the 3 translations, then the 3
154  articular rotation positions represented by a vpRxyzVector.
155 
156  - in reference frame, a 6 dimension vector, the first 3 values correspond to
157  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
158  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
159 */
161 {
162  q.resize (6);
163 
164  switch (frame) {
165  case vpRobot::CAMERA_FRAME :
166  q = 0;
167  break;
168 
170  case vpRobot::REFERENCE_FRAME : {
171  // Convert wMc_ to a position
172  // From fMc extract the pose
173  vpRotationMatrix wRc;
174  this->wMc_.extract(wRc);
175  vpRxyzVector rxyz;
176  rxyz.buildFrom(wRc);
177 
178  for (unsigned int i=0; i < 3; i++) {
179  q[i] = this->wMc_[i][3]; // translation x,y,z
180  q[i+3] = rxyz[i]; // Euler rotation x,y,z
181  }
182 
183  break;
184  }
185  case vpRobot::MIXT_FRAME :
186  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
187  }
188 }
189 
218 void
220  const vpColVector &v)
221 {
224  }
225 
226  switch (frame)
227  {
229  case vpRobot::CAMERA_FRAME: {
230  vpColVector v_max(6);
231 
232  for (unsigned int i=0; i<3; i++)
233  v_max[i] = getMaxTranslationVelocity();
234  for (unsigned int i=3; i<6; i++)
235  v_max[i] = getMaxRotationVelocity();
236 
237  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
238 
240  setRobotFrame(frame);
241  break ;
242  }
244  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
245  "functionality not implemented");
247  "Cannot set a velocity in the reference frame:"
248  "functionality not implemented");
249  break ;
250  case vpRobot::MIXT_FRAME:
251  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
252  "functionality not implemented");
254  "Cannot set a velocity in the mixt frame:"
255  "functionality not implemented");
256 
257  break ;
258  }
259 }
260 
267 {
270  }
271 
272  this->wMc_ = wMc;
273 }
void setPosition(const vpHomogeneousMatrix &wMc)
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 setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void setMaxTranslationVelocity(const double maxVt)
Definition: vpRobot.cpp:238
Implementation of an homogeneous matrix and operations on such kind of matrices.
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
vpHomogeneousMatrix wMc_
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
void get_cVe(vpVelocityTwistMatrix &cVe) const
Initialize the velocity controller.
Definition: vpRobot.h:68
void extract(vpRotationMatrix &R) const
vpHomogeneousMatrix getPosition() 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
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition: vpRobot.h:101
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
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
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition: vpRobot.cpp:208
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:107
void get_eJe(vpMatrix &eJe)
void eye()
Definition: vpMatrix.cpp:194
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:225