diff --git a/LIDARListener.py b/LIDARListener.py index a961198..99b20f9 100644 --- a/LIDARListener.py +++ b/LIDARListener.py @@ -9,6 +9,7 @@ fig, ax = plt.subplots(subplot_kw={'projection': 'polar'}) ax.set_title("LiDAR Strength and Distance") +ax.set_ylim(0, 100) # ADJUST LIMIT plt.show() with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: @@ -24,14 +25,14 @@ print(data) received_data = data.decode().split(',') if len(received_data) == 2: - strength, distance = map(float, received_data) - ax.clear() - ax.scatter(angles, np.full_like(angles, distance), c=np.full_like(angles, strength), cmap='viridis', - alpha=0.75) - ax.set_title("LiDAR Strength and Distance") - plt.draw() - plt.pause(0.001) - print("Strength:", strength, "Distance:", distance) + angle, distance = map(float, received_data) + angle = np.deg2rad(angle) + if 0 <= angle <= 2*np.pi and 0 <= distance <= 100: + ax.clear() + ax.scatter(angle, distance, c='b', alpha=0.75) + ax.set_title("LiDAR Strength and Distance") + ax.set_ylim(0, 100) # ADJUST LIMIT + plt.pause(0.01) def main():