UsTK : Ultrasound ToolKit  version 2.0.1 under development (2023-12-07)
usViper850WrapperVelocityControl.h
1 /****************************************************************************
2  *
3  * This file is part of the ustk software.
4  * Copyright (C) 2016 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 ustk 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  * This software was developed at:
17  * Inria Rennes - Bretagne Atlantique
18  * Campus Universitaire de Beaulieu
19  * 35042 Rennes Cedex
20  * France
21  *
22  * If you have questions regarding the use of this file, please contact
23  * Inria at ustk@inria.fr
24  *
25  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  *
28  * Authors:
29  * Marc Pouliquen
30  * Pedro Patlan Rosales
31  *
32  *****************************************************************************/
33 
39 #ifndef __usViper850WrapperVelocityControl_h_
40 #define __usViper850WrapperVelocityControl_h_
41 
42 // VISP includes
43 #include <visp3/ustk_core/usConfig.h>
44 
45 #if defined(USTK_HAVE_VTK_QT) && defined(VISP_HAVE_VIPER850) && defined(VISP_HAVE_MODULE_ROBOT)
46 
47 #include <QApplication>
48 #include <QObject>
49 #include <visp3/core/vpMath.h>
50 #include <visp3/core/vpMatrix.h>
51 #include <visp3/robot/vpRobotViper850.h>
52 
53 // For 4DC7 probe usage //
54 #define VIPER_PROBE_4DC7_TX 0.00479375
55 #define VIPER_PROBE_4DC7_TY 0.142001
56 #define VIPER_PROBE_4DC7_TZ -0.00113622
57 #define VIPER_PROBE_4DC7_RZ 1.63126 * M_PI / 180.0
58 #define VIPER_PROBE_4DC7_RY -0.781128 * M_PI / 180.0
59 #define VIPER_PROBE_4DC7_RX 1.68121 * M_PI / 180.0
60 
61 class VISP_EXPORT usViper850WrapperVelocityControl : public QObject
62 {
63  Q_OBJECT
64 public:
67 
68 public slots:
69  void init();
70  void run();
71  void stop();
72 
73  void startAutomaticForceControl();
74  void stopAutomaticForceControl();
75 
76  // Manual velocity control in US probe contact frame
77  void setXVelocity(int xVelocity);
78  void setYVelocity(int yVelocity);
79  void setZVelocity(int zVelocity);
80  void setXAngularVelocity(int xAngularVelocity);
81  void setYAngularVelocity(int yAngularVelocity);
82  void setZAngularVelocity(int zAngularVelocity);
83 
84  void moveLeft();
85  void moveRight();
86  void stopMoveLateral();
87 
88 signals:
91  void robotError();
92 private slots:
93  void controlLoop();
94  void controlLoopAutomatic();
95 
96 private:
97  bool m_initialized;
98  bool m_run;
99  vpRobotViper850 *viper;
100  void startRobot(void);
101 
102  vpMatrix eJe; // robot jacobian
103 
104  vpVelocityTwistMatrix eVp; // change velocity from ultrasound probe contact force to end-effector frame
105 
106  vpColVector velocityProbeContact; // velocity in ultrasound probe contact point
107  vpColVector q_dot;
108  vpColVector ve; // velocity of end-effector
109 };
110 #endif // USTK_HAVE_VTK_QT && VISP_HAVE_VIPER850
111 #endif // __usViper850WrapperVelocityControl_h_