Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpSimulatorPioneerPan.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
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 https://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
39
40#include <visp3/core/vpDebug.h>
41#include <visp3/core/vpExponentialMap.h>
42#include <visp3/core/vpHomogeneousMatrix.h>
43#include <visp3/robot/vpRobotException.h>
44#include <visp3/robot/vpSimulatorPioneerPan.h>
45
57
69{
70 xm_ = 0;
71 ym_ = 0;
72 theta_ = 0;
73 q_pan_ = 0;
74
75 nDof = 3;
76 eJeAvailable = true;
77 fJeAvailable = false;
79 qmin = nullptr;
80 qmax = nullptr;
81
82 wMc_ = wMm_ * mMp_ * pMe_ * cMe_.inverse();
83}
84
93
113{
114 switch (frame) {
118 }
119
120 setRobotFrame(frame);
121
122 // v is a 3 dimension vector that contains vx, wz, qpan
123 if (v.size() != 3) {
124 vpERROR_TRACE("Bad dimension of the control vector");
125 throw vpRobotException(vpRobotException::dimensionError, "Bad dimension of the control vector");
126 }
127
128 vpColVector v_max(3);
129
130 v_max[0] = getMaxTranslationVelocity();
131 v_max[1] = getMaxRotationVelocity();
132 v_max[2] = getMaxRotationVelocity();
133
134 vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
135
136 xm_ += delta_t_ * v_sat[0] * cos(theta_);
137 ym_ += delta_t_ * v_sat[0] * sin(theta_);
138 theta_ += delta_t_ * v_sat[1];
139 q_pan_ += delta_t_ * v_sat[2];
140
141 vpRotationMatrix wRm(0, 0, theta_);
142 vpTranslationVector wtm(xm_, ym_, 0);
143 wMm_.buildFrom(wtm, wRm);
144
145 // Update the end effector pose
147
148 // Update the camera pose
149 wMc_ = wMm_ * mMp_ * pMe_ * cMe_.inverse();
150
151 // Update the jacobian
153
154 break;
155 }
157 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the camera frame:"
158 "functionality not implemented");
160 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the reference frame:"
161 "functionality not implemented");
163 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the mixt frame:"
164 "functionality not implemented");
166 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the end-effector frame:"
167 "functionality not implemented");
168 }
169}
170
176
177/*
178 Get the current position of the robot.
179
180 \param frame : Control frame type in which to get the position, either :
181 - in the camera cartesian frame,
182 - joint (articular) coordinates of each axes (not implemented)
183 - in a reference or fixed cartesian frame attached to the robot base
184 - in a mixt cartesian frame (translation in reference frame, and rotation in
185 camera frame)
186
187 \param position : Measured position of the robot:
188 - in camera cartesian frame, a 6 dimension vector, set to 0.
189
190 - in articular, this functionality is not implemented.
191
192 - in reference frame, a 6 dimension vector, the first 3 values correspond to
193 the translation tx, ty, tz in meters (like a vpTranslationVector), and the
194 last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
195*/
197{
198 q.resize(6);
199
200 switch (frame) {
202 q = 0;
203 break;
204
206 std::cout << "ARTICULAR_FRAME is not implemented in "
207 "vpSimulatorPioneer::getPosition()"
208 << std::endl;
209 break;
211 // Convert wMc_ to a position
212 // From fMc extract the pose
214 this->wMc_.extract(wRc);
215 vpRxyzVector rxyz;
216 rxyz.buildFrom(wRc);
217
218 for (unsigned int i = 0; i < 3; i++) {
219 q[i] = this->wMc_[i][3]; // translation x,y,z
220 q[i + 3] = rxyz[i]; // Euler rotation x,y,z
221 }
222
223 break;
224 }
226 std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
227 break;
229 std::cout << "END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
230 break;
231 }
232}
233END_VISP_NAMESPACE
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
@ dimensionError
Bad dimension.
Definition vpException.h:71
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
void set_eJe(double q_pan)
void set_pMe(const double q)
vpHomogeneousMatrix mMp_
vpHomogeneousMatrix pMe_
Error that can be emitted by the vpRobot class and its derivatives.
@ wrongStateError
Wrong robot state.
int nDof
number of degrees of freedom
Definition vpRobot.h:101
virtual vpRobotStateType getRobotState(void) const
Definition vpRobot.h:152
double * qmin
Definition vpRobot.h:112
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition vpRobot.cpp:162
vpControlFrameType
Definition vpRobot.h:74
@ REFERENCE_FRAME
Definition vpRobot.h:75
@ ARTICULAR_FRAME
Definition vpRobot.h:77
@ MIXT_FRAME
Definition vpRobot.h:85
@ CAMERA_FRAME
Definition vpRobot.h:81
@ END_EFFECTOR_FRAME
Definition vpRobot.h:80
double * qmax
Definition vpRobot.h:113
int areJointLimitsAvailable
Definition vpRobot.h:111
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition vpRobot.h:109
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
Definition vpRobot.h:64
double getMaxRotationVelocity(void) const
Definition vpRobot.cpp:272
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition vpRobot.cpp:200
virtual void init()=0
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition vpRobot.h:105
double getMaxTranslationVelocity(void) const
Definition vpRobot.cpp:250
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition vpRobot.cpp:206
Implementation of a rotation matrix and operations on such kind of matrices.
Implementation of a rotation vector as Euler angle minimal representation.
vpRxyzVector & buildFrom(const vpRotationMatrix &R)
void getPosition(vpHomogeneousMatrix &wMc) const
vpHomogeneousMatrix wMc_
robot / camera location in the world frame
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Class that consider the case of a translation vector.
vpMatrix get_eJe() const
Definition vpUnicycle.h:96
vpHomogeneousMatrix cMe_
Definition vpUnicycle.h:116
#define vpERROR_TRACE
Definition vpDebug.h:423