diff --git a/DRAF_udp_send.py b/DRAF_udp_send.py deleted file mode 100644 index b9a2e867b68f74a33cbb88f14b932b4826c7a43b..0000000000000000000000000000000000000000 --- a/DRAF_udp_send.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Tue May 9 13:31:50 2023 - -@author: Jessica Dreyer, Sebastian Böttger -""" -#%% imports -import socket -import random -from datetime import datetime - -#%% constants -HOST = "127.0.0.1" -PORT = 50007 - -#%% script -# create socket connection -with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - s.connect((HOST,PORT)) - time_last_send = datetime.utcnow() - - while (1): - # buid send string - w = random.random() - v = random.random() + 144 - v_str = str(format((round(v, 5)), '.5f')).zfill(3) - w_str = format((round(w, 5)), '.5f') - if (w >= 0): - w_str = "+" + w_str - time_delta = datetime.utcnow() - time_last_send - t_str = format((round(time_delta.total_seconds(), 6)), '.6f') - stringSend = "w=" + w_str + "v=" + v_str +"t=" + t_str - - # send string - s.sendall(stringSend.encode()) - time_last_send = datetime.utcnow() \ No newline at end of file diff --git a/TEST_grafic.py b/TEST_grafic.py deleted file mode 100644 index 82039a292af66e67b3b7b3692915e39971c66ec6..0000000000000000000000000000000000000000 --- a/TEST_grafic.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Tue Jun 6 08:42:32 2023 - -@author: Basti-Uni -""" - -#%% imports -import numpy as np -import pandas as pd -import matplotlib.pyplot as plt -import matplotlib.patches as patches -from matplotlib.patches import Circle -import matplotlib.image as img - -# not impoertend imports -import time -import random - -#%% classes - - -background_url = './Bilder/Strecke_02.jpg' -background = img.imread(background_url) -#background = background.resize((1500, 800)) -fig = plt.figure() -ax = fig.add_subplot(111) -live_image = ax.imshow(background) -ax.set_xlim(0,4032) -ax.set_ylim(3024,0) -plt.show(block=False) - -#%% -for x in range(10): - ax.plot([(x*100)+550, 500], [800, 2000], color='red', linewidth=10) - fig.canvas.draw_idle() - fig.canvas.flush_events() - time.sleep(1) - -#%% -import matplotlib.pyplot as plt -import numpy as np -from matplotlib.animation import FuncAnimation - -# Bild laden -image_path = './Bilder/Strecke_02.jpg' -image = plt.imread(image_path) - -# Start- und Endposition der Linie -start_x, start_y = 100, 100 -end_x, end_y = 400, 400 - -# Anzahl der Schritte -num_steps = 100 - -# Zwischenwerte für die Linienposition berechnen -x_values = np.linspace(start_x, end_x, num_steps) -y_values = np.linspace(start_y, end_y, num_steps) - -# Funktion zum Zeichnen des Bildes und der Linie -def draw_image(frame): - plt.imshow(image) - plt.plot([x_values[frame], y_values[frame]], [x_values[frame+1], y_values[frame+1]], color='red', linewidth=2) - plt.axis('off') - -# Funktion zum Aktualisieren der Linienposition -def update_line(frame): - # Bild anzeigen und Linie zeichnen - plt.cla() # Vorherigen Plot löschen - draw_image(frame) - -# Animation erstellen -fig = plt.figure() -animation = FuncAnimation(fig, update_line, frames=num_steps-1, repeat=True, interval=50) # 50 Millisekunden Verzögerung zwischen den Schritten - -# Bild anzeigen -plt.show() - - - diff --git a/TEST_lokalisierung.py b/TEST_lokalisierung.py deleted file mode 100644 index e5c43dca7242d212e0325c77b82cc21bf2a32fca..0000000000000000000000000000000000000000 --- a/TEST_lokalisierung.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Tue May 30 19:26:11 2023 - -@author: Basti-Uni -""" - -#%% imports -import numpy as np -import pandas as pd - -#%% Constans -S = 0 # Value for a straight part of the track -R = 1 # Value for a right turn -L = 2 # Value for a left turn - - -#%% Erstellen der Strecke -track = [] -track.append(["S1", S, [L,S,L,R,S]]) -track.append(["S2", L, [S,L,S,L,R]]) -track.append(["S3", S, [L,S,L,S,L]]) -track.append(["S4", L, [S,L,S,L,S]]) -track.append(["S5", S, [L,S,L,S,L]]) -track.append(["S6", R, [S,L,S,L,S]]) -track.append(["S7", S, [R,S,L,S,L]]) -track.append(["S8", L, [S,R,S,L,S]]) -track.append(["S9", S, [L,S,R,S,L]]) -track.append(["S10", R, [S,L,S,R,S]]) -track.append(["S11", L, [R,S,L,S,R]]) -track.append(["S12", S, [L,R,S,L,S]]) -track.append(["S13", L, [S,L,R,S,L]]) - -# DataFrame erstellen -sections = pd.DataFrame(track, columns=['s_name', 'type', 'previous']); -current_section_type = S -last_sections_type = [L,S,L,S,L] -last_known_section = sections.iloc[3] - - -#%% Allgorithmus: -possible_sections = sections[sections.type == current_section_type] -previous_count = 0 -while(len(possible_sections) > 1 and previous_count < 5): - if(last_sections_type[previous_count] == None): - previous_count = 5 - else: - previous_types = pd.DataFrame(possible_sections.previous.array) - possible_sections = possible_sections[(previous_types[previous_count] == last_sections_type[previous_count]).array] - previous_count += 1 - -if(len(possible_sections) > 1): - print("More than one part of the track is possible for localization.") - if (last_known_section is not None): - - # Calculate distance from last known_section to all possible sections - index_last_known_section = sections[sections.s_name == last_known_section.s_name].index[0] - print("Index of Last Section: ", index_last_known_section) - - ### Änderungsvorschlag Anfang - help_sections = sections.copy() - help_sections.index += sections.shape[0] - help_sections = sections.copy().append(help_sections) - - filtert_section = pd.DataFrame() - for possible_section_s_name in np.array(possible_sections.s_name): - filtert_section = filtert_section.append(help_sections[help_sections.s_name == possible_section_s_name]) - - - indexs = abs(filtert_section.index - index_last_known_section) - print("Distance from indexs: ", indexs) - - # Get index of entry with the smallest distance - min_index = np.argmin(indexs) - - # Check if there is more than one entry with the same distance like min_index - all_min_indices = np.where(indexs == indexs[min_index])[0] - - # If there is more than on index, localization failed - if(len(all_min_indices) > 1): - min_index = all_min_indices[1] - print("No localization possible") - print(possible_sections) - s_name_possible_section = filtert_section.iloc[min_index].s_name - possible_sections = possible_sections[possible_sections.s_name == s_name_possible_section] - print ("Am nahliegenste Section:", possible_sections) - else: - print("No localization possible - More than one part of the track can fit") - print(possible_sections) - -elif(len(possible_sections) < 1): - print("No possible section was found. No localization possible.") - -if(len(possible_sections) == 1): - #print(possible_sections) - last_known_section = possible_sections.iloc[0] - - - - - - -