Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpRobotCamera.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/robot/vpRobotCamera.h>
40
41
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
42
43
#include <visp3/core/vpDebug.h>
44
#include <visp3/core/vpExponentialMap.h>
45
#include <visp3/core/vpHomogeneousMatrix.h>
46
#include <visp3/robot/vpRobotException.h>
47
48
BEGIN_VISP_NAMESPACE
68
vpRobotCamera::vpRobotCamera
() :
cMw_
() {
init
(); }
69
77
void
vpRobotCamera::init
()
78
{
79
nDof
= 6;
80
eJe
.
eye
(6, 6);
81
eJeAvailable
=
true
;
82
fJeAvailable
=
false
;
83
areJointLimitsAvailable
=
false
;
84
qmin
=
nullptr
;
85
qmax
=
nullptr
;
86
87
setMaxTranslationVelocity
(1.);
// vx, vy and vz max set to 1 m/s
88
setMaxRotationVelocity
(
vpMath::rad
(90));
// wx, wy and wz max set to 90 deg/s
89
}
90
101
void
vpRobotCamera::get_cVe
(
vpVelocityTwistMatrix
&cVe)
const
102
{
103
vpVelocityTwistMatrix
cVe_;
104
cVe = cVe_;
105
}
106
114
void
vpRobotCamera::get_eJe
(
vpMatrix
&eJe_) { eJe_ = this->
eJe
; }
115
138
void
vpRobotCamera::setVelocity
(
const
vpRobot::vpControlFrameType
frame,
const
vpColVector
&v)
139
{
140
switch
(frame) {
141
case
vpRobot::ARTICULAR_FRAME
:
142
case
vpRobot::CAMERA_FRAME
: {
143
if
(
vpRobot::STATE_VELOCITY_CONTROL
!=
getRobotState
()) {
144
setRobotState
(
vpRobot::STATE_VELOCITY_CONTROL
);
145
}
146
147
vpColVector
v_max(6);
148
149
for
(
unsigned
int
i = 0; i < 3; i++)
150
v_max[i] =
getMaxTranslationVelocity
();
151
for
(
unsigned
int
i = 3; i < 6; i++)
152
v_max[i] =
getMaxRotationVelocity
();
153
154
vpColVector
v_sat =
vpRobot::saturateVelocities
(v, v_max,
true
);
155
156
this->
cMw_
=
vpExponentialMap::direct
(v_sat,
delta_t_
).
inverse
() * this->
cMw_
;
157
break
;
158
}
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
vpRobotCamera::getPosition
(
vpHomogeneousMatrix
&cMw)
const
{ cMw = this->
cMw_
; }
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
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, a 6 dimension vector corresponding to the articular
191
position of each dof, first the 3 translations, then the 3
192
articular rotation positions represented by a vpRxyzVector.
193
194
- in reference frame, a 6 dimension vector, the first 3 values correspond to
195
the translation tx, ty, tz in meters (like a vpTranslationVector), and the
196
last 3 values to the rx, ry, rz rotation (like a vpRxyzVector).
197
*/
198
void
vpRobotCamera::getPosition
(
const
vpRobot::vpControlFrameType
frame,
vpColVector
&q)
199
{
200
q.
resize
(6);
201
202
switch
(frame) {
203
case
vpRobot::CAMERA_FRAME
:
204
q = 0;
205
break
;
206
207
case
vpRobot::ARTICULAR_FRAME
:
208
case
vpRobot::REFERENCE_FRAME
: {
209
// Convert wMc_ to a position
210
// From fMc extract the pose
211
vpRotationMatrix
cRw;
212
this->
cMw_
.extract(cRw);
213
vpRxyzVector
rxyz;
214
rxyz.
buildFrom
(cRw);
215
216
for
(
unsigned
int
i = 0; i < 3; i++) {
217
q[i] = this->
cMw_
[i][3];
// translation x,y,z
218
q[i + 3] = rxyz[i];
// Euler rotation x,y,z
219
}
220
221
break
;
222
}
223
case
vpRobot::MIXT_FRAME
:
224
std::cout <<
"MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
225
break
;
226
case
vpRobot::END_EFFECTOR_FRAME
:
227
std::cout <<
"END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()"
<< std::endl;
228
break
;
229
}
230
}
231
236
void
vpRobotCamera::setPosition
(
const
vpHomogeneousMatrix
&cMw)
237
{
238
if
(
vpRobot::STATE_POSITION_CONTROL
!=
getRobotState
()) {
239
setRobotState
(
vpRobot::STATE_POSITION_CONTROL
);
240
}
241
242
this->
cMw_
= cMw;
243
}
244
END_VISP_NAMESPACE
245
#elif !defined(VISP_BUILD_SHARED_LIBS)
246
// Work around to avoid warning: libvisp_robot.a(vpRobotCamera.cpp.o) has no symbols
247
void
dummy_vpRobotCamera() { }
248
#endif
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
vpHomogeneousMatrix::inverse
vpHomogeneousMatrix inverse() const
Definition
vpHomogeneousMatrix.cpp:1016
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
vpRobotCamera::get_eJe
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
Definition
vpRobotCamera.cpp:114
vpRobotCamera::setPosition
void setPosition(const vpHomogeneousMatrix &cMw)
Definition
vpRobotCamera.cpp:236
vpRobotCamera::get_cVe
void get_cVe(vpVelocityTwistMatrix &cVe) const
Definition
vpRobotCamera.cpp:101
vpRobotCamera::vpRobotCamera
vpRobotCamera()
Definition
vpRobotCamera.cpp:68
vpRobotCamera::setVelocity
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v) VP_OVERRIDE
Definition
vpRobotCamera.cpp:138
vpRobotCamera::cMw_
vpHomogeneousMatrix cMw_
Definition
vpRobotCamera.h:113
vpRobotCamera::getPosition
void getPosition(vpHomogeneousMatrix &cMw) const
Definition
vpRobotCamera.cpp: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::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::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
vpVelocityTwistMatrix
Definition
vpVelocityTwistMatrix.h:175
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
robot
src
robot-simulator
vpRobotCamera.cpp
Generated by
1.17.0