-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.h
83 lines (67 loc) · 2.2 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2016 Learning Algorithms and Systems Laboratory, EPFL, Switzerland
* Author: Sina Mirrazavi
* email: sina.mirrazavi@epfl.ch
* website: lasa.epfl.ch
*
* Permission is granted to copy, distribute, and/or modify this program
* under the terms of the GNU General Public License, version 2 or any
* later version published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details
*/
#include "eigen3/Eigen/Dense"
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include "ros/ros.h"
#include <omp.h>
#define MAXBUFSIZE ((int) 1e6)
int Num_of_robots=2;
namespace Eigen{
template<class Matrix>
void write_binary(const char* filename, const Matrix& matrix){
std::ofstream out(filename,ios::out | ios::binary | ios::trunc);
typename Matrix::Index rows=matrix.rows(), cols=matrix.cols();
out.write((char*) (&rows), sizeof(typename Matrix::Index));
out.write((char*) (&cols), sizeof(typename Matrix::Index));
out.write((char*) matrix.data(), rows*cols*sizeof(typename Matrix::Scalar) );
out.close();
}
template<class Matrix>
void read_binary(const char* filename, Matrix& matrix){
std::ifstream in(filename,ios::in | std::ios::binary);
typename Matrix::Index rows=0, cols=0;
in.read((char*) (&rows),sizeof(typename Matrix::Index));
in.read((char*) (&cols),sizeof(typename Matrix::Index));
matrix.resize(rows, cols);
in.read( (char *) matrix.data() , rows*cols*sizeof(typename Matrix::Scalar) );
in.close();
}
}
int KUKA_DOF=7;
string addTwochar(string folder_path, string b, int integer1,int integer2=-1)
{
std::string str;
str.append(folder_path);
str.append(b);
ostringstream convert;
convert << integer1;
str.append(convert.str());
if (integer2!=-1)
{
ostringstream convert;
convert << integer2;
str.append(convert.str());
}
str.append(".txt");
return str;
}
string buffer_path;
string folder_path="/home/sina/Dropbox/Sinas_stuff/catkin_ws/underlay/src/Data_Analysis/constructing_data_set/data";