blob: 48adbb9b3e1b2a493c727847640b86641236bfd7 [file] [log] [blame]
Campbell Crowley33e0e3d2017-12-27 17:55:40 -08001#!/usr/bin/python
2
3import numpy
4from frc971.control_loops.python import polytope
5import frc971.control_loops.python.drivetrain
6from frc971.control_loops.python import control_loop
7from frc971.control_loops.python import controls
8from frc971.control_loops.python.cim import CIM
9from matplotlib import pylab
10
11import glog
12
13def CoerceGoal(region, K, w, R):
14 """Intersects a line with a region, and finds the closest point to R.
15
16 Finds a point that is closest to R inside the region, and on the line
17 defined by K X = w. If it is not possible to find a point on the line,
18 finds a point that is inside the region and closest to the line. This
19 function assumes that
20
21 Args:
22 region: HPolytope, the valid goal region.
23 K: numpy.matrix (2 x 1), the matrix for the equation [K1, K2] [x1; x2] = w
24 w: float, the offset in the equation above.
25 R: numpy.matrix (2 x 1), the point to be closest to.
26
27 Returns:
28 numpy.matrix (2 x 1), the point.
29 """
30 return DoCoerceGoal(region, K, w, R)[0]
31
32def DoCoerceGoal(region, K, w, R):
33 if region.IsInside(R):
34 return (R, True)
35
36 perpendicular_vector = K.T / numpy.linalg.norm(K)
37 parallel_vector = numpy.matrix([[perpendicular_vector[1, 0]],
38 [-perpendicular_vector[0, 0]]])
39
40 # We want to impose the constraint K * X = w on the polytope H * X <= k.
41 # We do this by breaking X up into parallel and perpendicular components to
42 # the half plane. This gives us the following equation.
43 #
44 # parallel * (parallel.T \dot X) + perpendicular * (perpendicular \dot X)) = X
45 #
46 # Then, substitute this into the polytope.
47 #
48 # H * (parallel * (parallel.T \dot X) + perpendicular * (perpendicular \dot X)) <= k
49 #
50 # Substitute K * X = w
51 #
52 # H * parallel * (parallel.T \dot X) + H * perpendicular * w <= k
53 #
54 # Move all the knowns to the right side.
55 #
56 # H * parallel * ([parallel1 parallel2] * X) <= k - H * perpendicular * w
57 #
58 # Let t = parallel.T \dot X, the component parallel to the surface.
59 #
60 # H * parallel * t <= k - H * perpendicular * w
61 #
62 # This is a polytope which we can solve, and use to figure out the range of X
63 # that we care about!
64
65 t_poly = polytope.HPolytope(
66 region.H * parallel_vector,
67 region.k - region.H * perpendicular_vector * w)
68
69 vertices = t_poly.Vertices()
70
71 if vertices.shape[0]:
72 # The region exists!
73 # Find the closest vertex
74 min_distance = numpy.infty
75 closest_point = None
76 for vertex in vertices:
77 point = parallel_vector * vertex + perpendicular_vector * w
78 length = numpy.linalg.norm(R - point)
79 if length < min_distance:
80 min_distance = length
81 closest_point = point
82
83 return (closest_point, True)
84 else:
85 # Find the vertex of the space that is closest to the line.
86 region_vertices = region.Vertices()
87 min_distance = numpy.infty
88 closest_point = None
89 for vertex in region_vertices:
90 point = vertex.T
91 length = numpy.abs((perpendicular_vector.T * point)[0, 0])
92 if length < min_distance:
93 min_distance = length
94 closest_point = point
95
96 return (closest_point, False)
97
98class VelocityDrivetrainModel(control_loop.ControlLoop):
99 def __init__(self, drivetrain_params, left_low=True, right_low=True,
100 name="VelocityDrivetrainModel"):
101 super(VelocityDrivetrainModel, self).__init__(name)
102 self._drivetrain = frc971.control_loops.python.drivetrain.Drivetrain(
103 left_low=left_low, right_low=right_low,
104 drivetrain_params=drivetrain_params)
105 self.dt = drivetrain_params.dt
106 self.A_continuous = numpy.matrix(
107 [[self._drivetrain.A_continuous[1, 1], self._drivetrain.A_continuous[1, 3]],
108 [self._drivetrain.A_continuous[3, 1], self._drivetrain.A_continuous[3, 3]]])
109
110 self.B_continuous = numpy.matrix(
111 [[self._drivetrain.B_continuous[1, 0], self._drivetrain.B_continuous[1, 1]],
112 [self._drivetrain.B_continuous[3, 0], self._drivetrain.B_continuous[3, 1]]])
113 self.C = numpy.matrix(numpy.eye(2))
114 self.D = numpy.matrix(numpy.zeros((2, 2)))
115
116 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
117 self.B_continuous, self.dt)
118
119 # FF * X = U (steady state)
120 self.FF = self.B.I * (numpy.eye(2) - self.A)
121
122 self.PlaceControllerPoles(drivetrain_params.controller_poles)
Austin Schuh74425152018-12-21 11:37:14 +1100123 # Build a kalman filter for the velocity. We don't care what the gains
124 # are, but the hybrid kalman filter that we want to write to disk to get
125 # access to A_continuous and B_continuous needs this for completeness.
126 self.Q_continuous = numpy.matrix([[(0.5 ** 2.0), 0.0], [0.0, (0.5 ** 2.0)]])
127 self.R_continuous = numpy.matrix([[(0.1 ** 2.0), 0.0], [0.0, (0.1 ** 2.0)]])
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800128 self.PlaceObserverPoles(drivetrain_params.observer_poles)
Austin Schuh74425152018-12-21 11:37:14 +1100129 _, _, self.Q, self.R = controls.kalmd(
130 A_continuous=self.A_continuous, B_continuous=self.B_continuous,
131 Q_continuous=self.Q_continuous, R_continuous=self.R_continuous,
132 dt=self.dt)
133
134 self.KalmanGain, self.P_steady_state = controls.kalman(
135 A=self.A, B=self.B, C=self.C, Q=self.Q, R=self.R)
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800136
137 self.G_high = self._drivetrain.G_high
138 self.G_low = self._drivetrain.G_low
139 self.resistance = self._drivetrain.resistance
140 self.r = self._drivetrain.r
141 self.Kv = self._drivetrain.Kv
142 self.Kt = self._drivetrain.Kt
143
144 self.U_max = self._drivetrain.U_max
145 self.U_min = self._drivetrain.U_min
146
147
148class VelocityDrivetrain(object):
149 HIGH = 'high'
150 LOW = 'low'
151 SHIFTING_UP = 'up'
152 SHIFTING_DOWN = 'down'
153
Austin Schuh74425152018-12-21 11:37:14 +1100154 def __init__(self, drivetrain_params, name='VelocityDrivetrain'):
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800155 self.drivetrain_low_low = VelocityDrivetrainModel(
Austin Schuh74425152018-12-21 11:37:14 +1100156 left_low=True, right_low=True, name=name + 'LowLow',
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800157 drivetrain_params=drivetrain_params)
158 self.drivetrain_low_high = VelocityDrivetrainModel(
Austin Schuh74425152018-12-21 11:37:14 +1100159 left_low=True, right_low=False, name=name + 'LowHigh',
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800160 drivetrain_params=drivetrain_params)
161 self.drivetrain_high_low = VelocityDrivetrainModel(
Austin Schuh74425152018-12-21 11:37:14 +1100162 left_low=False, right_low=True, name = name + 'HighLow',
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800163 drivetrain_params=drivetrain_params)
164 self.drivetrain_high_high = VelocityDrivetrainModel(
Austin Schuh74425152018-12-21 11:37:14 +1100165 left_low=False, right_low=False, name = name + 'HighHigh',
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800166 drivetrain_params=drivetrain_params)
167
168 # X is [lvel, rvel]
169 self.X = numpy.matrix(
170 [[0.0],
171 [0.0]])
172
173 self.U_poly = polytope.HPolytope(
174 numpy.matrix([[1, 0],
175 [-1, 0],
176 [0, 1],
177 [0, -1]]),
178 numpy.matrix([[12],
179 [12],
180 [12],
181 [12]]))
182
183 self.U_max = numpy.matrix(
184 [[12.0],
185 [12.0]])
186 self.U_min = numpy.matrix(
187 [[-12.0000000000],
188 [-12.0000000000]])
189
190 self.dt = 0.00505
191
192 self.R = numpy.matrix(
193 [[0.0],
194 [0.0]])
195
196 self.U_ideal = numpy.matrix(
197 [[0.0],
198 [0.0]])
199
200 # ttrust is the comprimise between having full throttle negative inertia,
201 # and having no throttle negative inertia. A value of 0 is full throttle
202 # inertia. A value of 1 is no throttle negative inertia.
203 self.ttrust = 1.0
204
205 self.left_gear = VelocityDrivetrain.LOW
206 self.right_gear = VelocityDrivetrain.LOW
207 self.left_shifter_position = 0.0
208 self.right_shifter_position = 0.0
209 self.left_cim = CIM()
210 self.right_cim = CIM()
211
212 def IsInGear(self, gear):
213 return gear is VelocityDrivetrain.HIGH or gear is VelocityDrivetrain.LOW
214
215 def MotorRPM(self, shifter_position, velocity):
216 if shifter_position > 0.5:
217 return (velocity / self.CurrentDrivetrain().G_high /
218 self.CurrentDrivetrain().r)
219 else:
220 return (velocity / self.CurrentDrivetrain().G_low /
221 self.CurrentDrivetrain().r)
222
223 def CurrentDrivetrain(self):
224 if self.left_shifter_position > 0.5:
225 if self.right_shifter_position > 0.5:
226 return self.drivetrain_high_high
227 else:
228 return self.drivetrain_high_low
229 else:
230 if self.right_shifter_position > 0.5:
231 return self.drivetrain_low_high
232 else:
233 return self.drivetrain_low_low
234
235 def SimShifter(self, gear, shifter_position):
236 if gear is VelocityDrivetrain.HIGH or gear is VelocityDrivetrain.SHIFTING_UP:
237 shifter_position = min(shifter_position + 0.5, 1.0)
238 else:
239 shifter_position = max(shifter_position - 0.5, 0.0)
240
241 if shifter_position == 1.0:
242 gear = VelocityDrivetrain.HIGH
243 elif shifter_position == 0.0:
244 gear = VelocityDrivetrain.LOW
245
246 return gear, shifter_position
247
248 def ComputeGear(self, wheel_velocity, should_print=False, current_gear=False, gear_name=None):
249 high_omega = (wheel_velocity / self.CurrentDrivetrain().G_high /
250 self.CurrentDrivetrain().r)
251 low_omega = (wheel_velocity / self.CurrentDrivetrain().G_low /
252 self.CurrentDrivetrain().r)
253 #print gear_name, "Motor Energy Difference.", 0.5 * 0.000140032647 * (low_omega * low_omega - high_omega * high_omega), "joules"
254 high_torque = ((12.0 - high_omega / self.CurrentDrivetrain().Kv) *
255 self.CurrentDrivetrain().Kt / self.CurrentDrivetrain().resistance)
256 low_torque = ((12.0 - low_omega / self.CurrentDrivetrain().Kv) *
257 self.CurrentDrivetrain().Kt / self.CurrentDrivetrain().resistance)
258 high_power = high_torque * high_omega
259 low_power = low_torque * low_omega
260 #if should_print:
261 # print gear_name, "High omega", high_omega, "Low omega", low_omega
262 # print gear_name, "High torque", high_torque, "Low torque", low_torque
263 # print gear_name, "High power", high_power, "Low power", low_power
264
265 # Shift algorithm improvements.
266 # TODO(aschuh):
267 # It takes time to shift. Shifting down for 1 cycle doesn't make sense
268 # because you will end up slower than without shifting. Figure out how
269 # to include that info.
270 # If the driver is still in high gear, but isn't asking for the extra power
271 # from low gear, don't shift until he asks for it.
272 goal_gear_is_high = high_power > low_power
273 #goal_gear_is_high = True
274
275 if not self.IsInGear(current_gear):
276 glog.debug('%s Not in gear.', gear_name)
277 return current_gear
278 else:
279 is_high = current_gear is VelocityDrivetrain.HIGH
280 if is_high != goal_gear_is_high:
281 if goal_gear_is_high:
282 glog.debug('%s Shifting up.', gear_name)
283 return VelocityDrivetrain.SHIFTING_UP
284 else:
285 glog.debug('%s Shifting down.', gear_name)
286 return VelocityDrivetrain.SHIFTING_DOWN
287 else:
288 return current_gear
289
290 def FilterVelocity(self, throttle):
291 # Invert the plant to figure out how the velocity filter would have to work
292 # out in order to filter out the forwards negative inertia.
293 # This math assumes that the left and right power and velocity are equal.
294
295 # The throttle filter should filter such that the motor in the highest gear
296 # should be controlling the time constant.
297 # Do this by finding the index of FF that has the lowest value, and computing
298 # the sums using that index.
299 FF_sum = self.CurrentDrivetrain().FF.sum(axis=1)
300 min_FF_sum_index = numpy.argmin(FF_sum)
301 min_FF_sum = FF_sum[min_FF_sum_index, 0]
302 min_K_sum = self.CurrentDrivetrain().K[min_FF_sum_index, :].sum()
303 # Compute the FF sum for high gear.
304 high_min_FF_sum = self.drivetrain_high_high.FF[0, :].sum()
305
306 # U = self.K[0, :].sum() * (R - x_avg) + self.FF[0, :].sum() * R
307 # throttle * 12.0 = (self.K[0, :].sum() + self.FF[0, :].sum()) * R
308 # - self.K[0, :].sum() * x_avg
309
310 # R = (throttle * 12.0 + self.K[0, :].sum() * x_avg) /
311 # (self.K[0, :].sum() + self.FF[0, :].sum())
312
313 # U = (K + FF) * R - K * X
314 # (K + FF) ^-1 * (U + K * X) = R
315
316 # Scale throttle by min_FF_sum / high_min_FF_sum. This will make low gear
317 # have the same velocity goal as high gear, and so that the robot will hold
318 # the same speed for the same throttle for all gears.
319 adjusted_ff_voltage = numpy.clip(throttle * 12.0 * min_FF_sum / high_min_FF_sum, -12.0, 12.0)
320 return ((adjusted_ff_voltage + self.ttrust * min_K_sum * (self.X[0, 0] + self.X[1, 0]) / 2.0)
321 / (self.ttrust * min_K_sum + min_FF_sum))
322
323 def Update(self, throttle, steering):
324 # Shift into the gear which sends the most power to the floor.
325 # This is the same as sending the most torque down to the floor at the
326 # wheel.
327
328 self.left_gear = self.right_gear = True
329 if True:
330 self.left_gear = self.ComputeGear(self.X[0, 0], should_print=True,
331 current_gear=self.left_gear,
332 gear_name="left")
333 self.right_gear = self.ComputeGear(self.X[1, 0], should_print=True,
334 current_gear=self.right_gear,
335 gear_name="right")
336 if self.IsInGear(self.left_gear):
337 self.left_cim.X[0, 0] = self.MotorRPM(self.left_shifter_position, self.X[0, 0])
338
339 if self.IsInGear(self.right_gear):
340 self.right_cim.X[0, 0] = self.MotorRPM(self.right_shifter_position, self.X[0, 0])
341
342 if self.IsInGear(self.left_gear) and self.IsInGear(self.right_gear):
343 # Filter the throttle to provide a nicer response.
344 fvel = self.FilterVelocity(throttle)
345
346 # Constant radius means that angualar_velocity / linear_velocity = constant.
347 # Compute the left and right velocities.
348 steering_velocity = numpy.abs(fvel) * steering
349 left_velocity = fvel - steering_velocity
350 right_velocity = fvel + steering_velocity
351
352 # Write this constraint in the form of K * R = w
353 # angular velocity / linear velocity = constant
354 # (left - right) / (left + right) = constant
355 # left - right = constant * left + constant * right
356
357 # (fvel - steering * numpy.abs(fvel) - fvel - steering * numpy.abs(fvel)) /
358 # (fvel - steering * numpy.abs(fvel) + fvel + steering * numpy.abs(fvel)) =
359 # constant
360 # (- 2 * steering * numpy.abs(fvel)) / (2 * fvel) = constant
361 # (-steering * sign(fvel)) = constant
362 # (-steering * sign(fvel)) * (left + right) = left - right
363 # (steering * sign(fvel) + 1) * left + (steering * sign(fvel) - 1) * right = 0
364
365 equality_k = numpy.matrix(
366 [[1 + steering * numpy.sign(fvel), -(1 - steering * numpy.sign(fvel))]])
367 equality_w = 0.0
368
369 self.R[0, 0] = left_velocity
370 self.R[1, 0] = right_velocity
371
372 # Construct a constraint on R by manipulating the constraint on U
373 # Start out with H * U <= k
374 # U = FF * R + K * (R - X)
375 # H * (FF * R + K * R - K * X) <= k
376 # H * (FF + K) * R <= k + H * K * X
377 R_poly = polytope.HPolytope(
378 self.U_poly.H * (self.CurrentDrivetrain().K + self.CurrentDrivetrain().FF),
379 self.U_poly.k + self.U_poly.H * self.CurrentDrivetrain().K * self.X)
380
381 # Limit R back inside the box.
382 self.boxed_R = CoerceGoal(R_poly, equality_k, equality_w, self.R)
383
384 FF_volts = self.CurrentDrivetrain().FF * self.boxed_R
385 self.U_ideal = self.CurrentDrivetrain().K * (self.boxed_R - self.X) + FF_volts
386 else:
387 glog.debug('Not all in gear')
388 if not self.IsInGear(self.left_gear) and not self.IsInGear(self.right_gear):
389 # TODO(austin): Use battery volts here.
390 R_left = self.MotorRPM(self.left_shifter_position, self.X[0, 0])
391 self.U_ideal[0, 0] = numpy.clip(
392 self.left_cim.K * (R_left - self.left_cim.X) + R_left / self.left_cim.Kv,
393 self.left_cim.U_min, self.left_cim.U_max)
394 self.left_cim.Update(self.U_ideal[0, 0])
395
396 R_right = self.MotorRPM(self.right_shifter_position, self.X[1, 0])
397 self.U_ideal[1, 0] = numpy.clip(
398 self.right_cim.K * (R_right - self.right_cim.X) + R_right / self.right_cim.Kv,
399 self.right_cim.U_min, self.right_cim.U_max)
400 self.right_cim.Update(self.U_ideal[1, 0])
401 else:
402 assert False
403
404 self.U = numpy.clip(self.U_ideal, self.U_min, self.U_max)
405
406 # TODO(austin): Model the robot as not accelerating when you shift...
407 # This hack only works when you shift at the same time.
408 if self.IsInGear(self.left_gear) and self.IsInGear(self.right_gear):
409 self.X = self.CurrentDrivetrain().A * self.X + self.CurrentDrivetrain().B * self.U
410
411 self.left_gear, self.left_shifter_position = self.SimShifter(
412 self.left_gear, self.left_shifter_position)
413 self.right_gear, self.right_shifter_position = self.SimShifter(
414 self.right_gear, self.right_shifter_position)
415
416 glog.debug('U is %s %s', str(self.U[0, 0]), str(self.U[1, 0]))
417 glog.debug('Left shifter %s %d Right shifter %s %d',
418 self.left_gear, self.left_shifter_position,
419 self.right_gear, self.right_shifter_position)
420
Austin Schuh74425152018-12-21 11:37:14 +1100421def WritePolyDrivetrain(drivetrain_files, motor_files, hybrid_files,
422 year_namespace, drivetrain_params,
423 scalar_type='double'):
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800424 vdrivetrain = VelocityDrivetrain(drivetrain_params)
Austin Schuh74425152018-12-21 11:37:14 +1100425 hybrid_vdrivetrain = VelocityDrivetrain(drivetrain_params,
426 name="HybridVelocityDrivetrain")
Austin Schuhbcce26a2018-03-26 23:41:24 -0700427 if isinstance(year_namespace, list):
428 namespaces = year_namespace
429 else:
430 namespaces = [year_namespace, 'control_loops', 'drivetrain']
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800431 dog_loop_writer = control_loop.ControlLoopWriter(
432 "VelocityDrivetrain", [vdrivetrain.drivetrain_low_low,
433 vdrivetrain.drivetrain_low_high,
434 vdrivetrain.drivetrain_high_low,
435 vdrivetrain.drivetrain_high_high],
Austin Schuhbcce26a2018-03-26 23:41:24 -0700436 namespaces=namespaces,
437 scalar_type=scalar_type)
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800438
439 dog_loop_writer.Write(drivetrain_files[0], drivetrain_files[1])
440
Austin Schuh74425152018-12-21 11:37:14 +1100441 hybrid_loop_writer = control_loop.ControlLoopWriter(
442 "HybridVelocityDrivetrain", [hybrid_vdrivetrain.drivetrain_low_low,
443 hybrid_vdrivetrain.drivetrain_low_high,
444 hybrid_vdrivetrain.drivetrain_high_low,
445 hybrid_vdrivetrain.drivetrain_high_high],
446 namespaces=namespaces,
447 scalar_type=scalar_type,
448 plant_type='StateFeedbackHybridPlant',
449 observer_type='HybridKalman')
450
451 hybrid_loop_writer.Write(hybrid_files[0], hybrid_files[1])
452
Austin Schuhbcce26a2018-03-26 23:41:24 -0700453 cim_writer = control_loop.ControlLoopWriter("CIM", [CIM()], scalar_type=scalar_type)
Campbell Crowley33e0e3d2017-12-27 17:55:40 -0800454
455 cim_writer.Write(motor_files[0], motor_files[1])
456
457def PlotPolyDrivetrainMotions(drivetrain_params):
458 vdrivetrain = VelocityDrivetrain(drivetrain_params)
459 vl_plot = []
460 vr_plot = []
461 ul_plot = []
462 ur_plot = []
463 radius_plot = []
464 t_plot = []
465 left_gear_plot = []
466 right_gear_plot = []
467 vdrivetrain.left_shifter_position = 0.0
468 vdrivetrain.right_shifter_position = 0.0
469 vdrivetrain.left_gear = VelocityDrivetrain.LOW
470 vdrivetrain.right_gear = VelocityDrivetrain.LOW
471
472 glog.debug('K is %s', str(vdrivetrain.CurrentDrivetrain().K))
473
474 if vdrivetrain.left_gear is VelocityDrivetrain.HIGH:
475 glog.debug('Left is high')
476 else:
477 glog.debug('Left is low')
478 if vdrivetrain.right_gear is VelocityDrivetrain.HIGH:
479 glog.debug('Right is high')
480 else:
481 glog.debug('Right is low')
482
483 for t in numpy.arange(0, 1.7, vdrivetrain.dt):
484 if t < 0.5:
485 vdrivetrain.Update(throttle=0.00, steering=1.0)
486 elif t < 1.2:
487 vdrivetrain.Update(throttle=0.5, steering=1.0)
488 else:
489 vdrivetrain.Update(throttle=0.00, steering=1.0)
490 t_plot.append(t)
491 vl_plot.append(vdrivetrain.X[0, 0])
492 vr_plot.append(vdrivetrain.X[1, 0])
493 ul_plot.append(vdrivetrain.U[0, 0])
494 ur_plot.append(vdrivetrain.U[1, 0])
495 left_gear_plot.append((vdrivetrain.left_gear is VelocityDrivetrain.HIGH) * 2.0 - 10.0)
496 right_gear_plot.append((vdrivetrain.right_gear is VelocityDrivetrain.HIGH) * 2.0 - 10.0)
497
498 fwd_velocity = (vdrivetrain.X[1, 0] + vdrivetrain.X[0, 0]) / 2
499 turn_velocity = (vdrivetrain.X[1, 0] - vdrivetrain.X[0, 0])
500 if abs(fwd_velocity) < 0.0000001:
501 radius_plot.append(turn_velocity)
502 else:
503 radius_plot.append(turn_velocity / fwd_velocity)
504
505 # TODO(austin):
506 # Shifting compensation.
507
508 # Tighten the turn.
509 # Closed loop drive.
510
511 pylab.plot(t_plot, vl_plot, label='left velocity')
512 pylab.plot(t_plot, vr_plot, label='right velocity')
513 pylab.plot(t_plot, ul_plot, label='left voltage')
514 pylab.plot(t_plot, ur_plot, label='right voltage')
515 pylab.plot(t_plot, radius_plot, label='radius')
516 pylab.plot(t_plot, left_gear_plot, label='left gear high')
517 pylab.plot(t_plot, right_gear_plot, label='right gear high')
518 pylab.legend()
519 pylab.show()