Hooking up the inputs with restrictions
IMPORTANT NOTE: This will not work and will throw errors until Ravago
implements the setConstraint function in points.py which at the time of
writing this has not yet been committed.
Change-Id: Iee226103dcf2f510c18404ca650df23e771fd85c
diff --git a/frc971/control_loops/python/spline_graph.py b/frc971/control_loops/python/spline_graph.py
index 86dd001..73f0460 100755
--- a/frc971/control_loops/python/spline_graph.py
+++ b/frc971/control_loops/python/spline_graph.py
@@ -51,18 +51,29 @@
def input_json_clicked(self, button):
print("INPUT JSON CLICKED")
self.drawing_area.import_json(self.file_name_box.get_text())
+ self.long_input.set_value(
+ self.drawing_area.points.getConstraint(
+ "LONGITUDINAL_ACCELERATION"))
+ self.lat_input.set_value(
+ self.drawing_area.points.getConstraint("LATERAL_ACCELERATION"))
+ self.vol_input.set_value(
+ self.drawing_area.points.getConstraint("VOLTAGE"))
def long_changed(self, button):
- print("LONGITUDAL VELOCITY CHANGED")
+ value = self.long_input.get_value()
+ self.drawing_area.points.setConstraint("LONGITUDINAL_ACCELERATION",
+ value)
def lat_changed(self, button):
- print("LATITUDAL VELOCITY CHANGED")
+ value = self.lat_input.get_value()
+ self.drawing_area.points.setConstraint("LATERAL_ACCELERATION", value)
- def accel_changed(self, button):
- print("ACCELERATION CHANGED")
+ def vel_changed(self, button):
+ value = self.vel_input.get_value()
def vol_changed(self, button):
- print("VOLTAGE CHANGED")
+ value = self.vol_input.get_value()
+ self.drawing_area.points.setConstraint("VOLTAGE", value)
def __init__(self):
Gtk.Window.__init__(self)
@@ -110,44 +121,59 @@
self.long_input = Gtk.SpinButton()
self.long_input.set_size_request(100, 20)
self.long_input.set_numeric(True)
- self.long_input.set_range(-100, 100)
+ self.long_input.set_range(0, 5)
+ self.long_input.set_digits(3)
+ self.long_input.set_increments(0.1, 100)
self.long_input.connect("value-changed", self.long_changed)
self.long_label = Gtk.Label()
- self.long_label.set_text("Longitudal Velocity Restriction")
+ self.long_label.set_text("Longitudinal Acceleration Restriction")
+ self.long_input.set_value(
+ self.drawing_area.points.getConstraint(
+ "LONGITUDINAL_ACCELERATION"))
self.lat_input = Gtk.SpinButton()
self.lat_input.set_size_request(100, 20)
self.lat_input.set_numeric(True)
- self.lat_input.set_range(-100, 100)
+ self.lat_input.set_range(0, 5)
+ self.lat_input.set_digits(3)
+ self.lat_input.set_increments(0.1, 100)
self.lat_input.connect("value-changed", self.lat_changed)
self.lat_label = Gtk.Label()
- self.lat_label.set_text("Latitudal Velocity Restriction")
+ self.lat_label.set_text("Lateral Acceleration Restriction")
+ self.lat_input.set_value(
+ self.drawing_area.points.getConstraint("LATERAL_ACCELERATION"))
- self.accel_input = Gtk.SpinButton()
- self.accel_input.set_size_request(100, 20)
- self.accel_input.set_numeric(True)
- self.accel_input.set_range(-100, 100)
- self.accel_input.connect("value-changed", self.accel_changed)
-
- self.accel_label = Gtk.Label()
- self.accel_label.set_text("Acceleration Restriction")
+ self.vel_input = Gtk.SpinButton()
+ self.vel_input.set_size_request(100, 20)
+ self.vel_input.set_numeric(True)
+ self.vel_input.set_range(0, 10)
+ self.vel_input.set_digits(3)
+ self.vel_input.set_increments(0.1, 100)
+ self.vel_input.connect("value-changed", self.vel_changed)
+ self.vel_label = Gtk.Label()
+ self.vel_label.set_text(
+ "Velocity Restriction"
+ ) #note: the velocity restrictions are not yet working, they need to be hooked up later
self.vol_input = Gtk.SpinButton()
self.vol_input.set_size_request(100, 20)
self.vol_input.set_numeric(True)
- self.vol_input.set_range(-12, 12)
+ self.vol_input.set_range(0, 12)
+ self.vol_input.set_digits(3)
+ self.vol_input.set_increments(0.1, 100)
self.vol_input.connect("value-changed", self.vol_changed)
-
self.vol_label = Gtk.Label()
self.vol_label.set_text("Voltage Restriction")
+ self.vol_input.set_value(
+ self.drawing_area.points.getConstraint("VOLTAGE"))
container.put(self.long_input, 0, 60)
container.put(self.lat_input, 0, 110)
- container.put(self.accel_input, 0, 160)
+ container.put(self.vel_input, 0, 160)
container.put(self.vol_input, 0, 210)
container.put(self.long_label, 0, 40)
container.put(self.lat_label, 0, 90)
- container.put(self.accel_label, 0, 140)
+ container.put(self.vel_label, 0, 140)
container.put(self.vol_label, 0, 190)
self.output_json = Gtk.Button.new_with_label("Output")