Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
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
47
BEGIN_VISP_NAMESPACE
52
vpSimulatorPioneer::vpSimulatorPioneer
() :
wMc_
(),
wMe_
(),
xm_
(0),
ym_
(0),
theta_
(0) {
init
(); }
53
61
void
vpSimulatorPioneer::init
()
62
{
63
xm_
= 0;
64
ym_
= 0;
65
theta_
= 0;
66
67
nDof
= 2;
68
eJeAvailable
=
true
;
69
fJeAvailable
=
false
;
70
areJointLimitsAvailable
=
false
;
71
qmin
=
nullptr
;
72
qmax
=
nullptr
;
73
74
wMc_
=
wMe_
*
cMe_
.
inverse
();
75
}
76
84
void
vpSimulatorPioneer::get_eJe
(
vpMatrix
&_eJe) { _eJe =
vpUnicycle::get_eJe
(); }
85
103
void
vpSimulatorPioneer::setVelocity
(
const
vpRobot::vpControlFrameType
frame,
const
vpColVector
&v)
104
{
105
switch
(frame) {
106
case
vpRobot::ARTICULAR_FRAME
: {
107
if
(
vpRobot::STATE_VELOCITY_CONTROL
!=
getRobotState
()) {
108
setRobotState
(
vpRobot::STATE_VELOCITY_CONTROL
);
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
}
136
case
vpRobot::CAMERA_FRAME
:
137
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the camera frame:"
138
"functionality not implemented"
);
139
case
vpRobot::REFERENCE_FRAME
:
140
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the articular frame:"
141
"functionality not implemented"
);
142
case
vpRobot::MIXT_FRAME
:
143
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the mixt frame:"
144
"functionality not implemented"
);
145
case
vpRobot::END_EFFECTOR_FRAME
:
146
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the end-effector frame:"
147
"functionality not implemented"
);
148
}
149
}
150
155
void
vpSimulatorPioneer::getPosition
(
vpHomogeneousMatrix
&wMc)
const
{ wMc = this->
wMc_
; }
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
*/
176
void
vpSimulatorPioneer::getPosition
(
const
vpRobot::vpControlFrameType
frame,
vpColVector
&q)
177
{
178
q.
resize
(6);
179
180
switch
(frame) {
181
case
vpRobot::CAMERA_FRAME
:
182
q = 0;
183
break
;
184
185
case
vpRobot::ARTICULAR_FRAME
:
186
std::cout <<
"ARTICULAR_FRAME is not implemented in "
187
"vpSimulatorPioneer::getPosition()"
188
<< std::endl;
189
break
;
190
case
vpRobot::REFERENCE_FRAME
: {
191
// Convert wMc_ to a position
192
// From fMc extract the pose
193
vpRotationMatrix
wRc;
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
}
205
case
vpRobot::MIXT_FRAME
:
206
std::cout <<
"MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
207
break
;
208
case
vpRobot::END_EFFECTOR_FRAME
:
209
std::cout <<
"END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
210
break
;
211
}
212
}
213
END_VISP_NAMESPACE
vpColVector
Implementation of column vector and the associated operations.
Definition
vpColVector.h:191
vpColVector::resize
void resize(unsigned int i, bool flagNullify=true)
Definition
vpColVector.h:1159
vpException::dimensionError
@ dimensionError
Bad dimension.
Definition
vpException.h:71
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpHomogeneousMatrix::inverse
vpHomogeneousMatrix inverse() const
Definition
vpHomogeneousMatrix.cpp:1016
vpMatrix
Implementation of a matrix and operations on matrices.
Definition
vpMatrix.h:175
vpRobotException
Error that can be emitted by the vpRobot class and its derivatives.
Definition
vpRobotException.h:54
vpRobotException::wrongStateError
@ wrongStateError
Wrong robot state.
Definition
vpRobotException.h:70
vpRobotSimulator::delta_t_
double delta_t_
Definition
vpRobotSimulator.h:60
vpRobot::nDof
int nDof
number of degrees of freedom
Definition
vpRobot.h:101
vpRobot::getRobotState
virtual vpRobotStateType getRobotState(void) const
Definition
vpRobot.h:152
vpRobot::qmin
double * qmin
Definition
vpRobot.h:112
vpRobot::saturateVelocities
static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose=false)
Definition
vpRobot.cpp:162
vpRobot::vpControlFrameType
vpControlFrameType
Definition
vpRobot.h:74
vpRobot::REFERENCE_FRAME
@ REFERENCE_FRAME
Definition
vpRobot.h:75
vpRobot::ARTICULAR_FRAME
@ ARTICULAR_FRAME
Definition
vpRobot.h:77
vpRobot::MIXT_FRAME
@ MIXT_FRAME
Definition
vpRobot.h:85
vpRobot::CAMERA_FRAME
@ CAMERA_FRAME
Definition
vpRobot.h:81
vpRobot::END_EFFECTOR_FRAME
@ END_EFFECTOR_FRAME
Definition
vpRobot.h:80
vpRobot::qmax
double * qmax
Definition
vpRobot.h:113
vpRobot::areJointLimitsAvailable
int areJointLimitsAvailable
Definition
vpRobot.h:111
vpRobot::fJeAvailable
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition
vpRobot.h:109
vpRobot::STATE_VELOCITY_CONTROL
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
Definition
vpRobot.h:64
vpRobot::getMaxRotationVelocity
double getMaxRotationVelocity(void) const
Definition
vpRobot.cpp:272
vpRobot::setRobotState
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Definition
vpRobot.cpp:200
vpRobot::init
virtual void init()=0
vpRobot::eJeAvailable
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition
vpRobot.h:105
vpRobot::getMaxTranslationVelocity
double getMaxTranslationVelocity(void) const
Definition
vpRobot.cpp:250
vpRobot::setRobotFrame
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition
vpRobot.cpp:206
vpRotationMatrix
Implementation of a rotation matrix and operations on such kind of matrices.
Definition
vpRotationMatrix.h:130
vpRxyzVector
Implementation of a rotation vector as Euler angle minimal representation.
Definition
vpRxyzVector.h:183
vpRxyzVector::buildFrom
vpRxyzVector & buildFrom(const vpRotationMatrix &R)
Definition
vpRxyzVector.cpp:85
vpSimulatorPioneer::ym_
double ym_
Definition
vpSimulatorPioneer.h:119
vpSimulatorPioneer::vpSimulatorPioneer
vpSimulatorPioneer()
Definition
vpSimulatorPioneer.cpp:52
vpSimulatorPioneer::wMc_
vpHomogeneousMatrix wMc_
Definition
vpSimulatorPioneer.h:112
vpSimulatorPioneer::setVelocity
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Definition
vpSimulatorPioneer.cpp:103
vpSimulatorPioneer::xm_
double xm_
Definition
vpSimulatorPioneer.h:118
vpSimulatorPioneer::getPosition
void getPosition(vpHomogeneousMatrix &wMc) const
Definition
vpSimulatorPioneer.cpp:155
vpSimulatorPioneer::wMe_
vpHomogeneousMatrix wMe_
Definition
vpSimulatorPioneer.h:115
vpSimulatorPioneer::theta_
double theta_
Definition
vpSimulatorPioneer.h:120
vpTranslationVector
Class that consider the case of a translation vector.
Definition
vpTranslationVector.h:119
vpUnicycle::get_eJe
vpMatrix get_eJe() const
Definition
vpUnicycle.h:96
vpUnicycle::cMe_
vpHomogeneousMatrix cMe_
Definition
vpUnicycle.h:116
vpERROR_TRACE
#define vpERROR_TRACE
Definition
vpDebug.h:423
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
robot
src
robot-simulator
vpSimulatorPioneer.cpp
Generated by
1.17.0