blob: 7221870b1c065c8ee9bbe0b45c6d65e7326a8ca4 [file] [log] [blame]
Austin Schuh085eab92020-11-26 13:54:51 -08001#!/usr/bin/python3
Brian Silverman6260c092018-01-14 15:21:36 -08002
3from frc971.control_loops.python import control_loop
4from frc971.control_loops.python import controls
5import numpy
6import sys
7import copy
8import scipy.interpolate
9from matplotlib import pylab
10
11import gflags
12import glog
13
14FLAGS = gflags.FLAGS
15
16gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
17gflags.DEFINE_string('data', None, 'If defined, plot the provided CAN data')
Tyler Chatow6738c362019-02-16 14:12:30 -080018gflags.DEFINE_bool(
19 'rerun_kf', False,
20 'If true, rerun the KF. The torque in the data file will be interpreted as the commanded current.'
21)
22
Brian Silverman6260c092018-01-14 15:21:36 -080023
24class SystemParams(object):
Tyler Chatow6738c362019-02-16 14:12:30 -080025 def __init__(self, J, G, kP, kD, kCompensationTimeconstant, q_pos, q_vel,
26 q_torque, current_limit):
27 self.J = J
28 self.G = G
29 self.q_pos = q_pos
30 self.q_vel = q_vel
31 self.q_torque = q_torque
32 self.kP = kP
33 self.kD = kD
34 self.kCompensationTimeconstant = kCompensationTimeconstant
35 self.r_pos = 0.001
36 self.current_limit = current_limit
Brian Silverman6260c092018-01-14 15:21:36 -080037
Tyler Chatow6738c362019-02-16 14:12:30 -080038 #[15.0, 0.25],
39 #[10.0, 0.2],
40 #[5.0, 0.13],
41 #[3.0, 0.10],
42 #[2.0, 0.08],
43 #[1.0, 0.06],
44 #[0.5, 0.05],
45 #[0.25, 0.025],
46
47
48kWheel = SystemParams(
49 J=0.0008,
50 G=(1.25 + 0.02) / 0.35,
51 q_pos=0.001,
52 q_vel=0.20,
53 q_torque=0.005,
54 kP=7.0,
55 kD=0.0,
56 kCompensationTimeconstant=0.95,
57 current_limit=4.5)
58kTrigger = SystemParams(
59 J=0.00025,
60 G=(0.925 * 2.0 + 0.02) / 0.35,
61 q_pos=0.001,
62 q_vel=0.1,
63 q_torque=0.005,
64 kP=120.0,
65 kD=1.8,
66 kCompensationTimeconstant=0.95,
67 current_limit=3.0)
68
Brian Silverman6260c092018-01-14 15:21:36 -080069
70class HapticInput(control_loop.ControlLoop):
Tyler Chatow6738c362019-02-16 14:12:30 -080071 def __init__(self, params=None, name='HapticInput'):
72 # The defaults are for the steering wheel.
73 super(HapticInput, self).__init__(name)
74 motor = self.motor = control_loop.MN3510()
Brian Silverman6260c092018-01-14 15:21:36 -080075
Tyler Chatow6738c362019-02-16 14:12:30 -080076 # Moment of inertia of the wheel in kg m^2
77 self.J = params.J
Brian Silverman6260c092018-01-14 15:21:36 -080078
Tyler Chatow6738c362019-02-16 14:12:30 -080079 # Control loop time step
80 self.dt = 0.001
Brian Silverman6260c092018-01-14 15:21:36 -080081
Tyler Chatow6738c362019-02-16 14:12:30 -080082 # Gear ratio from the motor to the input.
83 self.G = params.G
Brian Silverman6260c092018-01-14 15:21:36 -080084
Tyler Chatow6738c362019-02-16 14:12:30 -080085 self.A_continuous = numpy.matrix(numpy.zeros((2, 2)))
86 self.A_continuous[1, 1] = 0
87 self.A_continuous[0, 1] = 1
Brian Silverman6260c092018-01-14 15:21:36 -080088
Tyler Chatow6738c362019-02-16 14:12:30 -080089 self.B_continuous = numpy.matrix(numpy.zeros((2, 1)))
90 self.B_continuous[1, 0] = motor.Kt * self.G / self.J
Brian Silverman6260c092018-01-14 15:21:36 -080091
Tyler Chatow6738c362019-02-16 14:12:30 -080092 # State feedback matrices
93 # [position, angular velocity]
94 self.C = numpy.matrix([[1.0, 0.0]])
95 self.D = numpy.matrix([[0.0]])
Brian Silverman6260c092018-01-14 15:21:36 -080096
Tyler Chatow6738c362019-02-16 14:12:30 -080097 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
98 self.B_continuous, self.dt)
Brian Silverman6260c092018-01-14 15:21:36 -080099
Tyler Chatow6738c362019-02-16 14:12:30 -0800100 self.U_max = numpy.matrix([[2.5]])
101 self.U_min = numpy.matrix([[-2.5]])
Brian Silverman6260c092018-01-14 15:21:36 -0800102
Tyler Chatow6738c362019-02-16 14:12:30 -0800103 self.L = numpy.matrix([[0.0], [0.0]])
104 self.K = numpy.matrix([[0.0, 0.0]])
105
106 self.InitializeState()
Brian Silverman6260c092018-01-14 15:21:36 -0800107
108
109class IntegralHapticInput(HapticInput):
Tyler Chatow6738c362019-02-16 14:12:30 -0800110 def __init__(self, params=None, name="IntegralHapticInput"):
111 super(IntegralHapticInput, self).__init__(name=name, params=params)
Brian Silverman6260c092018-01-14 15:21:36 -0800112
Tyler Chatow6738c362019-02-16 14:12:30 -0800113 self.A_continuous_unaugmented = self.A_continuous
114 self.B_continuous_unaugmented = self.B_continuous
Brian Silverman6260c092018-01-14 15:21:36 -0800115
Tyler Chatow6738c362019-02-16 14:12:30 -0800116 self.A_continuous = numpy.matrix(numpy.zeros((3, 3)))
117 self.A_continuous[0:2, 0:2] = self.A_continuous_unaugmented
118 self.A_continuous[1, 2] = (1 / self.J)
Brian Silverman6260c092018-01-14 15:21:36 -0800119
Tyler Chatow6738c362019-02-16 14:12:30 -0800120 self.B_continuous = numpy.matrix(numpy.zeros((3, 1)))
121 self.B_continuous[0:2, 0] = self.B_continuous_unaugmented
Brian Silverman6260c092018-01-14 15:21:36 -0800122
Tyler Chatow6738c362019-02-16 14:12:30 -0800123 self.C_unaugmented = self.C
124 self.C = numpy.matrix(numpy.zeros((1, 3)))
125 self.C[0:1, 0:2] = self.C_unaugmented
Brian Silverman6260c092018-01-14 15:21:36 -0800126
Tyler Chatow6738c362019-02-16 14:12:30 -0800127 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
128 self.B_continuous, self.dt)
Brian Silverman6260c092018-01-14 15:21:36 -0800129
Tyler Chatow6738c362019-02-16 14:12:30 -0800130 self.Q = numpy.matrix([[(params.q_pos**2.0), 0.0, 0.0],
131 [0.0, (params.q_vel**2.0), 0.0],
132 [0.0, 0.0, (params.q_torque**2.0)]])
Brian Silverman6260c092018-01-14 15:21:36 -0800133
Tyler Chatow6738c362019-02-16 14:12:30 -0800134 self.R = numpy.matrix([[(params.r_pos**2.0)]])
Brian Silverman6260c092018-01-14 15:21:36 -0800135
Tyler Chatow6738c362019-02-16 14:12:30 -0800136 self.KalmanGain, self.Q_steady = controls.kalman(
137 A=self.A, B=self.B, C=self.C, Q=self.Q, R=self.R)
138 self.L = self.A * self.KalmanGain
Brian Silverman6260c092018-01-14 15:21:36 -0800139
Tyler Chatow6738c362019-02-16 14:12:30 -0800140 self.K_unaugmented = self.K
141 self.K = numpy.matrix(numpy.zeros((1, 3)))
142 self.K[0, 0:2] = self.K_unaugmented
143 self.K[0, 2] = 1.0 / (self.motor.Kt / (self.motor.resistance))
144
145 self.InitializeState()
146
Brian Silverman6260c092018-01-14 15:21:36 -0800147
148def ReadCan(filename):
Tyler Chatow6738c362019-02-16 14:12:30 -0800149 """Reads the candump in filename and returns the 4 fields."""
150 trigger = []
151 trigger_velocity = []
152 trigger_torque = []
153 trigger_current = []
154 wheel = []
155 wheel_velocity = []
156 wheel_torque = []
157 wheel_current = []
Brian Silverman6260c092018-01-14 15:21:36 -0800158
Tyler Chatow6738c362019-02-16 14:12:30 -0800159 trigger_request_time = [0.0]
160 trigger_request_current = [0.0]
161 wheel_request_time = [0.0]
162 wheel_request_current = [0.0]
Brian Silverman6260c092018-01-14 15:21:36 -0800163
Tyler Chatow6738c362019-02-16 14:12:30 -0800164 with open(filename, 'r') as fd:
165 for line in fd:
166 data = line.split()
167 can_id = int(data[1], 16)
168 if can_id == 0:
169 data = [int(d, 16) for d in data[3:]]
170 trigger.append(((data[0] + (data[1] << 8)) - 32768) / 32768.0)
171 trigger_velocity.append(
172 ((data[2] + (data[3] << 8)) - 32768) / 32768.0)
173 trigger_torque.append(
174 ((data[4] + (data[5] << 8)) - 32768) / 32768.0)
175 trigger_current.append(
176 ((data[6] + ((data[7] & 0x3f) << 8)) - 8192) / 8192.0)
177 elif can_id == 1:
178 data = [int(d, 16) for d in data[3:]]
179 wheel.append(((data[0] + (data[1] << 8)) - 32768) / 32768.0)
180 wheel_velocity.append(
181 ((data[2] + (data[3] << 8)) - 32768) / 32768.0)
182 wheel_torque.append(
183 ((data[4] + (data[5] << 8)) - 32768) / 32768.0)
184 wheel_current.append(
185 ((data[6] + ((data[7] & 0x3f) << 8)) - 8192) / 8192.0)
186 elif can_id == 2:
187 data = [int(d, 16) for d in data[3:]]
188 trigger_request_current.append(
189 ((data[4] + (data[5] << 8)) - 32768) / 32768.0)
190 trigger_request_time.append(len(trigger) * 0.001)
191 elif can_id == 3:
192 data = [int(d, 16) for d in data[3:]]
193 wheel_request_current.append(
194 ((data[4] + (data[5] << 8)) - 32768) / 32768.0)
195 wheel_request_time.append(len(wheel) * 0.001)
Brian Silverman6260c092018-01-14 15:21:36 -0800196
Tyler Chatow6738c362019-02-16 14:12:30 -0800197 trigger_data_time = numpy.arange(0, len(trigger)) * 0.001
198 wheel_data_time = numpy.arange(0, len(wheel)) * 0.001
Brian Silverman6260c092018-01-14 15:21:36 -0800199
Tyler Chatow6738c362019-02-16 14:12:30 -0800200 # Extend out the data in the interpolation table.
201 trigger_request_time.append(trigger_data_time[-1])
202 trigger_request_current.append(trigger_request_current[-1])
203 wheel_request_time.append(wheel_data_time[-1])
204 wheel_request_current.append(wheel_request_current[-1])
Brian Silverman6260c092018-01-14 15:21:36 -0800205
Tyler Chatow6738c362019-02-16 14:12:30 -0800206 return (trigger_data_time, wheel_data_time, trigger, wheel,
207 trigger_velocity, wheel_velocity, trigger_torque, wheel_torque,
208 trigger_current, wheel_current, trigger_request_time,
209 trigger_request_current, wheel_request_time, wheel_request_current)
Brian Silverman6260c092018-01-14 15:21:36 -0800210
Brian Silverman6260c092018-01-14 15:21:36 -0800211
Tyler Chatow6738c362019-02-16 14:12:30 -0800212def rerun_and_plot_kf(data_time,
213 data_radians,
214 data_current,
215 data_request_current,
216 params,
217 run_correct=True):
218 kf_velocity = []
219 dt_velocity = []
220 kf_position = []
221 adjusted_position = []
222 last_angle = None
223 haptic_observer = IntegralHapticInput(params=params)
Brian Silverman6260c092018-01-14 15:21:36 -0800224
Tyler Chatow6738c362019-02-16 14:12:30 -0800225 # Parameter sweep J.
226 num_kf = 1
227 min_J = max_J = params.J
Brian Silverman6260c092018-01-14 15:21:36 -0800228
Tyler Chatow6738c362019-02-16 14:12:30 -0800229 # J = 0.0022
230 #num_kf = 15
231 #min_J = min_J / 2.0
232 #max_J = max_J * 2.0
233 initial_velocity = (data_radians[1] - data_radians[0]) * 1000.0
Brian Silverman6260c092018-01-14 15:21:36 -0800234
Tyler Chatow6738c362019-02-16 14:12:30 -0800235 def DupParamsWithJ(params, J):
236 p = copy.copy(params)
237 p.J = J
238 return p
Brian Silverman6260c092018-01-14 15:21:36 -0800239
Tyler Chatow6738c362019-02-16 14:12:30 -0800240 haptic_observers = [
241 IntegralHapticInput(params=DupParamsWithJ(params, j))
242 for j in numpy.logspace(
243 numpy.log10(min_J), numpy.log10(max_J), num=num_kf)
244 ]
245 # Initialize all the KF's.
246 haptic_observer.X_hat[1, 0] = initial_velocity
247 haptic_observer.X_hat[0, 0] = data_radians[0]
248 for observer in haptic_observers:
249 observer.X_hat[1, 0] = initial_velocity
250 observer.X_hat[0, 0] = data_radians[0]
Brian Silverman6260c092018-01-14 15:21:36 -0800251
Tyler Chatow6738c362019-02-16 14:12:30 -0800252 last_request_current = data_request_current[0]
Austin Schuh5ea48472021-02-02 20:46:41 -0800253 kf_torques = [[] for i in range(num_kf)]
Tyler Chatow6738c362019-02-16 14:12:30 -0800254 for angle, current, request_current in zip(data_radians, data_current,
255 data_request_current):
256 # Predict and correct all the parameter swept observers.
257 for i, observer in enumerate(haptic_observers):
258 observer.Y = numpy.matrix([[angle]])
259 if run_correct:
260 observer.CorrectObserver(numpy.matrix([[current]]))
261 kf_torques[i].append(-observer.X_hat[2, 0])
262 observer.PredictObserver(numpy.matrix([[current]]))
263 observer.PredictObserver(numpy.matrix([[current]]))
Brian Silverman6260c092018-01-14 15:21:36 -0800264
Tyler Chatow6738c362019-02-16 14:12:30 -0800265 # Predict and correct the main observer.
266 haptic_observer.Y = numpy.matrix([[angle]])
267 if run_correct:
268 haptic_observer.CorrectObserver(numpy.matrix([[current]]))
269 kf_position.append(haptic_observer.X_hat[0, 0])
270 adjusted_position.append(kf_position[-1] -
271 last_request_current / params.kP)
272 last_request_current = last_request_current * params.kCompensationTimeconstant + request_current * (
273 1.0 - params.kCompensationTimeconstant)
274 kf_velocity.append(haptic_observer.X_hat[1, 0])
275 if last_angle is None:
276 last_angle = angle
277 dt_velocity.append((angle - last_angle) / 0.001)
Brian Silverman6260c092018-01-14 15:21:36 -0800278
Tyler Chatow6738c362019-02-16 14:12:30 -0800279 haptic_observer.PredictObserver(numpy.matrix([[current]]))
280 last_angle = angle
Brian Silverman6260c092018-01-14 15:21:36 -0800281
Tyler Chatow6738c362019-02-16 14:12:30 -0800282 # Plot the wheel observers.
283 fig, ax1 = pylab.subplots()
284 ax1.plot(data_time, data_radians, '.', label='wheel')
285 ax1.plot(data_time, dt_velocity, '.', label='dt_velocity')
286 ax1.plot(data_time, kf_velocity, '.', label='kf_velocity')
287 ax1.plot(data_time, kf_position, '.', label='kf_position')
288 ax1.plot(data_time, adjusted_position, '.', label='adjusted_position')
Brian Silverman6260c092018-01-14 15:21:36 -0800289
Tyler Chatow6738c362019-02-16 14:12:30 -0800290 ax2 = ax1.twinx()
291 ax2.plot(data_time, data_current, label='data_current')
292 ax2.plot(data_time, data_request_current, label='request_current')
Brian Silverman6260c092018-01-14 15:21:36 -0800293
Tyler Chatow6738c362019-02-16 14:12:30 -0800294 for i, kf_torque in enumerate(kf_torques):
295 ax2.plot(
296 data_time,
297 kf_torque,
298 label='-kf_torque[%f]' % haptic_observers[i].J)
299 fig.tight_layout()
300 ax1.legend(loc=3)
301 ax2.legend(loc=4)
Brian Silverman6260c092018-01-14 15:21:36 -0800302
Brian Silverman6260c092018-01-14 15:21:36 -0800303
Tyler Chatow6738c362019-02-16 14:12:30 -0800304def plot_input(data_time,
305 data_radians,
306 data_velocity,
307 data_torque,
308 data_current,
309 params,
310 run_correct=True):
311 dt_velocity = []
312 last_angle = None
313 initial_velocity = (data_radians[1] - data_radians[0]) * 1000.0
Brian Silverman6260c092018-01-14 15:21:36 -0800314
Tyler Chatow6738c362019-02-16 14:12:30 -0800315 for angle in data_radians:
316 if last_angle is None:
317 last_angle = angle
318 dt_velocity.append((angle - last_angle) / 0.001)
319
320 last_angle = angle
321
322 # Plot the wheel observers.
323 fig, ax1 = pylab.subplots()
324 ax1.plot(data_time, data_radians, '.', label='angle')
325 ax1.plot(data_time, data_velocity, '-', label='velocity')
326 ax1.plot(data_time, dt_velocity, '.', label='dt_velocity')
327
328 ax2 = ax1.twinx()
329 ax2.plot(data_time, data_torque, label='data_torque')
330 ax2.plot(data_time, data_current, label='data_current')
331 fig.tight_layout()
332 ax1.legend(loc=3)
333 ax2.legend(loc=4)
334
Brian Silverman6260c092018-01-14 15:21:36 -0800335
336def main(argv):
Tyler Chatow6738c362019-02-16 14:12:30 -0800337 if FLAGS.plot:
338 if FLAGS.data is None:
339 haptic_wheel = HapticInput()
340 haptic_wheel_controller = IntegralHapticInput()
341 observer_haptic_wheel = IntegralHapticInput()
342 observer_haptic_wheel.X_hat[2, 0] = 0.01
Brian Silverman6260c092018-01-14 15:21:36 -0800343
Tyler Chatow6738c362019-02-16 14:12:30 -0800344 R = numpy.matrix([[0.0], [0.0], [0.0]])
Brian Silverman6260c092018-01-14 15:21:36 -0800345
Tyler Chatow6738c362019-02-16 14:12:30 -0800346 control_loop.TestSingleIntegralAxisSquareWave(
347 R, 1.0, haptic_wheel, haptic_wheel_controller,
348 observer_haptic_wheel)
349 else:
350 # Read the CAN trace in.
351 trigger_data_time, wheel_data_time, trigger, wheel, trigger_velocity, \
352 wheel_velocity, trigger_torque, wheel_torque, trigger_current, \
353 wheel_current, trigger_request_time, trigger_request_current, \
354 wheel_request_time, wheel_request_current = ReadCan(FLAGS.data)
355
356 wheel_radians = [w * numpy.pi * (338.16 / 360.0) for w in wheel]
357 wheel_velocity = [w * 50.0 for w in wheel_velocity]
358 wheel_torque = [w / 2.0 for w in wheel_torque]
359 wheel_current = [w * 10.0 for w in wheel_current]
360 wheel_request_current = [w * 2.0 for w in wheel_request_current]
361 resampled_wheel_request_current = scipy.interpolate.interp1d(
362 wheel_request_time, wheel_request_current,
363 kind="zero")(wheel_data_time)
364
365 trigger_radians = [t * numpy.pi * (45.0 / 360.0) for t in trigger]
366 trigger_velocity = [t * 50.0 for t in trigger_velocity]
367 trigger_torque = [t / 2.0 for t in trigger_torque]
368 trigger_current = [t * 10.0 for t in trigger_current]
Ravago Jones26f7ad02021-02-05 15:45:59 -0800369 trigger_request_current = [
370 t * 2.0 for t in trigger_request_current
371 ]
Tyler Chatow6738c362019-02-16 14:12:30 -0800372 resampled_trigger_request_current = scipy.interpolate.interp1d(
373 trigger_request_time, trigger_request_current,
374 kind="zero")(trigger_data_time)
375
376 if FLAGS.rerun_kf:
377 rerun_and_plot_kf(
378 trigger_data_time,
379 trigger_radians,
380 trigger_current,
381 resampled_trigger_request_current,
382 kTrigger,
383 run_correct=True)
384 rerun_and_plot_kf(
385 wheel_data_time,
386 wheel_radians,
387 wheel_current,
388 resampled_wheel_request_current,
389 kWheel,
390 run_correct=True)
391 else:
Ravago Jones26f7ad02021-02-05 15:45:59 -0800392 plot_input(trigger_data_time, trigger_radians,
393 trigger_velocity, trigger_torque, trigger_current,
394 kTrigger)
Tyler Chatow6738c362019-02-16 14:12:30 -0800395 plot_input(wheel_data_time, wheel_radians, wheel_velocity,
396 wheel_torque, wheel_current, kWheel)
397 pylab.show()
398
399 return
400
401 if len(argv) != 9:
402 glog.fatal('Expected .h file name and .cc file name')
Brian Silverman6260c092018-01-14 15:21:36 -0800403 else:
Tyler Chatow6738c362019-02-16 14:12:30 -0800404 namespaces = ['frc971', 'control_loops', 'drivetrain']
405 for name, params, filenames in [('HapticWheel', kWheel, argv[1:5]),
Ravago Jones26f7ad02021-02-05 15:45:59 -0800406 ('HapticTrigger', kTrigger,
407 argv[5:9])]:
Tyler Chatow6738c362019-02-16 14:12:30 -0800408 haptic_input = HapticInput(params=params, name=name)
409 loop_writer = control_loop.ControlLoopWriter(
410 name, [haptic_input],
411 namespaces=namespaces,
412 scalar_type='float')
413 loop_writer.Write(filenames[0], filenames[1])
Brian Silverman6260c092018-01-14 15:21:36 -0800414
Tyler Chatow6738c362019-02-16 14:12:30 -0800415 integral_haptic_input = IntegralHapticInput(
416 params=params, name='Integral' + name)
417 integral_loop_writer = control_loop.ControlLoopWriter(
418 'Integral' + name, [integral_haptic_input],
419 namespaces=namespaces,
420 scalar_type='float')
Brian Silverman6260c092018-01-14 15:21:36 -0800421
Tyler Chatow6738c362019-02-16 14:12:30 -0800422 integral_loop_writer.AddConstant(
423 control_loop.Constant("k" + name + "Dt", "%f",
424 integral_haptic_input.dt))
425 integral_loop_writer.AddConstant(
Ravago Jones26f7ad02021-02-05 15:45:59 -0800426 control_loop.Constant(
427 "k" + name + "FreeCurrent", "%f",
428 integral_haptic_input.motor.free_current))
Tyler Chatow6738c362019-02-16 14:12:30 -0800429 integral_loop_writer.AddConstant(
Ravago Jones26f7ad02021-02-05 15:45:59 -0800430 control_loop.Constant(
431 "k" + name + "StallTorque", "%f",
432 integral_haptic_input.motor.stall_torque))
Tyler Chatow6738c362019-02-16 14:12:30 -0800433 integral_loop_writer.AddConstant(
434 control_loop.Constant("k" + name + "J", "%f",
435 integral_haptic_input.J))
436 integral_loop_writer.AddConstant(
437 control_loop.Constant("k" + name + "R", "%f",
438 integral_haptic_input.motor.resistance))
439 integral_loop_writer.AddConstant(
440 control_loop.Constant("k" + name + "T", "%f",
441 integral_haptic_input.motor.Kt))
442 integral_loop_writer.AddConstant(
443 control_loop.Constant("k" + name + "V", "%f",
444 integral_haptic_input.motor.Kv))
445 integral_loop_writer.AddConstant(
446 control_loop.Constant("k" + name + "P", "%f", params.kP))
447 integral_loop_writer.AddConstant(
448 control_loop.Constant("k" + name + "D", "%f", params.kD))
449 integral_loop_writer.AddConstant(
450 control_loop.Constant("k" + name + "G", "%f", params.G))
451 integral_loop_writer.AddConstant(
452 control_loop.Constant("k" + name + "CurrentLimit", "%f",
453 params.current_limit))
Brian Silverman6260c092018-01-14 15:21:36 -0800454
Tyler Chatow6738c362019-02-16 14:12:30 -0800455 integral_loop_writer.Write(filenames[2], filenames[3])
Brian Silverman6260c092018-01-14 15:21:36 -0800456
457
458if __name__ == '__main__':
Tyler Chatow6738c362019-02-16 14:12:30 -0800459 argv = FLAGS(sys.argv)
460 sys.exit(main(argv))