Visual Servoing Platform version 3.7.0
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
69
78{
79 nDof = 6;
80 eJe.eye(6, 6);
81 eJeAvailable = true;
82 fJeAvailable = 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
102{
104 cVe = cVe_;
105}
106
114void vpRobotCamera::get_eJe(vpMatrix &eJe_) { eJe_ = this->eJe; }
115
139{
140 switch (frame) {
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 }
160 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the reference frame:"
161 "functionality not implemented");
163 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the mixt frame:"
164 "functionality not implemented");
166 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the end-effector frame:"
167 "functionality not implemented");
168 }
169}
170
175void 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*/
199{
200 q.resize(6);
201
202 switch (frame) {
204 q = 0;
205 break;
206
209 // Convert wMc_ to a position
210 // From fMc extract the pose
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 }
224 std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
225 break;
227 std::cout << "END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
228 break;
229 }
230}
231
244END_VISP_NAMESPACE
245#elif !defined(VISP_BUILD_SHARED_LIBS)
246// Work around to avoid warning: libvisp_robot.a(vpRobotCamera.cpp.o) has no symbols
247void dummy_vpRobotCamera() { }
248#endif
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
static vpHomogeneousMatrix direct(const vpColVector &v)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static double rad(double deg)
Definition vpMath.h:129
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
void setPosition(const vpHomogeneousMatrix &cMw)
void get_cVe(vpVelocityTwistMatrix &cVe) const
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v) VP_OVERRIDE
vpHomogeneousMatrix cMw_
void getPosition(vpHomogeneousMatrix &cMw) const
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
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition vpRobot.h:103
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_POSITION_CONTROL
Initialize the position controller.
Definition vpRobot.h:65
@ 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
void setMaxRotationVelocity(double maxVr)
Definition vpRobot.cpp:259
void setMaxTranslationVelocity(double maxVt)
Definition vpRobot.cpp:238
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)