Skip to content

Commit

Permalink
Made it work with angle,distance instead of strength
Browse files Browse the repository at this point in the history
  • Loading branch information
Mannvika committed Apr 25, 2024
1 parent 25ebf24 commit 8c60b65
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions LIDARListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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():
Expand Down

0 comments on commit 8c60b65

Please sign in to comment.