ViSP  2.9.0
vpSimulatorPioneer.cpp
1 /****************************************************************************
2  *
3  * $Id: vpSimulatorPioneer.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  * Pioneer mobile robot simulator without display.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 
49 #include <visp/vpHomogeneousMatrix.h>
50 #include <visp/vpSimulatorPioneer.h>
51 #include <visp/vpRobotException.h>
52 #include <visp/vpDebug.h>
53 #include <visp/vpExponentialMap.h>
54 
55 
61  : wMc_(), wMe_(), xm_(0), ym_(0), theta_(0)
62 {
63  init() ;
64 }
65 
73 void vpSimulatorPioneer::init()
74 {
75  xm_ = 0;
76  ym_ = 0;
77  theta_ = 0;
78 
79  nDof = 2;
80  eJeAvailable = true;
81  fJeAvailable = false;
83  qmin = NULL;
84  qmax = NULL;
85 
86  wMc_ = wMe_ * cMe_.inverse();
87 }
88 
89 
95 {
96 }
97 
105 void
107 {
108  _eJe = vpUnicycle::get_eJe();
109 }
110 
111 
125 void
127  const vpColVector &v)
128 {
129  switch (frame)
130  {
134  }
135  setRobotFrame(frame);
136 
137  // v is a 2 dimension vector that contains v,w
138  if (v.size() != 2) {
139  vpERROR_TRACE ("Bad dimension of the control vector");
141  "Bad dimension of the control vector");
142  }
143 
144  vpColVector v_max(2);
145 
146  v_max[0] = getMaxTranslationVelocity();
147  v_max[1] = getMaxRotationVelocity();
148 
149  vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
150 
151  xm_ += delta_t_ * v_sat[0] * cos(theta_);
152  ym_ += delta_t_ * v_sat[0] * sin(theta_);
153  theta_ += delta_t_ * v_sat[1];
154 
155  vpRotationMatrix wRe(0, 0, theta_);
156  vpTranslationVector wte(xm_, ym_, 0);
157  wMe_.buildFrom(wte, wRe);
158  wMc_ = wMe_ * cMe_.inverse();
159 
160  break ;
161  }
162  break ;
164  vpERROR_TRACE ("Cannot set a velocity in the camera frame: "
165  "functionality not implemented");
167  "Cannot set a velocity in the camera frame:"
168  "functionality not implemented");
169  break ;
171  vpERROR_TRACE ("Cannot set a velocity in the reference frame: "
172  "functionality not implemented");
174  "Cannot set a velocity in the articular frame:"
175  "functionality not implemented");
176  case vpRobot::MIXT_FRAME:
177  vpERROR_TRACE ("Cannot set a velocity in the mixt frame: "
178  "functionality not implemented");
180  "Cannot set a velocity in the mixt frame:"
181  "functionality not implemented");
182 
183  break ;
184  }
185 }
186 
191 void
193 {
194  wMc = this->wMc_ ;
195 }
196 
197 /*
198  Get the current position of the robot.
199 
200  \param frame : Control frame type in which to get the position, either :
201  - in the camera cartesien frame,
202  - joint (articular) coordinates of each axes (not implemented)
203  - in a reference or fixed cartesien frame attached to the robot base
204  - in a mixt cartesien frame (translation in reference frame, and rotation in camera frame)
205 
206  \param position : Measured position of the robot:
207  - in camera cartesien frame, a 6 dimension vector, set to 0.
208 
209  - in articular, this functionality is not implemented.
210 
211  - in reference frame, a 6 dimension vector, the first 3 values correspond to
212  the translation tx, ty, tz in meters (like a vpTranslationVector), and the
213  last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
214 */
216 {
217  q.resize (6);
218 
219  switch (frame) {
220  case vpRobot::CAMERA_FRAME :
221  q = 0;
222  break;
223 
225  std::cout << "ARTICULAR_FRAME is not implemented in vpSimulatorPioneer::getPosition()" << std::endl;
226  break;
227  case vpRobot::REFERENCE_FRAME : {
228  // Convert wMc_ to a position
229  // From fMc extract the pose
230  vpRotationMatrix wRc;
231  this->wMc_.extract(wRc);
232  vpRxyzVector rxyz;
233  rxyz.buildFrom(wRc);
234 
235  for (unsigned int i=0; i < 3; i++) {
236  q[i] = this->wMc_[i][3]; // translation x,y,z
237  q[i+3] = rxyz[i]; // Euler rotation x,y,z
238  }
239 
240  break;
241  }
242  case vpRobot::MIXT_FRAME :
243  std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
244  }
245 }
Definition of the vpMatrix class.
Definition: vpMatrix.h:98
Error that can be emited by the vpRobot class and its derivates.
vpHomogeneousMatrix wMe_
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
double * qmax
Definition: vpRobot.h:113
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
double getMaxTranslationVelocity(void) const
Definition: vpRobot.cpp:239
void getPosition(vpHomogeneousMatrix &wMc) const
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition: vpRobot.cpp:152
vpControlFrameType
Definition: vpRobot.h:78
double getMaxRotationVelocity(void) const
Definition: vpRobot.cpp:264
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition: vpRobot.cpp:190
The vpRotationMatrix considers the particular case of a rotation matrix.
unsigned int size() const
Definition: vpColVector.h:199
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition: vpRobot.h:105
Initialize the velocity controller.
Definition: vpRobot.h:70
vpMatrix get_eJe() const
Definition: vpUnicycle.h:115
void extract(vpRotationMatrix &R) const
vpHomogeneousMatrix wMc_
int areJointLimitsAvailable
Definition: vpRobot.h:111
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Construction from translation vector and rotation matrix.
vpHomogeneousMatrix cMe_
Definition: vpUnicycle.h:140
int nDof
number of degrees of freedom
Definition: vpRobot.h:101
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
vpHomogeneousMatrix inverse() const
virtual vpRobotStateType getRobotState(void) const
Definition: vpRobot.h:140
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:197
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:109
void buildFrom(const double phi, const double theta, const double psi)
Definition: vpRxyzVector.h:184
Class that consider the case of a translation vector.
void resize(const unsigned int i, const bool flagNullify=true)
Definition: vpColVector.h:94