Visual Servoing Platform  version 3.6.1 under development (2024-11-14)
vpRobot.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Generic virtual robot.
33  *
34 *****************************************************************************/
35 
41 #ifndef vpRobot_H
42 #define vpRobot_H
43 
44 #include <visp3/core/vpColVector.h>
45 #include <visp3/core/vpConfig.h>
46 #include <visp3/core/vpHomogeneousMatrix.h>
47 #include <visp3/core/vpMatrix.h>
48 #include <visp3/core/vpPoseVector.h>
49 
50 BEGIN_VISP_NAMESPACE
58 class VISP_EXPORT vpRobot
59 {
60 public:
64  typedef enum
65  {
70  STATE_FORCE_TORQUE_CONTROL
71  } vpRobotStateType;
72 
76  typedef enum
77  {
78  REFERENCE_FRAME,
80  ARTICULAR_FRAME,
82  JOINT_STATE = ARTICULAR_FRAME,
84  CAMERA_FRAME,
86  TOOL_FRAME = CAMERA_FRAME,
88  MIXT_FRAME
91  } vpControlFrameType;
92 
93 private: /* Membres privees */
94  vpRobot::vpRobotStateType stateRobot;
95  vpRobot::vpControlFrameType frameRobot;
96 
97 protected:
99  static const double maxTranslationVelocityDefault; // = 0.2;
101  static const double maxRotationVelocityDefault; // = 0.7;
102 
104  int nDof;
113 
115  double *qmin;
116  double *qmax;
117 
118  bool verbose_;
119 
120 public:
121  vpRobot(void);
122  vpRobot(const vpRobot &robot);
123  virtual ~vpRobot();
124 
127 
128  //---------- Jacobian -----------------------------
130  virtual void get_eJe(vpMatrix &_eJe) = 0;
133  virtual void get_fJe(vpMatrix &_fJe) = 0;
134 
137  virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q) = 0;
138 
139  double getMaxTranslationVelocity(void) const;
140  double getMaxRotationVelocity(void) const;
141 
145  int getNDof() const
146  {
147  return nDof;
148  }
149 
151  virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position) = 0;
152 
153  // Return the robot position (frame has to be specified).
154  vpColVector getPosition(const vpRobot::vpControlFrameType frame);
155  virtual vpRobotStateType getRobotState(void) const { return stateRobot; }
156 
157  virtual void init() = 0;
158 
159  vpRobot &operator=(const vpRobot &robot);
160 
161  void setMaxRotationVelocity(double maxVr);
162  void setMaxTranslationVelocity(double maxVt);
164  virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) = 0;
165  virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState);
166 
169  virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) = 0;
170  inline void setVerbose(bool verbose) { verbose_ = verbose; };
171 
173 
176  static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose = false);
178 
179 protected:
182  vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame);
183  vpControlFrameType getRobotFrame(void) const { return frameRobot; }
185 };
186 END_VISP_NAMESPACE
187 #endif
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Class that defines a generic virtual robot.
Definition: vpRobot.h:59
int nDof
number of degrees of freedom
Definition: vpRobot.h:104
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
Definition: vpRobot.h:106
void setVerbose(bool verbose)
Definition: vpRobot.h:170
virtual vpRobotStateType getRobotState(void) const
Definition: vpRobot.h:155
double * qmin
Definition: vpRobot.h:115
vpControlFrameType
Definition: vpRobot.h:77
@ END_EFFECTOR_FRAME
Definition: vpRobot.h:83
static const double maxRotationVelocityDefault
Definition: vpRobot.h:101
virtual void get_eJe(vpMatrix &_eJe)=0
Get the robot Jacobian expressed in the end-effector frame.
virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)=0
vpControlFrameType getRobotFrame(void) const
Definition: vpRobot.h:183
double * qmax
Definition: vpRobot.h:116
int areJointLimitsAvailable
Definition: vpRobot.h:114
virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &position)=0
Get the robot position (frame has to be specified).
int fJeAvailable
is the robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:112
vpRobotStateType
Definition: vpRobot.h:65
@ STATE_POSITION_CONTROL
Initialize the position controller.
Definition: vpRobot.h:68
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
Definition: vpRobot.h:67
@ STATE_ACCELERATION_CONTROL
Initialize the acceleration controller.
Definition: vpRobot.h:69
@ STATE_STOP
Stops robot motion especially in velocity and acceleration control.
Definition: vpRobot.h:66
static const double maxTranslationVelocityDefault
Definition: vpRobot.h:99
vpMatrix fJe
robot Jacobian expressed in the robot reference frame available
Definition: vpRobot.h:110
virtual void init()=0
virtual void get_fJe(vpMatrix &_fJe)=0
double maxTranslationVelocity
Definition: vpRobot.h:98
int eJeAvailable
is the robot Jacobian expressed in the end-effector frame available
Definition: vpRobot.h:108
virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q)=0
double maxRotationVelocity
Definition: vpRobot.h:100
bool verbose_
Definition: vpRobot.h:118
virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)=0
Set a displacement (frame has to be specified) in position control.
int getNDof() const
Definition: vpRobot.h:145