blob: a825ff07f6e876731fd73c1ca09d379fb721dc9e [file] [log] [blame]
Austin Schuh48d60c12017-02-04 21:58:58 -08001#!/usr/bin/python
2
3from frc971.control_loops.python import control_loop
4from frc971.control_loops.python import controls
5import numpy
Austin Schuh6c20f202017-02-18 22:31:44 -08006import scipy
Austin Schuh48d60c12017-02-04 21:58:58 -08007import sys
8from matplotlib import pylab
9
10import gflags
11import glog
12
13FLAGS = gflags.FLAGS
14
15gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
16
Austin Schuh3ad5ed82017-02-25 21:36:19 -080017
18def PlotDiff(list1, list2, time):
Tyler Chatow6738c362019-02-16 14:12:30 -080019 pylab.subplot(1, 1, 1)
20 pylab.plot(time, numpy.subtract(list1, list2), label='diff')
21 pylab.legend()
22
Austin Schuh3ad5ed82017-02-25 21:36:19 -080023
Austin Schuh3ad5ed82017-02-25 21:36:19 -080024class VelocityShooter(control_loop.HybridControlLoop):
Austin Schuh48d60c12017-02-04 21:58:58 -080025
Tyler Chatow6738c362019-02-16 14:12:30 -080026 def __init__(self, name='VelocityShooter'):
27 super(VelocityShooter, self).__init__(name)
28 # Number of motors
29 self.num_motors = 2.0
30 # Stall Torque in N m
31 self.stall_torque = 0.71 * self.num_motors
32 # Stall Current in Amps
33 self.stall_current = 134.0 * self.num_motors
34 # Free Speed in RPM
35 self.free_speed_rpm = 18730.0
36 # Free Speed in rotations/second.
37 self.free_speed = self.free_speed_rpm / 60.0
38 # Free Current in Amps
39 self.free_current = 0.7 * self.num_motors
40 # Moment of inertia of the shooter wheel in kg m^2
41 # 1400.6 grams/cm^2
42 # 1.407 *1e-4 kg m^2
43 self.J = 0.00120
44 # Resistance of the motor, divided by 2 to account for the 2 motors
45 self.R = 12.0 / self.stall_current
46 # Motor velocity constant
47 self.Kv = ((self.free_speed * 2.0 * numpy.pi) /
48 (12.0 - self.R * self.free_current))
49 # Torque constant
50 self.Kt = self.stall_torque / self.stall_current
51 # Gear ratio
52 self.G = 12.0 / 36.0
53 # Control loop time step
54 self.dt = 0.00505
Austin Schuh48d60c12017-02-04 21:58:58 -080055
Tyler Chatow6738c362019-02-16 14:12:30 -080056 # State feedback matrices
57 # [angular velocity]
58 self.A_continuous = numpy.matrix(
59 [[-self.Kt / (self.Kv * self.J * self.G * self.G * self.R)]])
60 self.B_continuous = numpy.matrix(
61 [[self.Kt / (self.J * self.G * self.R)]])
62 self.C = numpy.matrix([[1]])
63 self.D = numpy.matrix([[0]])
Austin Schuh48d60c12017-02-04 21:58:58 -080064
Tyler Chatow6738c362019-02-16 14:12:30 -080065 # The states are [unfiltered_velocity]
66 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
67 self.B_continuous, self.dt)
Austin Schuh48d60c12017-02-04 21:58:58 -080068
Tyler Chatow6738c362019-02-16 14:12:30 -080069 self.PlaceControllerPoles([.75])
Austin Schuhcd3237a2017-02-18 14:19:26 -080070
Tyler Chatow6738c362019-02-16 14:12:30 -080071 glog.debug('K %s', repr(self.K))
72 glog.debug('System poles are %s',
73 repr(numpy.linalg.eig(self.A_continuous)[0]))
74 glog.debug('Poles are %s',
75 repr(numpy.linalg.eig(self.A - self.B * self.K)[0]))
Austin Schuh48d60c12017-02-04 21:58:58 -080076
Tyler Chatow6738c362019-02-16 14:12:30 -080077 self.PlaceObserverPoles([0.3])
Austin Schuh48d60c12017-02-04 21:58:58 -080078
Tyler Chatow6738c362019-02-16 14:12:30 -080079 self.U_max = numpy.matrix([[12.0]])
80 self.U_min = numpy.matrix([[-12.0]])
Austin Schuh48d60c12017-02-04 21:58:58 -080081
Tyler Chatow6738c362019-02-16 14:12:30 -080082 qff_vel = 8.0
83 self.Qff = numpy.matrix([[1.0 / (qff_vel**2.0)]])
84
85 self.Kff = controls.TwoStateFeedForwards(self.B, self.Qff)
86 self.InitializeState()
87
Austin Schuh48d60c12017-02-04 21:58:58 -080088
Austin Schuhc66b6fc2017-03-25 19:56:59 -070089class SecondOrderVelocityShooter(VelocityShooter):
Austin Schuh48d60c12017-02-04 21:58:58 -080090
Tyler Chatow6738c362019-02-16 14:12:30 -080091 def __init__(self, name='SecondOrderVelocityShooter'):
92 super(SecondOrderVelocityShooter, self).__init__(name)
Austin Schuhc66b6fc2017-03-25 19:56:59 -070093
Tyler Chatow6738c362019-02-16 14:12:30 -080094 self.A_continuous_unaugmented = self.A_continuous
95 self.B_continuous_unaugmented = self.B_continuous
Austin Schuhc66b6fc2017-03-25 19:56:59 -070096
Tyler Chatow6738c362019-02-16 14:12:30 -080097 self.A_continuous = numpy.matrix(numpy.zeros((2, 2)))
98 self.A_continuous[0:1, 0:1] = self.A_continuous_unaugmented
99 self.A_continuous[1, 0] = 175.0
100 self.A_continuous[1, 1] = -self.A_continuous[1, 0]
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700101
Tyler Chatow6738c362019-02-16 14:12:30 -0800102 self.B_continuous = numpy.matrix(numpy.zeros((2, 1)))
103 self.B_continuous[0:1, 0] = self.B_continuous_unaugmented
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700104
Tyler Chatow6738c362019-02-16 14:12:30 -0800105 self.C = numpy.matrix([[0, 1]])
106 self.D = numpy.matrix([[0]])
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700107
Tyler Chatow6738c362019-02-16 14:12:30 -0800108 # The states are [unfiltered_velocity, velocity]
109 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
110 self.B_continuous, self.dt)
Austin Schuheb5c22e2017-04-09 18:30:28 -0700111
Tyler Chatow6738c362019-02-16 14:12:30 -0800112 self.PlaceControllerPoles([.70, 0.60])
Austin Schuheb5c22e2017-04-09 18:30:28 -0700113
Tyler Chatow6738c362019-02-16 14:12:30 -0800114 q_vel = 40.0
115 q_filteredvel = 30.0
116 self.Q = numpy.matrix([[(1.0 / (q_vel**2.0)), 0.0],
117 [0.0, (1.0 / (q_filteredvel**2.0))]])
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700118
Tyler Chatow6738c362019-02-16 14:12:30 -0800119 self.R = numpy.matrix([[(1.0 / (3.0**2.0))]])
120 self.K = controls.dlqr(self.A, self.B, self.Q, self.R)
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700121
Tyler Chatow6738c362019-02-16 14:12:30 -0800122 glog.debug('K %s', repr(self.K))
123 glog.debug('System poles are %s',
124 repr(numpy.linalg.eig(self.A_continuous)[0]))
125 glog.debug('Poles are %s',
126 repr(numpy.linalg.eig(self.A - self.B * self.K)[0]))
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700127
Tyler Chatow6738c362019-02-16 14:12:30 -0800128 self.PlaceObserverPoles([0.3, 0.3])
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700129
Tyler Chatow6738c362019-02-16 14:12:30 -0800130 self.U_max = numpy.matrix([[12.0]])
131 self.U_min = numpy.matrix([[-12.0]])
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700132
Tyler Chatow6738c362019-02-16 14:12:30 -0800133 qff_vel = 8.0
134 self.Qff = numpy.matrix([[1.0 / (qff_vel**2.0), 0.0],
135 [0.0, 1.0 / (qff_vel**2.0)]])
136
137 self.Kff = controls.TwoStateFeedForwards(self.B, self.Qff)
138 self.InitializeState()
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700139
140
141class Shooter(SecondOrderVelocityShooter):
Austin Schuh48d60c12017-02-04 21:58:58 -0800142
Tyler Chatow6738c362019-02-16 14:12:30 -0800143 def __init__(self, name='Shooter'):
144 super(Shooter, self).__init__(name)
Austin Schuh48d60c12017-02-04 21:58:58 -0800145
Tyler Chatow6738c362019-02-16 14:12:30 -0800146 self.A_continuous_unaugmented = self.A_continuous
147 self.B_continuous_unaugmented = self.B_continuous
Austin Schuh48d60c12017-02-04 21:58:58 -0800148
Tyler Chatow6738c362019-02-16 14:12:30 -0800149 self.A_continuous = numpy.matrix(numpy.zeros((3, 3)))
150 self.A_continuous[1:3, 1:3] = self.A_continuous_unaugmented
151 self.A_continuous[0, 2] = 1
Austin Schuh48d60c12017-02-04 21:58:58 -0800152
Tyler Chatow6738c362019-02-16 14:12:30 -0800153 self.B_continuous = numpy.matrix(numpy.zeros((3, 1)))
154 self.B_continuous[1:3, 0] = self.B_continuous_unaugmented
Austin Schuh48d60c12017-02-04 21:58:58 -0800155
Tyler Chatow6738c362019-02-16 14:12:30 -0800156 # State feedback matrices
157 # [position, unfiltered_velocity, angular velocity]
158 self.C = numpy.matrix([[1, 0, 0]])
159 self.D = numpy.matrix([[0]])
Austin Schuh48d60c12017-02-04 21:58:58 -0800160
Tyler Chatow6738c362019-02-16 14:12:30 -0800161 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
162 self.B_continuous, self.dt)
163 glog.debug(repr(self.A_continuous))
164 glog.debug(repr(self.B_continuous))
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700165
Tyler Chatow6738c362019-02-16 14:12:30 -0800166 observeability = controls.ctrb(self.A.T, self.C.T)
167 glog.debug('Rank of augmented observability matrix. %d',
168 numpy.linalg.matrix_rank(observeability))
Austin Schuhc66b6fc2017-03-25 19:56:59 -0700169
Tyler Chatow6738c362019-02-16 14:12:30 -0800170 self.PlaceObserverPoles([0.9, 0.8, 0.7])
Austin Schuh48d60c12017-02-04 21:58:58 -0800171
Tyler Chatow6738c362019-02-16 14:12:30 -0800172 self.K_unaugmented = self.K
173 self.K = numpy.matrix(numpy.zeros((1, 3)))
174 self.K[0, 1:3] = self.K_unaugmented
175 self.Kff_unaugmented = self.Kff
176 self.Kff = numpy.matrix(numpy.zeros((1, 3)))
177 self.Kff[0, 1:3] = self.Kff_unaugmented
Austin Schuh48d60c12017-02-04 21:58:58 -0800178
Tyler Chatow6738c362019-02-16 14:12:30 -0800179 self.InitializeState()
Austin Schuh48d60c12017-02-04 21:58:58 -0800180
181
182class IntegralShooter(Shooter):
Austin Schuh48d60c12017-02-04 21:58:58 -0800183
Tyler Chatow6738c362019-02-16 14:12:30 -0800184 def __init__(self, name='IntegralShooter'):
185 super(IntegralShooter, self).__init__(name=name)
Austin Schuh48d60c12017-02-04 21:58:58 -0800186
Tyler Chatow6738c362019-02-16 14:12:30 -0800187 self.A_continuous_unaugmented = self.A_continuous
188 self.B_continuous_unaugmented = self.B_continuous
Austin Schuh48d60c12017-02-04 21:58:58 -0800189
Tyler Chatow6738c362019-02-16 14:12:30 -0800190 self.A_continuous = numpy.matrix(numpy.zeros((4, 4)))
191 self.A_continuous[0:3, 0:3] = self.A_continuous_unaugmented
192 self.A_continuous[0:3, 3] = self.B_continuous_unaugmented
Austin Schuh48d60c12017-02-04 21:58:58 -0800193
Tyler Chatow6738c362019-02-16 14:12:30 -0800194 self.B_continuous = numpy.matrix(numpy.zeros((4, 1)))
195 self.B_continuous[0:3, 0] = self.B_continuous_unaugmented
Austin Schuh48d60c12017-02-04 21:58:58 -0800196
Tyler Chatow6738c362019-02-16 14:12:30 -0800197 self.C_unaugmented = self.C
198 self.C = numpy.matrix(numpy.zeros((1, 4)))
199 self.C[0:1, 0:3] = self.C_unaugmented
Austin Schuh48d60c12017-02-04 21:58:58 -0800200
Tyler Chatow6738c362019-02-16 14:12:30 -0800201 # The states are [position, unfiltered_velocity, velocity, torque_error]
202 self.A, self.B = self.ContinuousToDiscrete(self.A_continuous,
203 self.B_continuous, self.dt)
Austin Schuh6c20f202017-02-18 22:31:44 -0800204
Tyler Chatow6738c362019-02-16 14:12:30 -0800205 glog.debug('A: \n%s', repr(self.A_continuous))
206 glog.debug('eig(A): \n%s', repr(scipy.linalg.eig(self.A_continuous)))
207 glog.debug('schur(A): \n%s', repr(
208 scipy.linalg.schur(self.A_continuous)))
209 glog.debug('A_dt(A): \n%s', repr(self.A))
Austin Schuh48d60c12017-02-04 21:58:58 -0800210
Tyler Chatow6738c362019-02-16 14:12:30 -0800211 q_pos = 0.01
212 q_vel = 5.0
213 q_velfilt = 1.5
214 q_voltage = 2.0
215 self.Q_continuous = numpy.matrix([[(q_pos**2.0), 0.0, 0.0, 0.0],
216 [0.0, (q_vel**2.0), 0.0, 0.0],
217 [0.0, 0.0, (q_velfilt**2.0), 0.0],
218 [0.0, 0.0, 0.0, (q_voltage**2.0)]])
Austin Schuh48d60c12017-02-04 21:58:58 -0800219
Tyler Chatow6738c362019-02-16 14:12:30 -0800220 r_pos = 0.0003
221 self.R_continuous = numpy.matrix([[(r_pos**2.0)]])
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800222
Tyler Chatow6738c362019-02-16 14:12:30 -0800223 _, _, self.Q, self.R = controls.kalmd(
224 A_continuous=self.A_continuous,
225 B_continuous=self.B_continuous,
226 Q_continuous=self.Q_continuous,
227 R_continuous=self.R_continuous,
228 dt=self.dt)
Austin Schuh48d60c12017-02-04 21:58:58 -0800229
Tyler Chatow6738c362019-02-16 14:12:30 -0800230 self.KalmanGain, self.P_steady_state = controls.kalman(
231 A=self.A, B=self.B, C=self.C, Q=self.Q, R=self.R)
232 self.L = self.A * self.KalmanGain
Austin Schuh48d60c12017-02-04 21:58:58 -0800233
Tyler Chatow6738c362019-02-16 14:12:30 -0800234 self.K_unaugmented = self.K
235 self.K = numpy.matrix(numpy.zeros((1, 4)))
236 self.K[0, 0:3] = self.K_unaugmented
237 self.K[0, 3] = 1
238 self.Kff_unaugmented = self.Kff
239 self.Kff = numpy.matrix(numpy.zeros((1, 4)))
240 self.Kff[0, 0:3] = self.Kff_unaugmented
241
242 self.InitializeState()
Austin Schuh48d60c12017-02-04 21:58:58 -0800243
244
245class ScenarioPlotter(object):
Austin Schuh48d60c12017-02-04 21:58:58 -0800246
Tyler Chatow6738c362019-02-16 14:12:30 -0800247 def __init__(self):
248 # Various lists for graphing things.
249 self.t = []
250 self.x = []
251 self.v = []
252 self.a = []
253 self.x_hat = []
254 self.u = []
255 self.offset = []
256 self.diff = []
Austin Schuh48d60c12017-02-04 21:58:58 -0800257
Tyler Chatow6738c362019-02-16 14:12:30 -0800258 def run_test(self,
259 shooter,
260 goal,
261 iterations=200,
262 controller_shooter=None,
263 observer_shooter=None,
264 hybrid_obs=False):
265 """Runs the shooter plant with an initial condition and goal.
Austin Schuh48d60c12017-02-04 21:58:58 -0800266
Tyler Chatow6738c362019-02-16 14:12:30 -0800267 Args:
268 shooter: Shooter object to use.
269 goal: goal state.
270 iterations: Number of timesteps to run the model for.
271 controller_shooter: Shooter object to get K from, or None if we should
272 use shooter.
273 observer_shooter: Shooter object to use for the observer, or None if we
274 should use the actual state.
275 """
Austin Schuh48d60c12017-02-04 21:58:58 -0800276
Tyler Chatow6738c362019-02-16 14:12:30 -0800277 if controller_shooter is None:
278 controller_shooter = shooter
Austin Schuh48d60c12017-02-04 21:58:58 -0800279
Tyler Chatow6738c362019-02-16 14:12:30 -0800280 vbat = 12.0
Austin Schuh48d60c12017-02-04 21:58:58 -0800281
Tyler Chatow6738c362019-02-16 14:12:30 -0800282 if self.t:
283 initial_t = self.t[-1] + shooter.dt
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800284 else:
Tyler Chatow6738c362019-02-16 14:12:30 -0800285 initial_t = 0
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800286
Tyler Chatow6738c362019-02-16 14:12:30 -0800287 last_U = numpy.matrix([[0.0]])
288 for i in xrange(iterations):
289 X_hat = shooter.X
Austin Schuh48d60c12017-02-04 21:58:58 -0800290
Tyler Chatow6738c362019-02-16 14:12:30 -0800291 if observer_shooter is not None:
292 X_hat = observer_shooter.X_hat
293 self.x_hat.append(observer_shooter.X_hat[2, 0])
Austin Schuh48d60c12017-02-04 21:58:58 -0800294
Tyler Chatow6738c362019-02-16 14:12:30 -0800295 ff_U = controller_shooter.Kff * (goal - observer_shooter.A * goal)
Austin Schuh48d60c12017-02-04 21:58:58 -0800296
Tyler Chatow6738c362019-02-16 14:12:30 -0800297 U = controller_shooter.K * (goal - X_hat) + ff_U
298 U[0, 0] = numpy.clip(U[0, 0], -vbat, vbat)
299 self.x.append(shooter.X[0, 0])
Austin Schuh48d60c12017-02-04 21:58:58 -0800300
Tyler Chatow6738c362019-02-16 14:12:30 -0800301 self.diff.append(shooter.X[2, 0] - observer_shooter.X_hat[2, 0])
Austin Schuh48d60c12017-02-04 21:58:58 -0800302
Tyler Chatow6738c362019-02-16 14:12:30 -0800303 if self.v:
304 last_v = self.v[-1]
305 else:
306 last_v = 0
307
308 self.v.append(shooter.X[2, 0])
309 self.a.append((self.v[-1] - last_v) / shooter.dt)
310
311 if observer_shooter is not None:
312 if i != 0:
313 observer_shooter.Y = shooter.Y
314 observer_shooter.CorrectObserver(U)
315 self.offset.append(observer_shooter.X_hat[3, 0])
316
317 applied_U = last_U.copy()
318 if i > 60:
319 applied_U += 2
320 shooter.Update(applied_U)
321
322 if observer_shooter is not None:
323 if hybrid_obs:
324 observer_shooter.PredictHybridObserver(last_U, shooter.dt)
325 else:
326 observer_shooter.PredictObserver(last_U)
327 last_U = U.copy()
328
329 self.t.append(initial_t + i * shooter.dt)
330 self.u.append(U[0, 0])
331
332 def Plot(self):
333 pylab.figure()
334 pylab.subplot(3, 1, 1)
335 pylab.plot(self.t, self.v, label='x')
336 pylab.plot(self.t, self.x_hat, label='x_hat')
337 pylab.legend()
338
339 pylab.subplot(3, 1, 2)
340 pylab.plot(self.t, self.u, label='u')
341 pylab.plot(self.t, self.offset, label='voltage_offset')
342 pylab.legend()
343
344 pylab.subplot(3, 1, 3)
345 pylab.plot(self.t, self.a, label='a')
346 pylab.legend()
347
348 pylab.draw()
Austin Schuh48d60c12017-02-04 21:58:58 -0800349
350
351def main(argv):
Tyler Chatow6738c362019-02-16 14:12:30 -0800352 scenario_plotter = ScenarioPlotter()
Austin Schuh48d60c12017-02-04 21:58:58 -0800353
Tyler Chatow6738c362019-02-16 14:12:30 -0800354 if FLAGS.plot:
355 iterations = 200
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800356
Tyler Chatow6738c362019-02-16 14:12:30 -0800357 initial_X = numpy.matrix([[0.0], [0.0], [0.0]])
358 R = numpy.matrix([[0.0], [100.0], [100.0], [0.0]])
Austin Schuh48d60c12017-02-04 21:58:58 -0800359
Tyler Chatow6738c362019-02-16 14:12:30 -0800360 scenario_plotter_int = ScenarioPlotter()
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800361
Tyler Chatow6738c362019-02-16 14:12:30 -0800362 shooter = Shooter()
363 shooter_controller = IntegralShooter()
364 observer_shooter_hybrid = IntegralShooter()
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800365
Tyler Chatow6738c362019-02-16 14:12:30 -0800366 scenario_plotter_int.run_test(
367 shooter,
368 goal=R,
369 controller_shooter=shooter_controller,
370 observer_shooter=observer_shooter_hybrid,
371 iterations=iterations,
372 hybrid_obs=True)
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800373
Tyler Chatow6738c362019-02-16 14:12:30 -0800374 scenario_plotter_int.Plot()
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800375
Tyler Chatow6738c362019-02-16 14:12:30 -0800376 pylab.show()
Austin Schuh3ad5ed82017-02-25 21:36:19 -0800377
Tyler Chatow6738c362019-02-16 14:12:30 -0800378 if len(argv) != 5:
379 glog.fatal('Expected .h file name and .cc file name')
380 else:
381 namespaces = ['y2017', 'control_loops', 'superstructure', 'shooter']
382 shooter = Shooter('Shooter')
383 loop_writer = control_loop.ControlLoopWriter(
384 'Shooter', [shooter], namespaces=namespaces)
385 loop_writer.AddConstant(
386 control_loop.Constant('kFreeSpeed', '%f', shooter.free_speed))
387 loop_writer.AddConstant(
388 control_loop.Constant('kOutputRatio', '%f', shooter.G))
389 loop_writer.Write(argv[1], argv[2])
Austin Schuh48d60c12017-02-04 21:58:58 -0800390
Tyler Chatow6738c362019-02-16 14:12:30 -0800391 integral_shooter = IntegralShooter('IntegralShooter')
392 integral_loop_writer = control_loop.ControlLoopWriter(
393 'IntegralShooter', [integral_shooter],
394 namespaces=namespaces,
395 plant_type='StateFeedbackHybridPlant',
396 observer_type='HybridKalman')
397 integral_loop_writer.Write(argv[3], argv[4])
Austin Schuh48d60c12017-02-04 21:58:58 -0800398
399
400if __name__ == '__main__':
Tyler Chatow6738c362019-02-16 14:12:30 -0800401 argv = FLAGS(sys.argv)
402 glog.init()
403 sys.exit(main(argv))