Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
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
46
BEGIN_VISP_NAMESPACE
56
vpSimulatorPioneerPan::vpSimulatorPioneerPan
() :
wMc_
(),
wMm_
(),
xm_
(0),
ym_
(0),
theta_
(0),
q_pan_
() {
init
(); }
57
68
void
vpSimulatorPioneerPan::init
()
69
{
70
xm_
= 0;
71
ym_
= 0;
72
theta_
= 0;
73
q_pan_
= 0;
74
75
nDof
= 3;
76
eJeAvailable
=
true
;
77
fJeAvailable
=
false
;
78
areJointLimitsAvailable
=
false
;
79
qmin
=
nullptr
;
80
qmax
=
nullptr
;
81
82
wMc_
=
wMm_
*
mMp_
*
pMe_
*
cMe_
.
inverse
();
83
}
84
92
void
vpSimulatorPioneerPan::get_eJe
(
vpMatrix
&_eJe) { _eJe =
vpUnicycle::get_eJe
(); }
93
112
void
vpSimulatorPioneerPan::setVelocity
(
const
vpRobot::vpControlFrameType
frame,
const
vpColVector
&v)
113
{
114
switch
(frame) {
115
case
vpRobot::ARTICULAR_FRAME
: {
116
if
(
vpRobot::STATE_VELOCITY_CONTROL
!=
getRobotState
()) {
117
setRobotState
(
vpRobot::STATE_VELOCITY_CONTROL
);
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
146
set_pMe
(
q_pan_
);
147
148
// Update the camera pose
149
wMc_
=
wMm_
*
mMp_
*
pMe_
*
cMe_
.inverse();
150
151
// Update the jacobian
152
set_eJe
(
q_pan_
);
153
154
break
;
155
}
156
case
vpRobot::CAMERA_FRAME
:
157
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the camera frame:"
158
"functionality not implemented"
);
159
case
vpRobot::REFERENCE_FRAME
:
160
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the reference frame:"
161
"functionality not implemented"
);
162
case
vpRobot::MIXT_FRAME
:
163
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the mixt frame:"
164
"functionality not implemented"
);
165
case
vpRobot::END_EFFECTOR_FRAME
:
166
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the end-effector frame:"
167
"functionality not implemented"
);
168
}
169
}
170
175
void
vpSimulatorPioneerPan::getPosition
(
vpHomogeneousMatrix
&wMc)
const
{ wMc = this->
wMc_
; }
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
*/
196
void
vpSimulatorPioneerPan::getPosition
(
const
vpRobot::vpControlFrameType
frame,
vpColVector
&q)
197
{
198
q.
resize
(6);
199
200
switch
(frame) {
201
case
vpRobot::CAMERA_FRAME
:
202
q = 0;
203
break
;
204
205
case
vpRobot::ARTICULAR_FRAME
:
206
std::cout <<
"ARTICULAR_FRAME is not implemented in "
207
"vpSimulatorPioneer::getPosition()"
208
<< std::endl;
209
break
;
210
case
vpRobot::REFERENCE_FRAME
: {
211
// Convert wMc_ to a position
212
// From fMc extract the pose
213
vpRotationMatrix
wRc;
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
}
225
case
vpRobot::MIXT_FRAME
:
226
std::cout <<
"MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
227
break
;
228
case
vpRobot::END_EFFECTOR_FRAME
:
229
std::cout <<
"END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
230
break
;
231
}
232
}
233
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
vpPioneerPan::set_eJe
void set_eJe(double q_pan)
Definition
vpPioneerPan.h:135
vpPioneerPan::set_pMe
void set_pMe(const double q)
Definition
vpPioneerPan.h:210
vpPioneerPan::mMp_
vpHomogeneousMatrix mMp_
Definition
vpPioneerPan.h:224
vpPioneerPan::pMe_
vpHomogeneousMatrix pMe_
Definition
vpPioneerPan.h:225
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
vpSimulatorPioneerPan::q_pan_
double q_pan_
Definition
vpSimulatorPioneerPan.h:117
vpSimulatorPioneerPan::getPosition
void getPosition(vpHomogeneousMatrix &wMc) const
Definition
vpSimulatorPioneerPan.cpp:175
vpSimulatorPioneerPan::ym_
double ym_
Definition
vpSimulatorPioneerPan.h:115
vpSimulatorPioneerPan::vpSimulatorPioneerPan
vpSimulatorPioneerPan()
Definition
vpSimulatorPioneerPan.cpp:56
vpSimulatorPioneerPan::xm_
double xm_
Definition
vpSimulatorPioneerPan.h:114
vpSimulatorPioneerPan::wMm_
vpHomogeneousMatrix wMm_
Definition
vpSimulatorPioneerPan.h:109
vpSimulatorPioneerPan::wMc_
vpHomogeneousMatrix wMc_
robot / camera location in the world frame
Definition
vpSimulatorPioneerPan.h:108
vpSimulatorPioneerPan::setVelocity
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Definition
vpSimulatorPioneerPan.cpp:112
vpSimulatorPioneerPan::theta_
double theta_
Definition
vpSimulatorPioneerPan.h:116
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
vpSimulatorPioneerPan.cpp
Generated by
1.17.0