-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
118 changed files
with
3,185 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import numpy as np | ||
import polars as pl | ||
import scipy.fftpack as fftpack | ||
|
||
def low_pass_filter(array, fraction): | ||
transform = fftpack.fft(array) | ||
length = array.shape[0] | ||
end_length = ((1 - fraction)/2) | ||
start = round(length*end_length) | ||
end = round(length*(1-end_length)) | ||
transform[start:end] = np.zeros_like(transform[start:end]) | ||
output = fftpack.ifft(transform) | ||
# output.real | ||
return output.real |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
## This file contains the code originally used to create a plot using gps coordinates to create | ||
## a heat map. Currently has updated functioning graphs for rpm, torque, and braking. 2025-01-20 (last update by Nathaniel) | ||
## Made and commented by Nathaniel Platt | ||
import polars as pl | ||
import matplotlib.pyplot as plt | ||
from heatGraph import colored_line | ||
|
||
df = pl.read_parquet("Parquet/2024-12-02-Part1-100Hz.pq") | ||
# df = pl.read_csv("Temp/2024-12-02-Part1-100Hz.csv",infer_schema_length=0).with_columns(pl.all().cast(pl.Float32, strict=False)) | ||
# df1 = pl.read_csv("Temp/2024-12-02-Part2-100Hz.csv",infer_schema_length=0).with_columns(pl.all().cast(pl.Float32, strict=False)) | ||
df1 = pl.read_parquet("Parquet/2024-12-02-Part2-100Hz.pq") | ||
|
||
df.columns | ||
|
||
time1 = 1400 | ||
# time1 = 1000 | ||
time2 = 1650 | ||
# time2 = 1900 | ||
lat = "VDM_GPS_Latitude" | ||
long = "VDM_GPS_Longitude" | ||
speed = "SME_TRQSPD_Speed" | ||
busCurrent = "SME_TEMP_BusCurrent" | ||
tsCurrent = "TS_Current" | ||
torque = "SME_THROTL_TorqueDemand" | ||
brakes = "Brakes" | ||
df.columns | ||
short = pl.DataFrame(df.filter(pl.col("Seconds") >= time1).filter(pl.col("Seconds") <= time2)).filter(pl.col("VDM_GPS_Latitude") != 0).filter(pl.col("VDM_GPS_Longitude") != 0) | ||
|
||
|
||
# df.drop_nulls().select(lat).mean() | ||
|
||
# df.select(lat).filter(pl.col("VDM_GPS_Latitude") != 0) | ||
# df.filter(pl.col("Seconds") == 498.199).select([lat,long])\ | ||
# fig = plt.figure() | ||
# fig.add_subplot(1,1,1) | ||
# ax = plt.figure().add_subplot(1,1,1) | ||
# ax.pcolorfast(-1*short[long],-1*short[lat],a) | ||
# ax.plot(-1*short[long],-1*short[lat]) | ||
# ax.axis('scaled') | ||
# plt.show() | ||
# df.columns | ||
|
||
import warnings | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from matplotlib.collections import LineCollection | ||
|
||
fig1 = plt.figure() | ||
ax1 = fig1.add_subplot(1,1,1) | ||
lines = colored_line(short[lat], short[long], short[busCurrent], ax1, linewidth=1, cmap="plasma") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Bus Current (A)") | ||
plt.show() | ||
|
||
# Create a figure and plot the line on it | ||
fig1 = plt.figure() | ||
ax1 = fig1.add_subplot(1,3,1) | ||
lines = colored_line(short[lat], short[long], short[speed]/7500*109, ax1, linewidth=1, cmap="plasma") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("RPM (motor)") | ||
|
||
ax1 = fig1.add_subplot(1,3,2) | ||
lines = colored_line(short[lat], short[long], short[torque]/30000*7500, ax1, linewidth=1, cmap="viridis") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Torque (Nm)") | ||
|
||
ax1 = fig1.add_subplot(1,3,3) | ||
lines = colored_line(short[lat], short[long], (short[brakes]-0.1)*2000, ax1, linewidth=1, cmap="inferno") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Braking (psi)") | ||
|
||
plt.show() | ||
|
||
fig1 = plt.figure() | ||
ax1 = fig1.add_subplot(1,3,1) | ||
lines = colored_line(short[lat], short[long], short[busCurrent], ax1, linewidth=1, cmap="plasma") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Motor Controller Current (A)") | ||
|
||
ax1 = fig1.add_subplot(1,3,2) | ||
lines = colored_line(short[lat], short[long], short[tsCurrent], ax1, linewidth=1, cmap="viridis") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Accumulator Current (A)") | ||
|
||
ax1 = fig1.add_subplot(1,3,3) | ||
lines = colored_line(short[lat], short[long], (short[brakes]-0.1)*2000, ax1, linewidth=1, cmap="inferno") | ||
fig1.colorbar(lines) # add a color legend | ||
ax1.axis('scaled') | ||
ax1.set_title("Braking (psi)") | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
## This file is for visualizing the tire data we bought fall 2024. | ||
## All code should still be functional - Nathaniel 1/11/25 | ||
|
||
import polars as pl | ||
from matplotlib import pyplot as plt | ||
import os | ||
import re | ||
|
||
# folder = r"" | ||
# files = [f for f in os.listdir(folder) if os.path.isfile(os.path.join(folder, f))] | ||
# files = [folder+"\\"+f for f in files if f[-4:] == ".dat"] | ||
# files.sort(key = lambda f:int(re.match(r".+?([0-9]+)\.dat", f).group(1))) | ||
|
||
files = [r"TireData\B1965raw2.dat"] | ||
|
||
timeKey = r"ET" | ||
size = 1000 | ||
|
||
# see = df.columns | ||
see = ["FY", "FX", "P"] | ||
|
||
t1 = 0 | ||
t2 = float("inf") | ||
|
||
def readfile(filename): | ||
if filename[-3:] == ".pq": | ||
df = pl.read_parquet(filename) | ||
elif filename[-4:] == ".csv": | ||
df = pl.read_csv(filename, infer_schema_length=10000, ignore_errors=True) | ||
elif filename[-4:] == ".dat": | ||
with open(filename, "r") as file: | ||
text = file.readlines() | ||
text.pop(0) | ||
text.pop(1) | ||
text = [row.strip() for row in text] | ||
rows = [row.split("\t") for row in text] | ||
header = rows[0] | ||
rows = [[float(i) for i in row] for row in rows[1:]] | ||
# frame = {h:[for row in text] for n, h in enumerate(rows[0])} | ||
df = pl.DataFrame(rows, schema=header, orient="row") | ||
else: | ||
print("can't read") | ||
return None | ||
|
||
return df | ||
|
||
def getTime(df): | ||
print(df.columns) | ||
t = df[timeKey] | ||
print(t, len(t)) | ||
return t | ||
|
||
def plot(x, y, lab = ""): | ||
skip = max(1, int(len(x)/size)) | ||
plt.plot(x[::skip], y[::skip], linestyle="", marker="o") | ||
plt.xlabel(lab) | ||
plt.show() | ||
|
||
def getIndexes(t1, t2, t): | ||
t2 = min(t[-1], t2) | ||
i1 = int((t1/t[-1])*len(t)) | ||
i2 = int((t2/t[-1])*len(t)) | ||
return i1, i2 | ||
|
||
for f in files: | ||
df = readfile(f) | ||
if isinstance(df, type(None)): | ||
continue | ||
# df.write_csv(f.replace(folder, "TireDataCSV").replace(".dat",".csv")) | ||
t = getTime(df) | ||
i1, i2 = getIndexes(t1, t2, t) | ||
for c in see: | ||
plot(t[i1:i2], df[c][i1:i2], f + " " + c) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
## Contains the function we use for generating heat plots. | ||
## Code placed, edited and commented by Nathaniel Platt. Sourced online (don't remember where :( | ||
## Use like this: | ||
|
||
# fig1 = plt.figure() | ||
# ax1 = fig1.add_subplot(1,3,2) | ||
# lines = colored_line(short[lat], short[long], short[torque], ax1, linewidth=1, cmap="viridis") | ||
# fig1.colorbar(lines) # add a color legend | ||
# ax1.axis('scaled') | ||
# ax1.set_title("Torque") | ||
|
||
import numpy as np | ||
import warnings | ||
from matplotlib.collections import LineCollection | ||
|
||
# -------------- Create and show plot -------------- | ||
# Some arbitrary function that gives x, y, and color values | ||
def colored_line(x, y, c, ax, **lc_kwargs): | ||
""" | ||
Plot a line with a color specified along the line by a third value. | ||
It does this by creating a collection of line segments. Each line segment is | ||
made up of two straight lines each connecting the current (x, y) point to the | ||
midpoints of the lines connecting the current point with its two neighbors. | ||
This creates a smooth line with no gaps between the line segments. | ||
Parameters | ||
---------- | ||
x, y : array-like | ||
The horizontal and vertical coordinates of the data points. | ||
c : array-like | ||
The color values, which should be the same size as x and y. | ||
ax : Axes | ||
Axis object on which to plot the colored line. | ||
**lc_kwargs | ||
Any additional arguments to pass to matplotlib.collections.LineCollection | ||
constructor. This should not include the array keyword argument because | ||
that is set to the color argument. If provided, it will be overridden. | ||
Returns | ||
------- | ||
matplotlib.collections.LineCollection | ||
The generated line collection representing the colored line. | ||
""" | ||
if "array" in lc_kwargs: | ||
warnings.warn('The provided "array" keyword argument will be overridden') | ||
|
||
# Default the capstyle to butt so that the line segments smoothly line up | ||
default_kwargs = {"capstyle": "butt"} | ||
default_kwargs.update(lc_kwargs) | ||
|
||
# Compute the midpoints of the line segments. Include the first and last points | ||
# twice so we don't need any special syntax later to handle them. | ||
x = np.asarray(x) | ||
y = np.asarray(y) | ||
x_midpts = np.hstack((x[0], 0.5 * (x[1:] + x[:-1]), x[-1])) | ||
y_midpts = np.hstack((y[0], 0.5 * (y[1:] + y[:-1]), y[-1])) | ||
|
||
# Determine the start, middle, and end coordinate pair of each line segment. | ||
# Use the reshape to add an extra dimension so each pair of points is in its | ||
# own list. Then concatenate them to create: | ||
# [ | ||
# [(x1_start, y1_start), (x1_mid, y1_mid), (x1_end, y1_end)], | ||
# [(x2_start, y2_start), (x2_mid, y2_mid), (x2_end, y2_end)], | ||
# ... | ||
# ] | ||
coord_start = np.column_stack((x_midpts[:-1], y_midpts[:-1]))[:, np.newaxis, :] | ||
coord_mid = np.column_stack((x, y))[:, np.newaxis, :] | ||
coord_end = np.column_stack((x_midpts[1:], y_midpts[1:]))[:, np.newaxis, :] | ||
segments = np.concatenate((coord_start, coord_mid, coord_end), axis=1) | ||
|
||
lc = LineCollection(segments, **default_kwargs) | ||
lc.set_array(c) # set the colors of each segment | ||
|
||
return ax.add_collection(lc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## This file was created to generate IMU data but was too simple to function properly. | ||
## Does not work in its current state - Nathaniel 1/11/25 | ||
|
||
from matplotlib.axes import Axes | ||
from matplotlib.text import Text | ||
from matplotlib.transforms import Bbox | ||
import polars as pl | ||
import matplotlib.pyplot as plt | ||
from matplotlib import animation | ||
import numpy as np | ||
|
||
df = pl.read_parquet("./Parquet/2024-12-02-Part1-100Hz.pq") | ||
# df = pl.read_parquet("./Parquet/2024-12-02-Part2-100Hz.pq") | ||
|
||
time1 = 100 | ||
# time1 = 1530.4 | ||
# time1 = 1000 | ||
time2 = 9999999999 | ||
# time2 = 1710 | ||
# time2 = 1900 | ||
lat = "VDM_GPS_Latitude" | ||
long = "VDM_GPS_Longitude" | ||
|
||
df = pl.DataFrame(df.filter(pl.col("Seconds") >= time1).filter(pl.col("Seconds") <= time2))[::100] | ||
|
||
print(df.columns) | ||
|
||
fig, ax = plt.subplots(1,1) | ||
fig.set_label("Gyroscope (deg/s)") | ||
|
||
ax.plot(df.select("Seconds"), df.select("VDM_Z_AXIS_YAW_RATE"), label="Z Axis") | ||
ax.legend(loc="best") | ||
|
||
fig.tight_layout() | ||
plt.show() | ||
|
||
|
Oops, something went wrong.