GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ArduinoTutorials/PythonProcess/processPlot.py at main · barionleg/ArduinoTutorials

Expand file tree

/

processPlot.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
52 lines (45 loc) · 1.21 KB
/

processPlot.py

Copy path

File metadata and controls

52 lines (45 loc) · 1.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# Import data using Pandas (install with: pip install pandas)
data = pd.read_csv("data.csv")
print(data)
# Retrieve data columns
D = data.to_numpy();
t = D[:,0]
pan = D[:,1]
tilt = D[:,2]
r_us = D[:,3] + 7 # to account for the sensor offset
r_tof = D[:,4] + 7
# Create a basic plot
plt.plot(t,r_us)
plt.plot(t,r_tof)
plt.legend(["us","tof"])
plt.ylabel("Range (mm)")
plt.xlabel("Time (s)")
plt.xlim([min(t),max(t)])
plt.savefig('basic.png') # Save plot to a file
plt.show()
# Process data -- convert to position
# Compute angle off z-axis (azimuth)
phi = (90-tilt)*np.pi/180
# Compute angle around z-axis (polar angle)
theta = pan*np.pi/180
# Convert to cartesian
x_us = r_us*np.cos(theta)*np.sin(phi)
y_us = r_us*np.sin(theta)*np.sin(phi)
z_us = r_us*np.cos(phi)
x_tof = r_tof*np.cos(theta)*np.sin(phi)
y_tof = r_tof*np.sin(theta)*np.sin(phi)
z_tof = r_tof*np.cos(phi)
# Scatter plot of 3D points
fig = plt.figure()
fig.tight_layout()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x_us,y_us,z_us,s=2)
ax.scatter(x_tof,y_tof,z_tof,s=2)
plt.legend(["us","tof"])
ax.set_ylim3d(-2000, 2000)
ax.set_xlim3d(-2000, 2000)
ax.set_zlim3d(0, 2000)
plt.show()
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.