Visual Servoing Platform version 3.7.0
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
52
61{
62 nDof = 6;
63 eJe.eye(6, 6);
64 eJeAvailable = true;
65 fJeAvailable = 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
85{
87 cVe = cVe_;
88}
89
98void vpSimulatorCamera::get_eJe(vpMatrix &eJe_) { eJe_ = this->eJe; }
99
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*/
133{
134 q.resize(6);
135
136 switch (frame) {
138 q = 0;
139 break;
140
143 // Convert wMc_ to a position
144 // From fMc extract the pose
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 }
158 std::cout << "MIXT_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
159 break;
161 std::cout << "END_EFFECTOR_FRAME is not implemented in vpSimulatorCamera::getPosition()" << std::endl;
162 break;
163 }
164}
165
189{
192 }
193
194 switch (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
207 setRobotFrame(frame);
208 break;
209 }
211 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the reference frame: "
212 "functionality not implemented");
214 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the mixt frame: "
215 "functionality not implemented");
217 throw vpRobotException(vpRobotException::wrongStateError, "Cannot set a velocity in the end-effector frame: "
218 "functionality not implemented");
219 }
220}
221
235END_VISP_NAMESPACE
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.
static double rad(double deg)
Definition vpMath.h:129
Implementation of a matrix and operations on matrices.
Definition vpMatrix.h:175
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
vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame)
Definition vpRobot.cpp:206
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)
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
vpHomogeneousMatrix wMc_
void setPosition(const vpHomogeneousMatrix &wMc)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
vpHomogeneousMatrix getPosition() const
void get_cVe(vpVelocityTwistMatrix &cVe) const