Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
vpServoData.cpp
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 * Save data during the task execution.
33 *
34*****************************************************************************/
35
41// Servo
42#include <visp3/vs/vpServo.h>
43
44#include <visp3/core/vpIoException.h>
45#include <visp3/core/vpIoTools.h>
46#include <visp3/vs/vpServoData.h>
47
48void vpServoData::open(const std::string &directory)
49{
50 try {
51 if (vpIoTools::checkDirectory(directory) == false)
52 vpIoTools::makeDirectory(directory);
53
54 std::string s;
55 s = directory + "/vel.dat";
56 velocityFile.open(s.c_str());
57 s = directory + "/error.dat";
58 errorFile.open(s.c_str());
59
60 s = directory + "/errornorm.dat";
61 errorNormFile.open(s.c_str());
62 s = directory + "/s.dat";
63 sFile.open(s.c_str());
64 s = directory + "/sStar.dat";
65 sStarFile.open(s.c_str());
66
67 }
68 catch (...) {
69 vpERROR_TRACE("Error caught");
70 throw;
71 }
72}
73
74void vpServoData::setCmDeg() { cmDeg = true; }
75void vpServoData::setMeterRad() { cmDeg = false; }
76void vpServoData::save(const vpServo &task)
77{
78 if (cmDeg == false)
79 velocityFile << task.q_dot.t();
80 else {
81 for (unsigned int i = 0; i < 3; i++)
82 velocityFile << task.q_dot[i] * 100 << " ";
83 for (unsigned int i = 4; i < 6; i++)
84 velocityFile << vpMath::deg(task.q_dot[i]) << " ";
85 velocityFile << std::endl;
86 }
87 errorFile << (task.getError()).t();
88 errorNormFile << (task.getError()).sumSquare() << std::endl;
89 vNormFile << task.q_dot.sumSquare() << std::endl;
90
91 sFile << task.s.t();
92 sStarFile << task.sStar.t();
93}
94
96{
97 velocityFile.close();
98 errorFile.close();
99 errorNormFile.close();
100 sFile.close();
101 sStarFile.close();
102}
double sumSquare() const
vpRowVector t() const
static bool checkDirectory(const std::string &dirname)
static void makeDirectory(const std::string &dirname)
static double deg(double rad)
Definition vpMath.h:106
void open(const std::string &directory)
void save(const vpServo &task)
void setMeterRad()
velocity output in meter and deg (default)
void setCmDeg()
velocity output in cm and deg
vpColVector q_dot
Articular velocity.
Definition vpServo.h:571
vpColVector sStar
Definition vpServo.h:563
vpColVector s
Definition vpServo.h:559
vpColVector getError() const
Definition vpServo.h:276
#define vpERROR_TRACE
Definition vpDebug.h:388