Improve Spline UI graph behavior for edge cases
If one of the multisplines fails to optimize, trying to put the cursor
on it will cause an out of bounds error
If the robot was still highlighted on the splines and you tried to move
the cursor from the graph, it wouldn't work.
Signed-off-by: Ravago Jones <ravagojones@gmail.com>
Change-Id: Ic8c37c5de07f6ef6d7a2b71971f34627e6ad2dba
diff --git a/frc971/control_loops/python/graph.py b/frc971/control_loops/python/graph.py
index 7d73a79..b85b996 100644
--- a/frc971/control_loops/python/graph.py
+++ b/frc971/control_loops/python/graph.py
@@ -47,6 +47,8 @@
if self.data is None:
return None
cursor_index = int(self.cursor / self.dt)
+ if cursor_index > self.data.size:
+ return None
# use the time to index into the position data
distance_at_cursor = self.data[0][cursor_index - 1]
multispline_index = int(self.data[5][cursor_index - 1])