Make climber buttons work

Change-Id: Ia6d83928c0dbaa557fc02050bcdaf6b3b2d2d764
Signed-off-by: Ravago Jones <ravagojones@gmail.com>
diff --git a/y2020/control_loops/superstructure/BUILD b/y2020/control_loops/superstructure/BUILD
index 6ee38ad..100d90c 100644
--- a/y2020/control_loops/superstructure/BUILD
+++ b/y2020/control_loops/superstructure/BUILD
@@ -73,7 +73,6 @@
     ],
     target_compatible_with = ["@platforms//os:linux"],
     deps = [
-        ":climber",
         ":superstructure_goal_fbs",
         ":superstructure_output_fbs",
         ":superstructure_position_fbs",
@@ -135,24 +134,6 @@
     ],
 )
 
-cc_library(
-    name = "climber",
-    srcs = [
-        "climber.cc",
-    ],
-    hdrs = [
-        "climber.h",
-    ],
-    target_compatible_with = ["@platforms//os:linux"],
-    deps = [
-        ":superstructure_goal_fbs",
-        ":superstructure_output_fbs",
-        "//frc971/control_loops:control_loop",
-        "//frc971/control_loops:control_loops_fbs",
-        "//frc971/control_loops:profiled_subsystem_fbs",
-    ],
-)
-
 ts_library(
     name = "turret_plotter",
     srcs = ["turret_plotter.ts"],
diff --git a/y2020/control_loops/superstructure/climber.cc b/y2020/control_loops/superstructure/climber.cc
deleted file mode 100644
index bb449da..0000000
--- a/y2020/control_loops/superstructure/climber.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "y2020/control_loops/superstructure/climber.h"
-
-#include <algorithm>
-
-#include "y2020/control_loops/superstructure/superstructure_goal_generated.h"
-#include "y2020/control_loops/superstructure/superstructure_output_generated.h"
-
-namespace y2020 {
-namespace control_loops {
-namespace superstructure {
-
-void Climber::Iterate(const Goal *unsafe_goal, OutputT *output) {
-  if (unsafe_goal && output) {
-    // Pass through the voltage request from the user.  Backwards isn't
-    // supported, so prevent that.
-    output->climber_voltage =
-        std::clamp(unsafe_goal->climber_voltage(), 0.0f, 12.0f);
-  }
-}
-
-}  // namespace superstructure
-}  // namespace control_loops
-}  // namespace y2020
diff --git a/y2020/control_loops/superstructure/climber.h b/y2020/control_loops/superstructure/climber.h
deleted file mode 100644
index 29b7e51..0000000
--- a/y2020/control_loops/superstructure/climber.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef Y2020_CONTROL_LOOPS_SUPERSTRUCTURE_CLIMBER_H_
-#define Y2020_CONTROL_LOOPS_SUPERSTRUCTURE_CLIMBER_H_
-
-#include "y2020/control_loops/superstructure/superstructure_goal_generated.h"
-#include "y2020/control_loops/superstructure/superstructure_output_generated.h"
-
-namespace y2020 {
-namespace control_loops {
-namespace superstructure {
-
-// Class to encapsulate the climber logic.
-class Climber {
- public:
-  void Iterate(const Goal *unsafe_goal, OutputT *output);
-};
-
-}  // namespace superstructure
-}  // namespace control_loops
-}  // namespace y2020
-
-#endif  // Y2020_CONTROL_LOOPS_SUPERSTRUCTURE_CLIMBER_H_
diff --git a/y2020/control_loops/superstructure/superstructure.cc b/y2020/control_loops/superstructure/superstructure.cc
index 1a61a29..86dcbb1 100644
--- a/y2020/control_loops/superstructure/superstructure.cc
+++ b/y2020/control_loops/superstructure/superstructure.cc
@@ -158,8 +158,6 @@
           position->shooter(), status->fbb(),
           output != nullptr ? &(output_struct) : nullptr, position_timestamp);
 
-  climber_.Iterate(unsafe_goal, output != nullptr ? &(output_struct) : nullptr);
-
   const AbsoluteAndAbsoluteEncoderProfiledJointStatus *const hood_status =
       GetMutableTemporaryPointer(*status->fbb(), hood_status_offset);
 
@@ -237,6 +235,9 @@
     output_struct.feeder_voltage = 0.0;
     output_struct.intake_roller_voltage = 0.0;
     if (unsafe_goal) {
+      output_struct.climber_voltage =
+          std::clamp(unsafe_goal->climber_voltage(), -12.0f, 12.0f);
+
       if (unsafe_goal->shooting() || unsafe_goal->intake_preloading()) {
         preloading_timeout_ = position_timestamp + kPreloadingTimeout;
       }
diff --git a/y2020/control_loops/superstructure/superstructure.h b/y2020/control_loops/superstructure/superstructure.h
index b0bc9f5..8f3eb0a 100644
--- a/y2020/control_loops/superstructure/superstructure.h
+++ b/y2020/control_loops/superstructure/superstructure.h
@@ -6,7 +6,6 @@
 #include "frc971/control_loops/drivetrain/drivetrain_status_generated.h"
 #include "frc971/input/joystick_state_generated.h"
 #include "y2020/constants.h"
-#include "y2020/control_loops/superstructure/climber.h"
 #include "y2020/control_loops/superstructure/shooter/shooter.h"
 #include "y2020/control_loops/superstructure/superstructure_goal_generated.h"
 #include "y2020/control_loops/superstructure/superstructure_output_generated.h"
@@ -70,8 +69,6 @@
       drivetrain_status_fetcher_;
   aos::Fetcher<aos::JoystickState> joystick_state_fetcher_;
 
-  Climber climber_;
-
   aos::monotonic_clock::time_point shooting_start_time_ =
       aos::monotonic_clock::min_time;
   aos::monotonic_clock::time_point preloading_timeout_ =
diff --git a/y2020/control_loops/superstructure/superstructure_lib_test.cc b/y2020/control_loops/superstructure/superstructure_lib_test.cc
index 2b8b39a..b34273c 100644
--- a/y2020/control_loops/superstructure/superstructure_lib_test.cc
+++ b/y2020/control_loops/superstructure/superstructure_lib_test.cc
@@ -952,8 +952,8 @@
   // Give it time to stabilize.
   RunFor(chrono::seconds(1));
 
-  // Can't go backwards.
-  EXPECT_EQ(superstructure_plant_.climber_voltage(), 0.0);
+  // Can go backwards.
+  EXPECT_EQ(superstructure_plant_.climber_voltage(), -10.0);
 
   {
     auto builder = superstructure_goal_sender_.MakeBuilder();
@@ -965,7 +965,8 @@
     ASSERT_TRUE(builder.Send(goal_builder.Finish()));
   }
   RunFor(chrono::seconds(1));
-  // But forwards works.
+
+  // And forwards too.
   EXPECT_EQ(superstructure_plant_.climber_voltage(), 10.0);
 
   VerifyNearGoal();