Fix segfaults in spline UI
I suspect that this actually started happening when Python upgrades
happened, since the previous logic was checking for zero-length
trajectories, but it looks like numpy may now manage zero-length arrays
differently than it did previousl.
Change-Id: Id4212d0c7ea6efcf47295841c92de3aad79072a5
diff --git a/frc971/control_loops/python/libspline.py b/frc971/control_loops/python/libspline.py
index 4e68221..9ba6f4f 100755
--- a/frc971/control_loops/python/libspline.py
+++ b/frc971/control_loops/python/libspline.py
@@ -251,6 +251,9 @@
libSpline.TrajectoryGetPlanXVAPtr(self.__trajectory,
int(dt * 1e9)))
XVALength = libSpline.TrajectoryGetVectorLength(XVAPtr)
+ if XVALength == 0:
+ libSpline.TrajectoryDeleteVector(XVAPtr)
+ return None
X = np.zeros(XVALength)
V = np.zeros(XVALength)
A = np.zeros(XVALength)