-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacroHeader.h
More file actions
152 lines (126 loc) · 5.84 KB
/
Copy pathmacroHeader.h
File metadata and controls
152 lines (126 loc) · 5.84 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// Copyright [2014] Ruud Cools
#ifndef MACROHEADER_H_
#define MACROHEADER_H_
// Common header decleration
#include <algorithm>
#include <fstream>
#include <fcntl.h>
#include <glob.h>
#include <iostream>
#include <map>
#include <set>
#include <memory>
#include <tuple>
#include <string>
#include <string.h>
#include <stdexcept>
#include <sstream>
#include <termios.h>
#include <unistd.h>
#include <vector>
#include <iomanip>
#include <cassert>
#include <pugixml.hpp>
#ifdef QT
#include <QtCore/QPointF>
#include <QtCore/QFile>
#include <QtCore/QByteArray>
#endif
#define PIN_HIGH 1
#define PIN_LOW 0
#define DEFAULT_STATE PIN_HIGH
#define DELAY_BETWEEN_STEP_MICROSECONDS 250
#define HAS_RPI false
#define PI 3.1415926535897932384626433
#define TOLERANCE 0.00001
#define DEBUG
//#define DEBUG_FILE
// Create getter and setter for properties of a class
#define GETSET(type, varName, property) \
private: \
type varName; \
public: \
const type& get##property() const { \
return varName; \
}; \
void set##property(const type& val) { \
varName = val; \
};
#define GETSETPROTECTED(type, varName, property) \
protected: \
type varName; \
public: \
const type& get##property() const { \
return varName; \
}; \
void set##property(const type& val) { \
varName = val; \
};
// Create getter and setter for properties of a class
#define GETSET_NO_CONST(type, varName, property) \
private: \
type varName; \
public: \
type& get##property() \
{ \
return varName; \
}; \
\
void set##property(const type& val) \
{ \
varName = val; \
};
// Create getter and setter for Pointers in a class
#define GETSETPOINTER(type, varName, property) \
protected: \
type* varName; \
public: \
type* get##property() const { \
return varName; \
}; \
\
void set##property(type* val) { \
varName = val; \
};
#define GET(type, varName, property) \
private: \
type varName; \
public: \
const type& get##property() const { \
return varName; \
};
// Create debug messages
#if defined(DEBUG)
#define DEBUG_MSG(message) do {std::cout << message << std::endl;} while (false)
#elif defined(DEBUG_FILE)
#define DEBUG_MSG(message) do { \
std::ofstream thisStream; \
thisStream.open("Debug.save", std::ios_base::app); \
thisStream << message << std::endl; \
thisStream.close(); \
} while (false)
#else
#define DEBUG_MSG(message)
#endif
#define LOG_ERROR(message) do { \
std::stringstream stream; \
stream << std::endl << "[ERROR_LOG]" << \
"(" << __FILE__ << ":" << __LINE__ << "): " \
<< message; \
std::string what = stream.str(); \
throw std::runtime_error(what);} while (false)
#define LOG_WARNING(message) \
do {DEBUG_MSG("[WARN](" << \
__FILE__ << ":" << __LINE__ << "): " << message);} while (false)
#define LOG_DEBUG(message) \
do {DEBUG_MSG("[DEBUG] (" << \
__FILE__<< ":" << __LINE__ << "): " << message);} while (false)
#define LOG_INFO(message) \
do {DEBUG_MSG("[INFO] ("<< \
__FILE__ << ":" << __LINE__ << "): " << message);} while (false)
enum GUIMovementMode {ToolMode, AxisMode};
/// conversion of motor direction to joint direction
typedef std::map<std::string, std::string> DirectionConversionMap;
/// type used in trace calculations
typedef double traceType;
#endif // MACROHEADER_H_