-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmain.py
83 lines (56 loc) · 1.81 KB
/
main.py
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
from ruamel import yaml
import os
import numpy as np
def load_yaml(yaml_path):
config_dict = {}
if os.path.exists(yaml_path):
with open(yaml_path, 'r', encoding='utf-8') as config_file:
config_dict = yaml.load(config_file.read(), Loader=yaml.RoundTripLoader)
if config_dict == None or len(config_dict) == 0:
print("xxxxxxxxxxxxxxxxxxxxxxxx")
return {}
return config_dict
addLine = np.array([0,0,0,1])
ned = []
f = open('ned_to_ecef.txt', "r", encoding='utf-8')
lines = f.readlines()
f.close()
if len(lines) != 3:
exit(0)
ned.append(lines[0].rstrip().split(" "))
ned.append(lines[1].rstrip().split(" "))
ned.append(lines[2].rstrip().split(" "))
ned = np.matrix(ned)
nedT = ned.astype(np.double)
Tn2e = np.r_[nedT,[addLine]]
T1 = None
data = load_yaml('./1.yaml')
if data.get("transMatrix", None):
transMatrix = data["transMatrix"]
print(transMatrix)
if transMatrix.get("data", None):
transMatrixData = transMatrix["data"]
transMatrixDataT = np.array(transMatrixData).reshape(3,4)
print(transMatrixDataT)
T1 = np.r_[transMatrixDataT,[addLine]]
else:
exit(0)
else:
exit(0)
rotT = np.matrix([-1,0,0,0, 0,0,1,0, 0,1,0,0, 0,0,0,1]).reshape(4,4)
print('-------- original data ------------')
print("T1:", T1)
print("Tn2e:", Tn2e)
print("rotT:", rotT)
print('-------- temporary data ------------')
A = np.matrix(rotT * T1)
print("rotT * T1:", A)
print('-------- result------------')
result = Tn2e * A.I
# result = Tn2e * np.linalg.pinv(rotT * T1)
print(result)
print('-------- nedTransT------------')
nedTransT = np.delete(result, 3, 0)
print(nedTransT)
print('-------- write trans_ned_to_ecef.txt------------')
np.savetxt("trans_ned_to_ecef.txt", nedTransT,fmt='%.16f',delimiter=' ')