Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpSimulatorCamera.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
* Defines the simplest robot : a free flying camera.
32
*/
33
38
39
#include <visp3/core/vpDebug.h>
40
#include <visp3/core/vpExponentialMap.h>
41
#include <visp3/core/vpHomogeneousMatrix.h>
42
#include <visp3/robot/vpRobotException.h>
43
#include <visp3/robot/vpSimulatorCamera.h>
44
45
BEGIN_VISP_NAMESPACE
51
vpSimulatorCamera::vpSimulatorCamera
() :
wMc_
() {
init
(); }
52
60
void
vpSimulatorCamera::init
()
61
{
62
nDof
= 6;
63
eJe
.
eye
(6, 6);
64
eJeAvailable
=
true
;
65
fJeAvailable
=
false
;
66
areJointLimitsAvailable
=
false
;
67
qmin
=
nullptr
;
68
qmax
=
nullptr
;
69
70
setMaxTranslationVelocity
(1.);
// vx, vy and vz max set to 1 m/s
71
setMaxRotationVelocity
(
vpMath::rad
(90));
// wx, wy and wz max set to 90 deg/s
72
}
73
84
void
vpSimulatorCamera::get_cVe
(
vpVelocityTwistMatrix
&cVe)
const
85
{
86
vpVelocityTwistMatrix
cVe_;
87
cVe = cVe_;
88
}
89
98
void
vpSimulatorCamera::get_eJe
(
vpMatrix
&eJe_) { eJe_ = this->
eJe
; }
99
104
void
vpSimulatorCamera::getPosition
(
vpHomogeneousMatrix
&wMc)
const
{ wMc = this->
wMc_
; }
109
vpHomogeneousMatrix
vpSimulatorCamera::getPosition
()
const
{
return
(this->
wMc_
); }
110
111
/*
112
Get the current position of the camera.
113
114
\param frame : Control frame type in which to get the position, either :
115
- in the camera cartesian frame,
116
- joint (articular) coordinates of each axes
117
- in a reference or fixed cartesian frame attached to the robot base
118
- in a mixt cartesian frame (translation in reference frame, and rotation in
119
camera frame)
120
121
\param position : Measured position of the robot:
122
- in camera cartesian frame, a 6 dimension vector, set to 0.
123
124
- in articular, a 6 dimension vector corresponding to the articular
125
position of each dof, first the 3 translations, then the 3
126
articular rotation positions represented by a vpRxyzVector.
127
128
- in reference frame, a 6 dimension vector, the first 3 values correspond to
129
the translation tx, ty, tz in meters (like a vpTranslationVector), and the
130
last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
131
*/
132
void
vpSimulatorCamera::getPosition
(
const
vpRobot::vpControlFrameType
frame,
vpColVector
&q)
133
{
134
q.
resize
(6);
135
136
switch
(frame) {
137
case
vpRobot::CAMERA_FRAME
:
138
q = 0;
139
break
;
140
141
case
vpRobot::ARTICULAR_FRAME
:
142
case
vpRobot::REFERENCE_FRAME
: {
143
// Convert wMc_ to a position
144
// From fMc extract the pose
145
vpRotationMatrix
wRc;
146
this->
wMc_
.extract(wRc);
147
vpRxyzVector
rxyz;
148
rxyz.
buildFrom
(wRc);
149
150
for
(
unsigned
int
i = 0; i < 3; i++) {
151
q[i] = this->
wMc_
[i][3];
// translation x,y,z
152
q[i + 3] = rxyz[i];
// Euler rotation x,y,z
153
}
154
155
break
;
156
}
157
case
vpRobot::MIXT_FRAME
:
158
std::cout <<
"MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
159
break
;
160
case
vpRobot::END_EFFECTOR_FRAME
:
161
std::cout <<
"END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
162
break
;
163
}
164
}
165
188
void
vpSimulatorCamera::setVelocity
(
const
vpRobot::vpControlFrameType
frame,
const
vpColVector
&v)
189
{
190
if
(
vpRobot::STATE_VELOCITY_CONTROL
!=
getRobotState
()) {
191
setRobotState
(
vpRobot::STATE_VELOCITY_CONTROL
);
192
}
193
194
switch
(frame) {
195
case
vpRobot::ARTICULAR_FRAME
:
196
case
vpRobot::CAMERA_FRAME
: {
197
vpColVector
v_max(6);
198
199
for
(
unsigned
int
i = 0; i < 3; i++)
200
v_max[i] =
getMaxTranslationVelocity
();
201
for
(
unsigned
int
i = 3; i < 6; i++)
202
v_max[i] =
getMaxRotationVelocity
();
203
204
vpColVector
v_sat =
vpRobot::saturateVelocities
(v, v_max,
true
);
205
206
wMc_
=
wMc_
*
vpExponentialMap::direct
(v_sat,
delta_t_
);
207
setRobotFrame
(frame);
208
break
;
209
}
210
case
vpRobot::REFERENCE_FRAME
:
211
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the reference frame: "
212
"functionality not implemented"
);
213
case
vpRobot::MIXT_FRAME
:
214
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the mixt frame: "
215
"functionality not implemented"
);
216
case
vpRobot::END_EFFECTOR_FRAME
:
217
throw
vpRobotException
(
vpRobotException::wrongStateError
,
"Cannot set a velocity in the end-effector frame: "
218
"functionality not implemented"
);
219
}
220
}
221
227
void
vpSimulatorCamera::setPosition
(
const
vpHomogeneousMatrix
&wMc)
228
{
229
if
(
vpRobot::STATE_POSITION_CONTROL
!=
getRobotState
()) {
230
setRobotState
(
vpRobot::STATE_POSITION_CONTROL
);
231
}
232
233
this->
wMc_
= wMc;
234
}
235
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
vpExponentialMap::direct
static vpHomogeneousMatrix direct(const vpColVector &v)
Definition
vpExponentialMap.cpp:54
vpHomogeneousMatrix
Implementation of an homogeneous matrix and operations on such kind of matrices.
Definition
vpHomogeneousMatrix.h:221
vpMath::rad
static double rad(double deg)
Definition
vpMath.h:129
vpMatrix
Implementation of a matrix and operations on matrices.
Definition
vpMatrix.h:175
vpMatrix::eye
void eye()
Definition
vpMatrix_operations.cpp:928
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::eJe
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition
vpRobot.h:103
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_POSITION_CONTROL
@ STATE_POSITION_CONTROL
Initialize the position controller.
Definition
vpRobot.h:65
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::setMaxRotationVelocity
void setMaxRotationVelocity(double maxVr)
Definition
vpRobot.cpp:259
vpRobot::setRobotFrame
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition
vpRobot.cpp:206
vpRobot::setMaxTranslationVelocity
void setMaxTranslationVelocity(double maxVt)
Definition
vpRobot.cpp:238
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
vpSimulatorCamera::get_eJe
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
Definition
vpSimulatorCamera.cpp:98
vpSimulatorCamera::wMc_
vpHomogeneousMatrix wMc_
Definition
vpSimulatorCamera.h:115
vpSimulatorCamera::setPosition
void setPosition(const vpHomogeneousMatrix &wMc)
Definition
vpSimulatorCamera.cpp:227
vpSimulatorCamera::setVelocity
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Definition
vpSimulatorCamera.cpp:188
vpSimulatorCamera::getPosition
vpHomogeneousMatrix getPosition() const
Definition
vpSimulatorCamera.cpp:109
vpSimulatorCamera::get_cVe
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition
vpSimulatorCamera.cpp:84
vpSimulatorCamera::vpSimulatorCamera
vpSimulatorCamera()
Definition
vpSimulatorCamera.cpp:51
vpVelocityTwistMatrix
Definition
vpVelocityTwistMatrix.h:175
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
robot
src
robot-simulator
vpSimulatorCamera.cpp
Generated by
1.17.0