Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpSimulatorPioneer.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 simulator without display.
32 */
33
40
41#include <visp3/core/vpDebug.h>
42#include <visp3/core/vpExponentialMap.h>
43#include <visp3/core/vpHomogeneousMatrix.h>
44#include <visp3/robot/vpRobotException.h>
45#include <visp3/robot/vpSimulatorPioneer.h>
46
53
62{
63 xm_ = 0;
64 ym_ = 0;
65 theta_ = 0;
66
67 nDof = 2;
68 eJeAvailable = true;
69 fJeAvailable = false;
71 qmin = nullptr;
72 qmax = nullptr;
73
74 wMc_ = wMe_ * cMe_.inverse();
75}
76
85
104{
105 switch (frame) {
109 }
110 setRobotFrame(frame);
111
112 // v is a 2 dimension vector that contains v,w
113 if (v.size() != 2) {
114 vpERROR_TRACE("Bad dimension of the control vector");
115 throw vpRobotException(vpRobotException::dimensionError, "Bad dimension of the control vector");
116 }
117
118 vpColVector v_max(2);
119
120 v_max[0] = getMaxTranslationVelocity();
121 v_max[1] = getMaxRotationVelocity();
122
123 vpColVector v_sat = vpRobot::saturateVelocities(v, v_max, true);
124
125 xm_ += delta_t_ * v_sat[0] * cos(theta_);
126 ym_ += delta_t_ * v_sat[0] * sin(theta_);
127 theta_ += delta_t_ * v_sat[1];
128
129 vpRotationMatrix wRe(0, 0, theta_);
130 vpTranslationVector wte(xm_, ym_, 0);
131 wMe_.buildFrom(wte, wRe);
132 wMc_ = wMe_ * cMe_.inverse();
133
134 break;
135 }
137 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the camera frame:"
138 "functionality not implemented");
140 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the articular frame:"
141 "functionality not implemented");
143 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the mixt frame:"
144 "functionality not implemented");
146 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the end-effector frame:"
147 "functionality not implemented");
148 }
149}
150
156
157/*
158 Get the current position of the robot.
159
160 \param frame : Control frame type in which to get the position, either :
161 - in the camera cartesian frame,
162 - joint (articular) coordinates of each axes (not implemented)
163 - in a reference or fixed cartesian frame attached to the robot base
164 - in a mixt cartesian frame (translation in reference frame, and rotation in
165 camera frame)
166
167 \param position : Measured position of the robot:
168 - in camera cartesian frame, a 6 dimension vector, set to 0.
169
170 - in articular, this functionality is not implemented.
171
172 - in reference frame, a 6 dimension vector, the first 3 values correspond to
173 the translation tx, ty, tz in meters (like a vpTranslationVector), and the
174 last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
175*/
177{
178 q.resize(6);
179
180 switch (frame) {
182 q = 0;
183 break;
184
186 std::cout << "ARTICULAR_FRAME is not implemented in "
187 "vpSimulatorPioneer::getPosition()"
188 << std::endl;
189 break;
191 // Convert wMc_ to a position
192 // From fMc extract the pose
194 this->wMc_.extract(wRc);
195 vpRxyzVector rxyz;
196 rxyz.buildFrom(wRc);
197
198 for (unsigned int i = 0; i < 3; i++) {
199 q[i] = this->wMc_[i][3]; // translation x,y,z
200 q[i + 3] = rxyz[i]; // Euler rotation x,y,z
201 }
202
203 break;
204 }
206 std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
207 break;
209 std::cout << "END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
210 break;
211 }
212}
213END_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
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)
vpHomogeneousMatrix wMc_
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
void getPosition(vpHomogeneousMatrix &wMc) const
vpHomogeneousMatrix wMe_
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