1 /**************************************************************************** 2 * 3 * ViSP, open source Visual Servoing Platform software. 4 * Copyright (C) 2005 - 2019 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 http://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 * Authors: 35 * Eric Marchand 36 * 37 *****************************************************************************/ 38 39 #ifndef vpRobot_H 40 #define vpRobot_H 41 42 /*! 43 \file vpRobot.h 44 \brief class that defines a generic virtual robot 45 */ 46 47 #include <visp3/core/vpColVector.h> 48 #include <visp3/core/vpHomogeneousMatrix.h> 49 #include <visp3/core/vpMatrix.h> 50 #include <visp3/core/vpPoseVector.h> 51 52 /*! 53 \class vpRobot 54 \ingroup group_robot_real_gantry group_robot_real_cylindrical 55 group_robot_real_arm \ingroup group_robot_real_ptu group_robot_real_unicycle 56 group_robot_real_template \brief Class that defines a generic virtual robot. 57 */ 58 class VISP_EXPORT vpRobot 59 { 60 public: 61 /*! 62 Robot control states. 63 */ 64 typedef enum { 65 STATE_STOP, //!< Stops robot motion especially in velocity and acceleration control. 66 STATE_VELOCITY_CONTROL, //!< Initialize the velocity controller. 67 STATE_POSITION_CONTROL, //!< Initialize the position controller. 68 STATE_ACCELERATION_CONTROL, //!< Initialize the acceleration controller. 69 STATE_FORCE_TORQUE_CONTROL //!< Initialize the force/torque controller. 70 } vpRobotStateType; 71 72 /*! 73 Robot control frames. 74 */ 75 typedef enum { 76 REFERENCE_FRAME, /*!< Corresponds to a fixed reference frame 77 attached to the robot structure. */ 78 ARTICULAR_FRAME, /*!< Corresponds to the joint state. This value is deprecated. 79 You should rather use vpRobot::JOINT_STATE. */ 80 JOINT_STATE = ARTICULAR_FRAME, /*!< Corresponds to the joint state. */ 81 END_EFFECTOR_FRAME, /*!< Corresponds to robot end-effector frame. */ 82 CAMERA_FRAME, /*!< Corresponds to a frame attached to the 83 camera mounted on the robot end-effector. */ 84 TOOL_FRAME = CAMERA_FRAME, /*!< Corresponds to a frame attached to the 85 tool (camera, gripper...) mounted on the robot end-effector. This value is equal to vpRobot::CAMERA_FRAME. */ 86 MIXT_FRAME /*!< Corresponds to a "virtual" frame where 87 translations are expressed in the reference frame, and 88 rotations in the camera frame.*/ 89 } vpControlFrameType; 90 91 private: /* Membres privees */ 92 vpRobot::vpRobotStateType stateRobot; 93 vpRobot::vpControlFrameType frameRobot; 94 95 protected: 96 double maxTranslationVelocity; 97 static const double maxTranslationVelocityDefault; // = 0.2; 98 double maxRotationVelocity; 99 static const double maxRotationVelocityDefault; // = 0.7; 100 101 //! number of degrees of freedom 102 int nDof; 103 //! robot Jacobian expressed in the end-effector frame 104 vpMatrix eJe; 105 //! is the robot Jacobian expressed in the end-effector frame available 106 int eJeAvailable; 107 //! robot Jacobian expressed in the robot reference frame available 108 vpMatrix fJe; 109 //! is the robot Jacobian expressed in the robot reference frame available 110 int fJeAvailable; 111 112 int areJointLimitsAvailable; 113 double *qmin; 114 double *qmax; 115 116 bool verbose_; 117 118 public: 119 vpRobot(void); 120 vpRobot(const vpRobot &robot); 121 virtual ~vpRobot(); 122 123 /** @name Inherited functionalities from vpRobot */ 124 //@{ 125 126 //---------- Jacobian ----------------------------- 127 //! Get the robot Jacobian expressed in the end-effector frame 128 virtual void get_eJe(vpMatrix &_eJe) = 0; 129 //! Get the robot Jacobian expressed in the robot reference (or world) 130 //! frame. 131 virtual void get_fJe(vpMatrix &_fJe) = 0; 132 133 //! Get a displacement (frame as to ve specified) between two successive 134 //! position control. 135 virtual void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &q) = 0; 136 137 double getMaxTranslationVelocity(void) const; 138 double getMaxRotationVelocity(void) const; 139 //! Get the robot position (frame has to be specified). 140 virtual void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) = 0; 141 142 // Return the robot position (frame has to be specified). 143 vpColVector getPosition(const vpRobot::vpControlFrameType frame); getRobotState(void)144 virtual vpRobotStateType getRobotState(void) const { return stateRobot; } 145 146 virtual void init() = 0; 147 148 vpRobot &operator=(const vpRobot &robot); 149 150 void setMaxRotationVelocity(double maxVr); 151 void setMaxTranslationVelocity(double maxVt); 152 //! Set a displacement (frame has to be specified) in position control. 153 virtual void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) = 0; 154 virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState); 155 156 //! Set the velocity (frame has to be specified) that will be applied to the 157 //! velocity controller. 158 virtual void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) = 0; setVerbose(bool verbose)159 inline void setVerbose(bool verbose) { verbose_ = verbose; }; 160 161 //@} 162 163 /** @name Static Public Member Functions inherited from vpRobot */ 164 //@{ 165 static vpColVector saturateVelocities(const vpColVector &v_in, const vpColVector &v_max, bool verbose = false); 166 //@} 167 168 protected: 169 /** @name Protected Member Functions Inherited from vpRobot */ 170 //@{ 171 vpControlFrameType setRobotFrame(vpRobot::vpControlFrameType newFrame); getRobotFrame(void)172 vpControlFrameType getRobotFrame(void) const { return frameRobot; } 173 //@} 174 }; 175 176 #endif 177