Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpServoData.cpp
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 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 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 http://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  * Save data during the task execution.
32  *
33  * Authors:
34  * Eric Marchand
35  *
36  *****************************************************************************/
37 
38 
44 // Servo
45 #include <visp3/vs/vpServo.h>
46 
47 #include <visp3/vs/vpServoData.h>
48 #include <visp3/core/vpIoException.h>
49 #include <visp3/core/vpIoTools.h>
50 
51 void
52 vpServoData::open(const char *directory)
53 {
54  try
55  {
56  if (vpIoTools::checkDirectory(directory) == false)
57  vpIoTools::makeDirectory(directory);
58 
59  char s[FILENAME_MAX] ;
60 
61  sprintf(s,"%s/vel.dat",directory) ;
62  velocityFile.open(s) ;
63  sprintf(s,"%s/error.dat",directory) ;
64  errorFile.open(s) ;
65  sprintf(s,"%s/errornorm.dat",directory) ;
66  errorNormFile.open(s) ;
67  sprintf(s,"%s/s.dat",directory) ;
68  sFile.open(s) ;
69  sprintf(s,"%s/sStar.dat",directory) ;
70  sStarFile.open(s) ;
71 
72  }
73  catch(...)
74  {
75  vpERROR_TRACE("Error caught") ;
76  throw ;
77  }
78 }
79 
81 {
82  cmDeg = true ;
83 }
85 {
86  cmDeg = false ;
87 }
88 void vpServoData::save(const vpServo &task)
89 {
90  if (cmDeg==false) velocityFile << task.q_dot.t() ;
91  else
92  {
93  for (unsigned int i=0 ; i < 3 ; i++)
94  velocityFile << task.q_dot[i]*100 <<" " ;
95  for (unsigned int i=4 ; i < 6 ; i++)
96  velocityFile << vpMath::deg(task.q_dot[i]) <<" " ;
97  velocityFile << std::endl ;
98  }
99  errorFile << ( task.getError() ).t() ;
100  errorNormFile << ( task.getError() ).sumSquare() << std::endl ;
101  vNormFile << task.q_dot.sumSquare() << std::endl ;
102 
103  sFile <<task.s.t() ;
104  sStarFile << task.sStar.t();
105 }
106 
107 
108 
110 {
111  velocityFile.close() ;
112  errorFile.close() ;
113  errorNormFile.close() ;
114  sFile.close() ;
115  sStarFile.close() ;
116 }
117 
118 
119 
120 /*
121  * Local variables:
122  * c-basic-offset: 2
123  * End:
124  */
void open(const char *baseDirectory)
Definition: vpServoData.cpp:52
static bool checkDirectory(const char *dirname)
Definition: vpIoTools.cpp:358
void save(const vpServo &task)
Definition: vpServoData.cpp:88
void setCmDeg()
velocity output in cm and deg
Definition: vpServoData.cpp:80
#define vpERROR_TRACE
Definition: vpDebug.h:391
vpColVector q_dot
Articular velocity.
Definition: vpServo.h:509
static void makeDirectory(const char *dirname)
Definition: vpIoTools.cpp:427
vpColVector getError() const
Definition: vpServo.h:271
vpRowVector t() const
vpColVector s
Definition: vpServo.h:498
double sumSquare() const
static double deg(double rad)
Definition: vpMath.h:97
vpColVector sStar
Definition: vpServo.h:501
void setMeterRad()
velocity output in meter and deg (default)
Definition: vpServoData.cpp:84