aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/graph_extruder.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-02-03 16:41:14 -0500
committerKevin O'Connor <kevin@koconnor.net>2020-02-03 16:42:57 -0500
commitb3a180ea7723eb11cde757b25dc7f973765f0cf4 (patch)
treef73a6caebf0a67ecedff63995c45ed284e611196 /scripts/graph_extruder.py
parent2336d2d6ab0585f376d068d52e6480569d886912 (diff)
downloadkutter-b3a180ea7723eb11cde757b25dc7f973765f0cf4.tar.gz
kutter-b3a180ea7723eb11cde757b25dc7f973765f0cf4.tar.xz
kutter-b3a180ea7723eb11cde757b25dc7f973765f0cf4.zip
graph_extruder: Add in older pa algorithms for reference
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts/graph_extruder.py')
-rwxr-xr-xscripts/graph_extruder.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/graph_extruder.py b/scripts/graph_extruder.py
index 5c0fb5cf..1a5bfb6c 100755
--- a/scripts/graph_extruder.py
+++ b/scripts/graph_extruder.py
@@ -62,11 +62,30 @@ def time_to_index(t):
PA_HALF_SMOOTH_T = .040 / 2.
PRESSURE_ADVANCE = .045
+# Calculate raw pressure advance positions
def calc_pa_raw(t, positions):
pa = PRESSURE_ADVANCE * INV_SEG_TIME
i = time_to_index(t)
return positions[i] + pa * (positions[i+1] - positions[i])
+# Pressure advance smoothed using average velocity (for reference only)
+def calc_pa_average(t, positions):
+ pa_factor = PRESSURE_ADVANCE / (2. * PA_HALF_SMOOTH_T)
+ base_pos = positions[time_to_index(t)]
+ start_pos = positions[time_to_index(t - PA_HALF_SMOOTH_T)]
+ end_pos = positions[time_to_index(t + PA_HALF_SMOOTH_T)]
+ return base_pos + (end_pos - start_pos) * pa_factor
+
+# Pressure advance with simple time smoothing (for reference only)
+def calc_pa_smooth(t, positions):
+ start_index = time_to_index(t - PA_HALF_SMOOTH_T) + 1
+ end_index = time_to_index(t + PA_HALF_SMOOTH_T)
+ pa = PRESSURE_ADVANCE * INV_SEG_TIME
+ pa_data = [positions[i] + pa * (positions[i+1] - positions[i])
+ for i in range(start_index, end_index)]
+ return sum(pa_data) / (end_index - start_index)
+
+# Calculate pressure advance smoothed using a "weighted average"
def calc_pa_weighted(t, positions):
base_index = time_to_index(t)
start_index = time_to_index(t - PA_HALF_SMOOTH_T) + 1