Autogen rule written for 'claw' module.

Change-Id: Iad44bde1de4f3503f4cf01739577c6ab55da8bf0
diff --git a/y2015/control_loops/claw/BUILD b/y2015/control_loops/claw/BUILD
index e671004..200b422 100644
--- a/y2015/control_loops/claw/BUILD
+++ b/y2015/control_loops/claw/BUILD
@@ -25,17 +25,41 @@
   ],
 )
 
+genrule(
+  name = 'genrule_claw',
+  visibility = ['//visibility:private'],
+  cmd = '$(location //y2015/control_loops/python:claw) $(OUTS)',
+  tools = [
+    '//y2015/control_loops/python:claw',
+  ],
+  outs = [
+    'claw_motor_plant.h',
+    'claw_motor_plant.cc',
+  ],
+)
+
 cc_library(
-  name = 'claw_lib',
+  name = 'claw_plants',
   srcs = [
-    'claw.cc',
     'claw_motor_plant.cc',
   ],
   hdrs = [
-    'claw.h',
     'claw_motor_plant.h',
   ],
   deps = [
+    '//frc971/control_loops:state_feedback_loop',
+  ],
+)
+
+cc_library(
+  name = 'claw_lib',
+  hdrs = [
+    'claw.h',
+  ],
+  srcs = [
+    'claw.cc',
+  ],
+  deps = [
     ':claw_queue',
     '//aos/common/controls:control_loop',
     '//aos/common:time',
@@ -43,6 +67,7 @@
     '//y2015:constants',
     '//frc971/control_loops:state_feedback_loop',
     '//frc971/zeroing:zeroing',
+    ':claw_plants',
   ],
 )
 
diff --git a/y2015/control_loops/claw/claw.cc b/y2015/control_loops/claw/claw.cc
index e487024..e6ab9e7 100644
--- a/y2015/control_loops/claw/claw.cc
+++ b/y2015/control_loops/claw/claw.cc
@@ -33,7 +33,8 @@
 Claw::Claw(control_loops::ClawQueue *claw)
     : aos::controls::ControlLoop<control_loops::ClawQueue>(claw),
       last_piston_edge_(Time::Now()),
-      claw_loop_(new ClawCappedStateFeedbackLoop(MakeClawLoop())),
+      claw_loop_(new ClawCappedStateFeedbackLoop(
+          ::y2015::control_loops::claw::MakeClawLoop())),
       claw_estimator_(constants::GetValues().claw.zeroing),
       profile_(::aos::controls::kLoopFrequency) {}
 
diff --git a/y2015/control_loops/claw/claw_lib_test.cc b/y2015/control_loops/claw/claw_lib_test.cc
index 10fcc07..6b3ad87 100644
--- a/y2015/control_loops/claw/claw_lib_test.cc
+++ b/y2015/control_loops/claw/claw_lib_test.cc
@@ -25,7 +25,8 @@
  public:
   // Constructs a claw simulation.
   ClawSimulation()
