Added simulation data for the angle adjust and tuned the loop.
diff --git a/frc971/control_loops/python/angle_adjust.py b/frc971/control_loops/python/angle_adjust.py
index ed04198..f49c305 100755
--- a/frc971/control_loops/python/angle_adjust.py
+++ b/frc971/control_loops/python/angle_adjust.py
@@ -13,11 +13,11 @@
# Stall Current in Amps
self.stall_current = 63.8
# Free Speed in RPM
- self.free_speed = 16000.0
+ self.free_speed = 14900.0
# Free Current in Amps
self.free_current = 1.2
# Moment of inertia of the angle adjust about the shooter's pivot in kg m^2
- self.J = 0.41085133
+ self.J = 9.4
# Resistance of the motor
self.R = 12.0 / self.stall_current
# Motor velocity constant
@@ -44,7 +44,7 @@
self.ContinuousToDiscrete(self.A_continuous, self.B_continuous,
self.dt, self.C)
- self.PlaceControllerPoles([.89, .85])
+ self.PlaceControllerPoles([.5, .5])
self.rpl = .05
self.ipl = 0.008
@@ -56,13 +56,23 @@
def main(argv):
# Simulate the response of the system to a step input.
+ angle_adjust_data = numpy.genfromtxt(
+ 'angle_adjust/angle_adjust_data.csv', delimiter=',')
angle_adjust = AngleAdjust()
simulated_x = []
- for _ in xrange(100):
- angle_adjust.Update(numpy.matrix([[12.0]]))
+ real_x = []
+ initial_x = angle_adjust_data[0, 2]
+ for i in xrange(angle_adjust_data.shape[0]):
+ angle_adjust.Update(numpy.matrix([[angle_adjust_data[i, 1] - 0.7]]))
simulated_x.append(angle_adjust.X[0, 0])
+ x_offset = angle_adjust_data[i, 2] - initial_x
+ real_x.append(x_offset)
- pylab.plot(range(100), simulated_x)
+ sim_delay = 2
+ pylab.plot(range(sim_delay, angle_adjust_data.shape[0] + sim_delay),
+ simulated_x, label='Simulation')
+ pylab.plot(range(angle_adjust_data.shape[0]), real_x, label='Reality')
+ pylab.legend()
pylab.show()
# Simulate the closed loop response of the system to a step input.
@@ -82,8 +92,11 @@
if len(argv) != 3:
print "Expected .cc file name and .h file name"
else:
- angle_adjust.DumpHeaderFile(argv[1])
- angle_adjust.DumpCppFile(argv[2], argv[1])
+ if argv[1][-3:] == '.cc':
+ print '.cc file is second'
+ else:
+ angle_adjust.DumpHeaderFile(argv[1])
+ angle_adjust.DumpCppFile(argv[2], argv[1])
if __name__ == '__main__':
sys.exit(main(sys.argv))