Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpSimulatorPioneerPan.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  * Pioneer mobile robot equipped with a pan head simulator without display.
32  *
33  * Authors:
34  * Fabien Spindler
35  *
36  *****************************************************************************/
37 
38 
45 #include <visp3/core/vpHomogeneousMatrix.h>
46 #include <visp3/robot/vpSimulatorPioneerPan.h>
47 #include <visp3/robot/vpRobotException.h>
48 #include <visp3/core/vpDebug.h>
49 #include <visp3/core/vpExponentialMap.h>
50 
51 
61 vpSimulatorPioneerPan::vpSimulatorPioneerPan() : wMc_(), wMm_(), xm_(0), ym_(0), theta_(0), q_pan_()
62 {
63  init() ;
64 }
65 
76 void vpSimulatorPioneerPan::init()
77 {
78  xm_ = 0;
79  ym_ = 0;
80  theta_ = 0;
81  q_pan_ = 0;
82 
83  nDof = 3;
84  eJeAvailable = true;
85  fJeAvailable = false;
87  qmin = NULL;
88  qmax = NULL;
89 
90  wMc_ = wMm_ * mMp_ * pMe_ * cMe_.inverse();
91 }
92 
93 
99 {
100 }
101 
109 void
111 {
112  _eJe = vpUnicycle::get_eJe();
113 }
114 
128 void
130  const vpColVector &v)
131 {
132  switch (frame)
133  {
137  }
138 
139  setRobotFrame(frame);
140 
141  // v is a 3 dimension vector that contains vx, wz, qpan
142  if (v.size() != 3) {
143  vpERROR_TRACE ("Bad dimension of the control vector");
145  "Bad dimension of the control vector");
146  }
147 
148  vpColVector v_max(3);
149 
150  v_max[0] = getMaxTranslationVelocity();
151  v_max[1] = getMaxRotationVelocity();
152  v_max[2] = getMaxRotationVelocity();
153 
154  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
155 
156  xm_ += delta_t_ * v_sat[0] * cos(theta_);
157  ym_ += delta_t_ * v_sat[0] * sin(theta_);
158  theta_ += delta_t_ * v_sat[1];
159  q_pan_ += delta_t_ * v_sat[2];
160 
161  vpRotationMatrix wRm(0, 0, theta_);
162  vpTranslationVector wtm(xm_, ym_, 0);
163  wMm_.buildFrom(wtm, wRm);
164 
165  // Update the end effector pose
166  set_pMe(q_pan_);
167 
168  // Update the camera pose
169  wMc_ = wMm_ * mMp_ * pMe_ * cMe_.inverse();
170 
171  // Update the jacobian
172  set_eJe(q_pan_);
173 
174  break ;
175  }
178  "Cannot set a velocity in the camera frame:"
179  "functionality not implemented");
182  "Cannot set a velocity in the reference frame:"
183  "functionality not implemented");
184  case vpRobot::MIXT_FRAME:
186  "Cannot set a velocity in the mixt frame:"
187  "functionality not implemented");
188  }
189 }
190 
195 void
197 {
198  wMc = this->wMc_ ;
199 }
200 
201 /*
202  Get the current position of the robot.
203 
204  \param frame : Control frame type in which to get the position, either :
205  - in the camera cartesien frame,
206  - joint (articular) coordinates of each axes (not implemented)
207  - in a reference or fixed cartesien frame attached to the robot base
208  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
209 
210  \param position : Measured position of the robot:
211  - in camera cartesien frame, a 6 dimension vector, set to 0.
212 
213  - in articular, this functionality is not implemented.
214 
215  - in reference frame, a 6 dimension vector, the first 3 values correspond to
216  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
217  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
218 */
220 {
221  q.resize (6);
222 
223  switch (frame) {
224  case vpRobot::CAMERA_FRAME :
225  q = 0;
226  break;
227 
229  std::cout << "ARTICULAR_FRAME is not implemented in vpSimulatorPioneer::getPosition()" << std::endl;
230  break;
231  case vpRobot::REFERENCE_FRAME : {
232  // Convert wMc_ to a position
233  // From fMc extract the pose
234  vpRotationMatrix wRc;
235  this->wMc_.extract(wRc);
236  vpRxyzVector rxyz;
237  rxyz.buildFrom(wRc);
238 
239  for (unsigned int i=0; i < 3; i++) {
240  q[i] = this->wMc_[i][3]; // translation x,y,z
241  q[i+3] = rxyz[i]; // Euler rotation x,y,z
242  }
243 
244  break;
245  }
246  case vpRobot::MIXT_FRAME :
247  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
248  }
249 }
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:97
vpRxyzVector buildFrom(const vpRotationMatrix &R)
void set_pMe(const double q)
Definition: vpPioneerPan.h:216
Error that can be emited by the vpRobot class and its derivates.
vpHomogeneousMatrix wMc_
robot / camera location in the world frame
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
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition: vpRobot.cpp:163
vpControlFrameType
Definition: vpRobot.h:76
unsigned int size() const
Return the number of elements of the 2D array.
Definition: vpArray2D.h:156
vpHomogeneousMatrix wMm_
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
vpHomogeneousMatrix mMp_
Definition: vpPioneerPan.h:230
vpMatrix get_eJe() const
Definition: vpUnicycle.h:113
void extract(vpRotationMatrix &R) const
int areJointLimitsAvailable
Definition: vpRobot.h:109
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
vpHomogeneousMatrix cMe_
Definition: vpUnicycle.h:139
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
int nDof
number of degrees of freedom
Definition: vpRobot.h:99
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72
vpHomogeneousMatrix pMe_
Definition: vpPioneerPan.h:231
vpHomogeneousMatrix inverse() const
virtual vpRobotStateType getRobotState(void) const
Definition: vpRobot.h:141
void getPosition(vpHomogeneousMatrix &wMc) const
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 set_eJe(double q_pan)
Definition: vpPioneerPan.h:143
Class that consider the case of a translation vector.
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:225