AUV-Coop-Assembly
Master Thesis for Robotics Engineering. Cooperative peg-in-hole assembly with two underwater vehicles guided by vision
logger_old.cpp
1 #include "header/logger.h"
2 
3 Logger::Logger(){}
4 
5 Logger::Logger(std::string nodeName, std::string pathLog){
6 
7  this->nodeName = nodeName;
8  this->pathLog = pathLog += "/" + nodeName;
9  std::cout << "[" << nodeName
10  << "][Logger] Start " << std::endl;
11 }
12 
13 void Logger::createDirectoryForNode(){
14  PRT::createDirectory(pathLog);
15  std::cout << "[" << nodeName
16  << "][Logger] Created Log Folder in "
17  << pathLog << std::endl;
18 }
19 
20 int Logger::createTasksListDirectories(std::vector <Task*> tasksList){
21 
22  for (int i =0; i< tasksList.size(); ++i){
23  PRT::createDirectory(pathLog +"/" +tasksList[i]->getName());
24  }
25  std::cout << "[" << nodeName
26  << "][Logger] Created Log SubFolders for tasks in "
27  << pathLog << std::endl;
28  return 0;
29 
30 }
31 
32 int Logger::writeAllForTasks(std::vector <Task*> tasksList){
33 
34  Logger::writeActivation(tasksList);
35  Logger::writeReference(tasksList);
36  Logger::writeError(tasksList);
37 
38  return 0;
39 }
40 
41 int Logger::writeActivation(std::vector <Task*> tasksList){
42 
43  for(int i=0; i<tasksList.size(); i++){
44  std::string pathname = pathLog + "/" + tasksList[i]->getName();
45  PRT::matrixCmat2file(pathname + "/activation.txt",
46  tasksList[i]->getActivation().GetDiag());
47  }
48 
49  return 0;
50 
51 }
52 
53 int Logger::writeReference(std::vector <Task*> tasksList){
54 
55  for(int i=0; i<tasksList.size(); i++){
56  std::string pathname = pathLog + "/" + tasksList[i]->getName();
57 
58  PRT::matrixCmat2file(pathname + "/reference.txt",
59  tasksList[i]->getReference());
60  }
61  return 0;
62 
63 }
64 
65 int Logger::writeError(std::vector <Task*> tasksList){
66 
67  for(int i=0; i<tasksList.size(); i++){
68  std::string pathname = pathLog + "/" + tasksList[i]->getName();
69 
70  PRT::matrixCmat2file(pathname + "/error.txt",
71  tasksList[i]->getError());
72  }
73  return 0;
74 
75 }
76 
77 void Logger::writeYDot(std::vector<double> yDot, std::string yDotString){
78 
79  std::string pathyDot = pathLog + "/" +yDotString +".txt";
80  PRT::vectorStd2file(pathyDot, yDot);
81 
82 }
83 
84 void Logger::writeNonCoopVel(Eigen::VectorXd nonCoopVel, std::string rob){
85  std::string path = pathLog + "/nonCoopVel" + rob + ".txt";
86  PRT::matrixEigen2file(path, nonCoopVel);
87 
88 }
89 
90 void Logger::writeCoopVel(Eigen::VectorXd coopVel){
91 
92  std::string path = pathLog + "/coopVel.txt";
93  PRT::matrixEigen2file(path, coopVel);
94 
95 }
96 
97 void Logger::writeScalar(double scalar, std::string fileName){
98  std::string path = pathLog + "/" + fileName + ".txt";
99  PRT::double2file(path, scalar);
100 
101 }
102 
103 void Logger::writeEigenMatrix(Eigen::MatrixXd mat, std::string fileName){
104  std::string path = pathLog + "/" + fileName + ".txt";
105  PRT::matrixEigen2file(path, mat);
106 }
107 
108 void Logger::writeCmatMatrix(CMAT::Matrix mat, std::string fileName){
109  Logger::writeEigenMatrix(CONV::matrix_cmat2eigen(mat), fileName);
110 }
111 
112 
113 void Logger::writeStressTool(Eigen::Matrix4d wTt, Eigen::Matrix4d wTt2){
114  CMAT::TransfMatrix wTt_cmat = CONV::matrix_eigen2cmat(wTt);
115  CMAT::TransfMatrix wTt2_cmat = CONV::matrix_eigen2cmat(wTt2);
116 
117  CMAT::Vect6 stressErrorSwapped = CMAT::CartError(wTt_cmat, wTt2_cmat);
118 
119  std::vector<double> stressError(6);
120  stressError.at(0) = stressErrorSwapped(4);
121  stressError.at(1) = stressErrorSwapped(5);
122  stressError.at(2) = stressErrorSwapped(6);
123  stressError.at(3) = stressErrorSwapped(1);
124  stressError.at(4) = stressErrorSwapped(2);
125  stressError.at(5) = stressErrorSwapped(3);
126 
127  std::string path = pathLog + "/stressTool" + ".txt";
128  PRT::vectorStd2file(path, stressError);
129 
130 }
131 
132 
133 
134 
135