vpRobotFrankaSim.h
Go to the documentation of this file.
1 /*
2  * This file is part of the ViSP software.
3  * Copyright (C) 2005 - 2021 by INRIA. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * ("GPL") version 2 as published by the Free Software Foundation.
8  * See the file LICENSE.txt at the root directory of this source
9  * distribution for additional information about the GNU GPL.
10  *
11  * For using ViSP with software that can not be combined with the GNU
12  * GPL, please contact INRIA about acquiring a ViSP Professional
13  * Edition License.
14  *
15  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
16  *
17  * This software was developed at:
18  * INRIA Rennes - Bretagne Atlantique
19  * Campus Universitaire de Beaulieu
20  * 35042 Rennes Cedex
21  * France
22  * http://www.irisa.fr/lagadic
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  * Franka robot simulator.
32  *
33  * Authors:
34  * Alexander Oliva
35  * Fabien Spindler
36  */
37 
38 #ifndef vpRobotFrankaSim_h
39 #define vpRobotFrankaSim_h
40 
41 #include <atomic>
42 #include <mutex>
43 #include <thread>
44 
45 #include <visp3/core/vpConfig.h>
46 #include <visp3/core/vpPoseVector.h>
47 #include <visp3/core/vpThetaUVector.h>
48 #include <visp3/robot/vpRobot.h>
49 
50 #if defined( VISP_HAVE_OROCOS_KDL )
51 
52 #ifdef VISP_HAVE_OROCOS_KDL
53 #include <kdl/chain.hpp>
54 #include <kdl/chainfksolver.hpp>
55 #include <kdl/chainfksolverpos_recursive.hpp>
56 #include <kdl/chainiksolverpos_nr.hpp>
57 #include <kdl/chainiksolverpos_nr_jl.hpp>
58 #include <kdl/chainiksolvervel_pinv.hpp>
59 #include <kdl/chainjnttojacsolver.hpp>
60 #include <kdl/frames_io.hpp>
61 #include <kdl/solveri.hpp>
62 #endif
63 
67 class VISP_EXPORT vpRobotFrankaSim
68 {
69 public:
71  virtual ~vpRobotFrankaSim();
72 
73  vpRobot::vpRobotStateType getRobotState( void );
74 
75  void get_fJe( vpMatrix &fJe );
76  void get_fJe( const vpColVector &q, vpMatrix &fJe );
77  void get_eJe( vpMatrix &eJe_ );
78  void get_eJe( const vpColVector &q, vpMatrix &fJe );
79  vpHomogeneousMatrix get_eMc() const;
80  vpHomogeneousMatrix get_fMe( const vpColVector &q );
81  vpHomogeneousMatrix get_fMe();
82  vpHomogeneousMatrix get_flMe() const;
83  vpHomogeneousMatrix get_flMcom() const;
84  double get_tool_mass() const;
85 
86  void getGravity( vpColVector &gravity );
87  void getMass( vpMatrix &mass );
88  void getCoriolis( vpColVector &coriolis );
89  void getCoriolisMatrix( vpMatrix &coriolis );
90  void getFriction( vpColVector &friction );
91 
92  virtual void getForceTorque( const vpRobot::vpControlFrameType frame, vpColVector &force );
93  virtual void getPosition( const vpRobot::vpControlFrameType frame, vpColVector &position );
94  virtual void getPosition( const vpRobot::vpControlFrameType frame, vpPoseVector &position );
95  virtual void getVelocity( const vpRobot::vpControlFrameType frame, vpColVector &d_position );
96 
97  virtual void set_eMc( const vpHomogeneousMatrix &eMc );
98  virtual void setForceTorque( const vpRobot::vpControlFrameType frame, const vpColVector &force );
99  virtual void setPosition( const vpRobot::vpControlFrameType frame, const vpColVector &position );
100  virtual void setVelocity( const vpRobot::vpControlFrameType frame, const vpColVector &vel );
101 
102  virtual void add_tool( const vpHomogeneousMatrix &flMe, const double mL, const vpHomogeneousMatrix &flMcom,
103  const vpMatrix &I_L );
104  virtual void set_flMe( const vpHomogeneousMatrix &flMe );
105  virtual void set_g0( const vpColVector &g0 );
106 
111  inline void setVerbose( bool verbose ) { m_verbose = verbose; }
112 
113 protected:
114  vpColVector m_q; // Joint Positions
115  vpColVector m_dq; // Joint Velocities
116  vpColVector m_tau_J; // Joint efforts
117 
118  double m_mL; // payload mass
119  vpHomogeneousMatrix m_flMcom; // payload Center of Mass pose in flange frame
120  vpMatrix m_Il; // payload inertia tensor
121  vpHomogeneousMatrix m_flMe; // End-effector pose in flange frame
122  bool m_toolMounted; // flag to indicate the presence of a tool
123  bool m_camMounted; // flag to indicate the presence of a camera
124 
125  vpColVector m_g0; // Absolute gravitational acceleration vector in base frame
126 
127  std::mutex m_mutex;
128 
129  vpColVector solveIK( const vpHomogeneousMatrix &edMw );
130  vpColVector getVelDes();
131 
132 #ifdef VISP_HAVE_OROCOS_KDL
133  KDL::JntArray m_q_kdl;
134  KDL::JntArray m_dq_des_kdl;
135  KDL::Chain m_chain_kdl;
136  KDL::JntArray m_q_min_kdl;
137  KDL::JntArray m_q_max_kdl;
138  KDL::ChainFkSolverPos_recursive *m_fksolver_kdl;
139  KDL::ChainJntToJacSolver *m_jacobianSolver_kdl;
140  KDL::ChainIkSolverVel_pinv *m_diffIkSolver_kdl;
141  KDL::ChainIkSolverPos_NR_JL *m_iksolver_JL_kdl;
142 #endif
143 
144  vpRobot::vpRobotStateType m_stateRobot;
145 
146  vpColVector m_q_des; // Desired joint position.
147 
148  vpColVector m_dq_des; // Desired joint velocity.
149  vpColVector m_dq_des_filt; // Desired joint velocity filtered.
150  vpColVector m_v_cart_des; // Desired Cartesian velocity in end-effector frame.
151 
152  vpColVector m_tau_J_des; // Desired joint torques.
153  vpColVector m_tau_J_des_filt; // Desired joint torques filtered.
154 
155  vpHomogeneousMatrix m_eMc; // Transformation of the camera w.r.t. End-Effector frame
156  vpVelocityTwistMatrix m_eVc;
157 
158  bool m_verbose;
159 };
160 
161 #endif
162 #endif
vpRobotFrankaSim::m_q_max_kdl
KDL::JntArray m_q_max_kdl
Definition: vpRobotFrankaSim.h:137
vpRobotFrankaSim::m_q_des
vpColVector m_q_des
Definition: vpRobotFrankaSim.h:146
vpRobotFrankaSim::m_toolMounted
bool m_toolMounted
Definition: vpRobotFrankaSim.h:122
vpRobotFrankaSim::m_tau_J
vpColVector m_tau_J
Definition: vpRobotFrankaSim.h:116
vpRobotFrankaSim::m_chain_kdl
KDL::Chain m_chain_kdl
Definition: vpRobotFrankaSim.h:135
vpRobotFrankaSim::m_dq_des
vpColVector m_dq_des
Definition: vpRobotFrankaSim.h:148
vpRobotFrankaSim
Definition: vpRobotFrankaSim.h:67
vpRobotFrankaSim::m_g0
vpColVector m_g0
Definition: vpRobotFrankaSim.h:125
vpRobotFrankaSim::m_q_kdl
KDL::JntArray m_q_kdl
Definition: vpRobotFrankaSim.h:133
vpRobotFrankaSim::m_diffIkSolver_kdl
KDL::ChainIkSolverVel_pinv * m_diffIkSolver_kdl
Definition: vpRobotFrankaSim.h:140
vpRobotFrankaSim::m_dq_des_kdl
KDL::JntArray m_dq_des_kdl
Definition: vpRobotFrankaSim.h:134
vpRobotFrankaSim::setVerbose
void setVerbose(bool verbose)
Definition: vpRobotFrankaSim.h:111
vpRobotFrankaSim::m_tau_J_des_filt
vpColVector m_tau_J_des_filt
Definition: vpRobotFrankaSim.h:153
vpRobotFrankaSim::m_camMounted
bool m_camMounted
Definition: vpRobotFrankaSim.h:123
vpRobotFrankaSim::m_tau_J_des
vpColVector m_tau_J_des
Definition: vpRobotFrankaSim.h:152
vpRobotFrankaSim::m_mL
double m_mL
Definition: vpRobotFrankaSim.h:118
vpRobotFrankaSim::m_v_cart_des
vpColVector m_v_cart_des
Definition: vpRobotFrankaSim.h:150
vpRobotFrankaSim::m_fksolver_kdl
KDL::ChainFkSolverPos_recursive * m_fksolver_kdl
Definition: vpRobotFrankaSim.h:138
vpRobotFrankaSim::m_q
vpColVector m_q
Definition: vpRobotFrankaSim.h:114
vpRobotFrankaSim::m_flMcom
vpHomogeneousMatrix m_flMcom
Definition: vpRobotFrankaSim.h:119
vpRobotFrankaSim::m_eMc
vpHomogeneousMatrix m_eMc
Definition: vpRobotFrankaSim.h:155
vpRobotFrankaSim::m_verbose
bool m_verbose
Definition: vpRobotFrankaSim.h:158
vpRobotFrankaSim::m_eVc
vpVelocityTwistMatrix m_eVc
Definition: vpRobotFrankaSim.h:156
vpRobotFrankaSim::m_Il
vpMatrix m_Il
Definition: vpRobotFrankaSim.h:120
vpRobotFrankaSim::m_stateRobot
vpRobot::vpRobotStateType m_stateRobot
Definition: vpRobotFrankaSim.h:144
vpRobotFrankaSim::m_iksolver_JL_kdl
KDL::ChainIkSolverPos_NR_JL * m_iksolver_JL_kdl
Definition: vpRobotFrankaSim.h:141
vpRobotFrankaSim::m_jacobianSolver_kdl
KDL::ChainJntToJacSolver * m_jacobianSolver_kdl
Definition: vpRobotFrankaSim.h:139
franka_model::friction
vpColVector friction(const vpColVector &dq)
Definition: FrictionTorque.cpp:19
vpRobotFrankaSim::m_flMe
vpHomogeneousMatrix m_flMe
Definition: vpRobotFrankaSim.h:121
vpRobotFrankaSim::m_q_min_kdl
KDL::JntArray m_q_min_kdl
Definition: vpRobotFrankaSim.h:136
vpRobotFrankaSim::m_dq_des_filt
vpColVector m_dq_des_filt
Definition: vpRobotFrankaSim.h:149
vpRobotFrankaSim::m_mutex
std::mutex m_mutex
Definition: vpRobotFrankaSim.h:127
vpRobotFrankaSim::m_dq
vpColVector m_dq
Definition: vpRobotFrankaSim.h:115


visp_ros
Author(s): Francois Pasteau, Fabien Spindler, Gatien Gaumerais, Alexander Oliva
autogenerated on Wed Mar 2 2022 01:13:33