-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcommon.h
More file actions
135 lines (115 loc) · 3.23 KB
/
common.h
File metadata and controls
135 lines (115 loc) · 3.23 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
#ifndef COMMON_H
#define COMMON_H
#include <vector>
#include <list>
#include <chrono>
#include <ratio>
#include <sstream>
#include <iomanip>
#include <mutex>
#include <algorithm>
#include <memory>
#include <limits>
#include <limits.h>
#include <spdlog/spdlog.h>
#include <boost/thread/thread.hpp>
#include "sqlite3/CppSQLite3.h"
#ifdef WIN32
#include <json/json.h>
#else
#include <jsoncpp/json/json.h>
#endif
#define CAN_CHANGE_DIRECTION false
#define DISTANCE_INFINITY (INT_MAX/1000)
#define DISTANCE_INFINITY_DOUBLE ((std::numeric_limits<double>::max)()/1000.0)
#define DB_File ("agv.db")
#define AGV_TYPE_VIRTUAL_ROS_AGV -1
#define AGV_TYPE_ANTING_FORKLIFT 1
typedef std::chrono::duration<int,std::milli> duration_millisecond;
typedef std::chrono::duration<int> duration_second;
typedef std::chrono::duration<int,std::ratio<60*60>> duration_hour;
typedef std::unique_lock<std::mutex> UNIQUE_LCK;
extern std::shared_ptr<spdlog::logger> combined_logger;
enum {
AGV_LINE_COLOR_WHITE = 0, //未算出路径最小值
AGV_LINE_COLOR_GRAY, //已经计算出一定的值,在Q队列中,但是尚未计算出最小值
AGV_LINE_COLOR_BLACK, //已算出路径最小值
};
std::string getTimeStrNow();
std::string getTimeStrToday();
std::string getTimeStrTomorrow();
std::string toHexString(const char *data, int len);
std::string intToString(int i);
std::string longToString(long l);
int stringToInt(std::string str);
double stringToDouble(std::string str);
bool stringToBool(std::string str);
std::vector<std::string> split(std::string src,std::string sp = " ");
std::vector<std::string> splitMultiJson(std::string multiJson);
bool IsValidIPAddress(const char * str);
int HexStringToInt(std::string str);
int getRandom(int maxRandom);
//东药名匠公用
double func_dis(int x1, int y1, int x2, int y2);
int func_angle(int a1, int a2);
std::string transToFullMsg(const std::string &data);
class Pose4D
{
public:
Pose4D(){}
Pose4D(double x, double y, double theta, int floor)
{
m_x = x;
m_y = y;
m_theta = theta;
m_floor = floor;
}
double m_x;
double m_y;
double m_theta;
int m_floor;
};
class DyMsg
{
public:
std::string msg;
int waitTime;
};
class TimeUsed{
public:
void start()
{
s = std::chrono::steady_clock::now();
}
void end()
{
e = std::chrono::steady_clock::now();
}
double getUsed()
{
std::chrono::duration<double> time_used = std::chrono::duration_cast<std::chrono::duration<double>>(e - s);
return time_used.count();
}
private:
std::chrono::steady_clock::time_point s;
std::chrono::steady_clock::time_point e;
};
extern boost::thread_group g_threads;
extern CppSQLite3DB g_db;
#ifndef _WIN32
void memcpy_s(void *__restrict __dest, size_t __m,const void *__restrict __src, size_t __n);
#endif
void sleep_for_s(int s);
void sleep_for_ms(int ms);
void sleep_for_us(int us);
//考虑到有些项目可能是多种车一起调度,那么根据项目来区分不同的taskmaker
enum{
AGV_PROJECT_QUNCHUANG = 0,
AGV_PROJECT_DONGYAO,
AGV_PROJECT_QINGDAO,
AGV_PROJECT_ANTING
//...
};
extern const int GLOBAL_AGV_PROJECT;
extern std::atomic<bool> g_quit;
#endif // COMMON_H