-      : claw_plant_(new StateFeedbackPlant<2, 1, 1>(MakeClawPlant())),
+      : claw_plant_(new StateFeedbackPlant<2, 1, 1>(
+            y2015::control_loops::claw::MakeClawPlant())),
         pot_and_encoder_(constants::GetValues().claw.zeroing.index_difference),
         claw_queue_(".frc971.control_loops.claw_queue", 0x9d7452fb,
                     ".frc971.control_loops.claw_queue.goal",
diff --git a/y2015/control_loops/claw/claw_motor_plant.cc b/y2015/control_loops/claw/claw_motor_plant.cc
deleted file mode 100644
index 5f5c206..0000000
--- a/y2015/control_loops/claw/claw_motor_plant.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "y2015/control_loops/claw/claw_motor_plant.h"
-
-#include <vector>
-
-#include "frc971/control_loops/state_feedback_loop.h"
-
-namespace frc971 {
-namespace control_loops {
-
-StateFeedbackPlantCoefficients<2, 1, 1> MakeClawPlantCoefficients() {
-  Eigen::Matrix<double, 2, 2> A;
-  A << 1.0, 0.00482455476758, 0.0, 0.930652495326;
-  Eigen::Matrix<double, 2, 1> B;
-  B << 6.97110924671e-05, 0.0275544125308;
-  Eigen::Matrix<double, 1, 2> C;
-  C << 1, 0;
-  Eigen::Matrix<double, 1, 1> D;
-  D << 0;
-  Eigen::Matrix<double, 1, 1> U_max;
-  U_max << 12.0;
-  Eigen::Matrix<double, 1, 1> U_min;
-  U_min << -12.0;
-  return StateFeedbackPlantCoefficients<2, 1, 1>(A, B, C, D, U_max, U_min);
-}
-
-StateFeedbackController<2, 1, 1> MakeClawController() {
-  Eigen::Matrix<double, 2, 1> L;
-  L << 0.998251427366, 26.9874526231;
-  Eigen::Matrix<double, 1, 2> K;
-  K << 74.4310031124, 4.72251126222;
-  Eigen::Matrix<double, 2, 2> A_inv;
-  A_inv << 1.0, -0.00518405612386, 0.0, 1.07451492907;
-  return StateFeedbackController<2, 1, 1>(L, K, A_inv, MakeClawPlantCoefficients());
-}
-
-StateFeedbackPlant<2, 1, 1> MakeClawPlant() {
-  ::std::vector< ::std::unique_ptr<StateFeedbackPlantCoefficients<2, 1, 1>>> plants(1);
-  plants[0] = ::std::unique_ptr<StateFeedbackPlantCoefficients<2, 1, 1>>(new StateFeedbackPlantCoefficients<2, 1, 1>(MakeClawPlantCoefficients()));
-  return StateFeedbackPlant<2, 1, 1>(&plants);
-}
-
-StateFeedbackLoop<2, 1, 1> MakeClawLoop() {
-  ::std::vector< ::std::unique_ptr<StateFeedbackController<2, 1, 1>>> controllers(1);
-  controllers[0] = ::std::unique_ptr<StateFeedbackController<2, 1, 1>>(new StateFeedbackController<2, 1, 1>(MakeClawController()));
-  return StateFeedbackLoop<2, 1, 1>(&controllers);
-}
-
-}  // namespace control_loops
-}  // namespace frc971
diff --git a/y2015/control_loops/claw/claw_motor_plant.h b/y2015/control_loops/claw/claw_motor_plant.h
deleted file mode 100644
index 6cb9cdb..0000000
--- a/y2015/control_loops/claw/claw_motor_plant.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef Y2015_CONTROL_LOOPS_CLAW_CLAW_MOTOR_PLANT_H_
-#define Y2015_CONTROL_LOOPS_CLAW_CLAW_MOTOR_PLANT_H_
-
-#include "frc971/control_loops/state_feedback_loop.h"
-
-namespace frc971 {
-namespace control_loops {
-
-StateFeedbackPlantCoefficients<2, 1, 1> MakeClawPlantCoefficients();
-
-StateFeedbackController<2, 1, 1> MakeClawController();
-
-StateFeedbackPlant<2, 1, 1> MakeClawPlant();
-
-StateFeedbackLoop<2, 1, 1> MakeClawLoop();
-
-}  // namespace control_loops
-}  // namespace frc971
-
-#endif  // Y2015_CONTROL_LOOPS_CLAW_CLAW_MOTOR_PLANT_H_
diff --git a/y2015/control_loops/python/BUILD b/y2015/control_loops/python/BUILD
new file mode 100644
index 0000000..ab66d3e
--- /dev/null
+++ b/y2015/control_loops/python/BUILD
@@ -0,0 +1,25 @@
+package(default_visibility = ['//y2015:__subpackages__'])
+
+py_binary(
+  name = 'arm',
+  srcs = [
+    'arm.py',
+  ],
+  deps = [
+    '//external:python-gflags',
+    '//external:python-glog',
+    '//frc971/control_loops/python:controls',
+  ],
+)
+
+py_binary(
+  name = 'claw',
+  srcs = [
+    'claw.py',
+  ],
+  deps = [
+    '//external:python-gflags',
+    '//external:python-glog',
+    '//frc971/control_loops/python:controls',
+  ],
+)
diff --git a/y2015/control_loops/python/claw.py b/y2015/control_loops/python/claw.py
index cdb76ae..86a261d 100755
--- a/y2015/control_loops/python/claw.py
+++ b/y2015/control_loops/python/claw.py
@@ -1,13 +1,21 @@
 #!/usr/bin/python
 
-import control_loop
-import controls
-import polytope
-import polydrivetrain
+from frc971.control_loops.python import control_loop
+from frc971.control_loops.python import controls
+from frc971.control_loops.python import polytope
 import numpy
 import sys
 import matplotlib
 from matplotlib import pylab
+import glog
+import gflags
+
+FLAGS = gflags.FLAGS
+
+try:
+  gflags.DEFINE_bool('plot', False, 'If true, plot the loop response.')
+except gflags.DuplicateFlagError:
+  pass
 
 class Claw(control_loop.ControlLoop):
   def __init__(self, name="Claw", mass=None):
@@ -110,7 +118,7 @@
 
 
 def run_test(claw, initial_X, goal, max_separation_error=0.01,
-             show_graph=True, iterations=200, controller_claw=None,
+             show_graph=False, iterations=200, controller_claw=None,
              observer_claw=None):
   """Runs the claw plant with an initial condition and goal.
 
@@ -198,14 +206,13 @@
 
   # Write the generated constants out to a file.
   if len(argv) != 3:
-    print "Expected .h file name and .cc file name for the claw."
+    glog.fatal('Expected .h and .cc filename for claw.')
   else:
-    claw = Claw("Claw")
-    loop_writer = control_loop.ControlLoopWriter("Claw", [claw])
-    if argv[1][-3:] == '.cc':
-      loop_writer.Write(argv[2], argv[1])
-    else:
-      loop_writer.Write(argv[1], argv[2])
+    namespaces = ['y2015', 'control_loops', 'claw']
+    claw = Claw('Claw')
+    loop_writer = control_loop.ControlLoopWriter('Claw', [claw],
+                                                 namespaces=namespaces)
+    loop_writer.Write(argv[1], argv[2])
 
 if __name__ == '__main__':
   sys.exit(main(sys.argv))