|
|
@@ -2,84 +2,56 @@ import matplotlib.pyplot as plt |
|
|
|
import numpy as np |
|
|
|
import re |
|
|
|
|
|
|
|
"""--------------- Open, format and save ART positions from text files---------------------------------------------""" |
|
|
|
# Opening a recording |
|
|
|
art_recording = open('ART_IndLoc precision tests/Recording_1.txt', 'r') |
|
|
|
art_recording = art_recording.read() |
|
|
|
|
|
|
|
# Formatting a recording |
|
|
|
art_recording = re.split(' |\n', art_recording) # split string at whitespace and linebreak |
|
|
|
art_recording = np.array(art_recording) # list -> np.array |
|
|
|
# Count the total number of recorded positions |
|
|
|
total_pos_counter = 0 |
|
|
|
for i in art_recording: |
|
|
|
if i == '6d': # this is the flag marking a 6d position (Syntax of the ART guys in the txt files) |
|
|
|
total_pos_counter += 1 |
|
|
|
|
|
|
|
# Create an empty array which will store the ART measurement infos |
|
|
|
art_info = np.zeros((total_pos_counter, 7)) # [t, x, y, z, alpha, beta, gamma] |
|
|
|
|
|
|
|
# Fill the empty numpy array with the information's of the art_recording |
|
|
|
pos_counter = 0 |
|
|
|
for i in range(len(art_recording)): |
|
|
|
if art_recording[i] == 'ts': # following entry is timestamp |
|
|
|
art_info[pos_counter] = float(art_recording[i+1]) |
|
|
|
if art_recording[i] == '6d': # following entries are x,y,z,alpha,beta,gamma |
|
|
|
art_info[pos_counter, 1] = float(art_recording[i+3].split('[')[1]) # x (had to delete some excess text) |
|
|
|
art_info[pos_counter, 2] = float(art_recording[i+4]) # y |
|
|
|
art_info[pos_counter, 3] = float(art_recording[i+5]) # z |
|
|
|
|
|
|
|
art_info[pos_counter, 4] = float(art_recording[i+6]) # alpha |
|
|
|
art_info[pos_counter, 5] = float(art_recording[i+7]) # beta |
|
|
|
art_info[pos_counter, 6] = float(art_recording[i+8].split(']')[0]) # gamma (had to delete some excess text |
|
|
|
|
|
|
|
pos_counter += 1 |
|
|
|
|
|
|
|
|
|
|
|
"""------------------- Plotting (First ART, then IndLoc)------------------------------------------------------""" |
|
|
|
font = {"family":"serif", |
|
|
|
"color":"black", |
|
|
|
"size":15} |
|
|
|
|
|
|
|
plt.plot(art_info[:, 1], art_info[:, 2], color="g", label="ART System") |
|
|
|
|
|
|
|
print("x=", art_info[:, 1]) |
|
|
|
print("y=", art_info[:, 2]) |
|
|
|
|
|
|
|
plt.grid() |
|
|
|
positions = np.load("calculated_positions/current_positions.npy") |
|
|
|
positions = positions*1000 # from metre to millimetre |
|
|
|
plt.plot(positions[:, 0], positions[:, 1], label="Ind Loc") |
|
|
|
# |
|
|
|
# positions = np.load("calculated_positions/Positions_1.9.npy") |
|
|
|
# positions = positions*1000 # from metre to millimetre |
|
|
|
# plt.plot(positions[:, 0], positions[:, 1], label="1.9") |
|
|
|
# |
|
|
|
# positions = np.load("calculated_positions/Positions_1.10.npy") |
|
|
|
# positions = positions*1000 # from metre to millimetre |
|
|
|
# plt.plot(positions[:, 0], positions[:, 1], label="1.10") |
|
|
|
# |
|
|
|
# positions = np.load("calculated_positions/Positions_1.11.npy") |
|
|
|
# positions = positions*1000 # from metre to millimetre |
|
|
|
# plt.plot(positions[:, 0], positions[:, 1], label="1.11") |
|
|
|
|
|
|
|
plt.legend() |
|
|
|
plt.show() |
|
|
|
|
|
|
|
|
|
|
|
""" ------------------------ Analyzing one Recording ---------------------------------------------------------------""" |
|
|
|
data = np.load("recorded_data\ART Recordings\Recording_17.npy") |
|
|
|
print(np.shape(data)) |
|
|
|
|
|
|
|
print("sample 1000:", data[1000]) # x,y,z, f1,f2,f3,...,m1,m2,m3,...,m8 |
|
|
|
|
|
|
|
|
|
|
|
for i in range(16): |
|
|
|
ant_averaged = np.average(data[:, 3+i]) |
|
|
|
if i <= 7: |
|
|
|
print("Frame", i+1, " averaged [V] =", ant_averaged) |
|
|
|
else: |
|
|
|
print("Main", i+1-8, " averaged [V] =", ant_averaged) |
|
|
|
|
|
|
|
|
|
|
|
print("avg_main8 * Faktor =", ant_averaged*88.74017567) |
|
|
|
class ART_plotting: |
|
|
|
def __init__(self): |
|
|
|
self.bla = 0 |
|
|
|
|
|
|
|
def plot_art(self, recording_number): |
|
|
|
""" |
|
|
|
:param recording_name: int, Choose which recording to print e.g. Recording_!1! , Recording_!2!, etc. |
|
|
|
:return: void it just plots |
|
|
|
""" |
|
|
|
|
|
|
|
"""--------------- Open, format and save ART positions from text files---------------------------------------""" |
|
|
|
# Opening a recording |
|
|
|
art_recording = open('ART_IndLoc precision tests/Recording_'+str(recording_number)+'.txt', 'r') |
|
|
|
art_recording = art_recording.read() |
|
|
|
|
|
|
|
# Formatting a recording |
|
|
|
art_recording = re.split(' |\n', art_recording) # split string at whitespace and linebreak |
|
|
|
art_recording = np.array(art_recording) # list -> np.array |
|
|
|
# Count the total number of recorded positions |
|
|
|
total_pos_counter = 0 |
|
|
|
for i in art_recording: |
|
|
|
if i == '6d': # this is the flag marking a 6d position (Syntax of the ART guys in the txt files) |
|
|
|
total_pos_counter += 1 |
|
|
|
|
|
|
|
# Create an empty array which will store the ART measurement infos |
|
|
|
art_info = np.zeros((total_pos_counter, 7)) # [t, x, y, z, alpha, beta, gamma] |
|
|
|
|
|
|
|
# Fill the empty numpy array with the information's of the art_recording |
|
|
|
pos_counter = 0 |
|
|
|
for i in range(len(art_recording)): |
|
|
|
if art_recording[i] == 'ts': # following entry is timestamp |
|
|
|
art_info[pos_counter] = float(art_recording[i+1]) |
|
|
|
if art_recording[i] == '6d': # following entries are x,y,z,alpha,beta,gamma |
|
|
|
art_info[pos_counter, 1] = float(art_recording[i+3].split('[')[1]) # x (had to delete some excess text) |
|
|
|
art_info[pos_counter, 2] = float(art_recording[i+4]) # y |
|
|
|
art_info[pos_counter, 3] = float(art_recording[i+5]) # z |
|
|
|
|
|
|
|
art_info[pos_counter, 4] = float(art_recording[i+6]) # alpha |
|
|
|
art_info[pos_counter, 5] = float(art_recording[i+7]) # beta |
|
|
|
art_info[pos_counter, 6] = float(art_recording[i+8].split(']')[0]) # gamma (had to delete some excess text |
|
|
|
|
|
|
|
pos_counter += 1 |
|
|
|
|
|
|
|
"""------------------- Plotting ART ----------------------------------------------------""" |
|
|
|
font = {"family":"serif", |
|
|
|
"color":"black", |
|
|
|
"size":15} |
|
|
|
|
|
|
|
plt.plot(art_info[:, 1], art_info[:, 2], color="lightgreen", label="ART System", linewidth=5, marker="x") |
|
|
|
|
|
|
|
print("x=", art_info[:, 1]) |
|
|
|
print("y=", art_info[:, 2]) |