sttl.h 2.92 KB
Newer Older
Sören Schwertfeger's avatar
Sören Schwertfeger committed
1
2
3
4
#ifndef STTL
#define STTL


Sören Schwertfeger's avatar
Sören Schwertfeger committed
5
6
7
// #include <stdlib.h>
// #include <stdio.h>

Sören Schwertfeger's avatar
Sören Schwertfeger committed
8
9
#include <Eigen/Geometry> 

Sören Schwertfeger's avatar
Sören Schwertfeger committed
10
11
12
#include <iomanip>
#include <iostream>

Sören Schwertfeger's avatar
Sören Schwertfeger committed
13
14
15
16
17
#include <string>
#include <list>

namespace sttl{

Sören Schwertfeger's avatar
Sören Schwertfeger committed
18
19
20
21
22
23
24

/*
 * A Transform between two frames
 * There might be multiple transforms for every frame - maybe even with the same reference frame.
 * Those are not specially handeled here - just more than one Transform will exist.
 */
class Transform{
Sören Schwertfeger's avatar
Sören Schwertfeger committed
25
26
public:

Sören Schwertfeger's avatar
Sören Schwertfeger committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
	struct Id{
		uint64_t id[2];
		Id(){
			id[0] = 0;
			id[1] = 0;
			// id[2] = 0;
			// id[3] = 0;
		}
		Id(uint64_t id0, uint64_t id1){
			id[0] = id0;
			id[1] = id1;
			// id[2] = id2;
			// id[3] = id3;
		}
		bool operator==(const Id& other) const{
			return id[0] == other.id[0] && id[1] == other.id[1];
		}

		std::string toString() const;
		bool fromString(const std::string& string);

	};

	std::string frameName;	//< the name of the frame we are describing
Sören Schwertfeger's avatar
Sören Schwertfeger committed
51
52
	std::string referenceFrameName;  //< in case the reference Frame cannot be found

Sören Schwertfeger's avatar
Sören Schwertfeger committed
53
54
55
56
57
58
59
60
61
62
63
64
	Eigen::Transform<double,3,Eigen::Affine> transform; //< the transfrom of this frame wrt the reference frame
	bool hasCovariance; //< only true if the covariance matrix below has proper values
	Eigen::Matrix<double, 7, 7> covariance; //< the 7x7 covariance matrix of translation and rotation as quaternion

	std::string byUser;	//< The user responsible for generating this transform
	std::string time;	//< the time this transform was generated

	std::string method;	//< Name of the method used to generate this transform - use the constants below if possible
	std::string program; //< Name of the program used to generate this transform (e.g. "cloudcompare")
	std::string details; //< Any additional data that this method/ program wants to save 

	Id id; //< special 256bit (hopefully) unique id generated once by generateId() 
Sören Schwertfeger's avatar
Sören Schwertfeger committed
65

Sören Schwertfeger's avatar
Sören Schwertfeger committed
66
67
68
69
70
	std::list<Id> history; //< list of other transforms between these frames that influenced this result.

	Transform():hasCovariance(false){}

	bool generateId();
Sören Schwertfeger's avatar
Sören Schwertfeger committed
71
72
73

};

Sören Schwertfeger's avatar
Sören Schwertfeger committed
74
static const std::string METHOD_MANUAL = "Manual"; 
Sören Schwertfeger's avatar
Sören Schwertfeger committed
75
static const std::string METHOD_POINT_PAIRS = "Point Pairs"; 
Sören Schwertfeger's avatar
Sören Schwertfeger committed
76
77
78
static const std::string METHOD_ICP = "ICP"; 
static const std::string METHOD_G2O = "g2o"; 

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
class Frame{
public:
	std::string name;
	std::string dataNames;

	std::list<std::list<sttl::Transform>::iterator> children;
	std::list<std::list<sttl::Transform>::iterator> parents;

	Eigen::Transform<double,3,Eigen::Affine> rootTransform; //< the transfrom of this frame wrt root

	bool visited;
};


bool generateFrames(std::list<sttl::Transform> & transforms, std::list<Frame> &frames);

std::list<sttl::Frame>::iterator findFrame(std::list<sttl::Frame> &frames, const std::string & frame);
std::list<sttl::Frame>::iterator findFrameForData(std::list<sttl::Frame> &frames, const std::string & dataName);
Sören Schwertfeger's avatar
Sören Schwertfeger committed
97

98
99
bool saveList(const std::list<sttl::Transform> & transforms, const std::string &file);
bool loadList(std::list<sttl::Transform> & transforms, const std::string &file);
Sören Schwertfeger's avatar
Sören Schwertfeger committed
100
101
102
103
104
105



}

#endif