Flip front/back and use team number for IP address

We tend to go to backwards buttons more often, and it's slightly more
natural to have front buttons on the left, so switch front/back

Also, both robots were controlling the 10.9.71.179 camera.  Point
them now at robot specific IP addresses.

Change-Id: I0b1c0152f62edae0453d44a614b927c40a4daf2e
diff --git a/y2018/BUILD b/y2018/BUILD
index e4c4128..cccc2cf 100644
--- a/y2018/BUILD
+++ b/y2018/BUILD
@@ -47,6 +47,7 @@
         "//aos/common:time",
         "//aos/common/actions:action_lib",
         "//aos/common/logging",
+        "//aos/common/network:team_number",
         "//aos/common/util:log_interval",
         "//aos/input:drivetrain_input",
         "//aos/input:joystick_input",
diff --git a/y2018/constants.cc b/y2018/constants.cc
index 2ad0c97..70c58f0 100644
--- a/y2018/constants.cc
+++ b/y2018/constants.cc
@@ -135,7 +135,7 @@
 }
 
 const Values &DoGetValues() {
-  uint16_t team = ::aos::network::GetTeamNumber();
+  const uint16_t team = ::aos::network::GetTeamNumber();
   LOG(INFO, "creating a Constants for team %" PRIu16 "\n", team);
   return GetValuesForTeam(team);
 }
diff --git a/y2018/joystick_reader.cc b/y2018/joystick_reader.cc
index 173e6ef..45b7302 100644
--- a/y2018/joystick_reader.cc
+++ b/y2018/joystick_reader.cc
@@ -3,10 +3,12 @@
 #include <string.h>
 #include <unistd.h>
 #include <mutex>
+#include <google/protobuf/stubs/stringprintf.h>
 
 #include "aos/common/actions/actions.h"
 #include "aos/common/input/driver_station_data.h"
 #include "aos/common/logging/logging.h"
+#include "aos/common/network/team_number.h"
 #include "aos/common/stl_mutex.h"
 #include "aos/common/time.h"
 #include "aos/common/util/log_interval.h"
@@ -41,6 +43,7 @@
 namespace joysticks {
 
 namespace arm = ::y2018::control_loops::superstructure::arm;
+using google::protobuf::StringPrintf;
 
 const ButtonLocation kIntakeClosed(3, 2);
 const ButtonLocation kDuck(3, 9);
@@ -49,19 +52,19 @@
 const ButtonLocation kIntakeIn(3, 4);
 const ButtonLocation kIntakeOut(3, 3);
 
-const ButtonLocation kArmFrontHighBox(4, 11);
-const ButtonLocation kArmFrontExtraHighBox(4, 1);
-const ButtonLocation kArmFrontMiddle2Box(4, 9);
-const ButtonLocation kArmFrontMiddle1Box(4, 7);
-const ButtonLocation kArmFrontLowBox(4, 5);
-const ButtonLocation kArmFrontSwitch(3, 7);
+const ButtonLocation kArmBackHighBox(4, 11);
+const ButtonLocation kArmBackExtraHighBox(4, 1);
+const ButtonLocation kArmBackMiddle2Box(4, 9);
+const ButtonLocation kArmBackMiddle1Box(4, 7);
+const ButtonLocation kArmBackLowBox(4, 5);
+const ButtonLocation kArmBackSwitch(3, 7);
 
-const ButtonLocation kArmBackHighBox(4, 12);
-const ButtonLocation kArmBackExtraHighBox(3, 14);
-const ButtonLocation kArmBackMiddle2Box(4, 10);
-const ButtonLocation kArmBackMiddle1Box(4, 8);
-const ButtonLocation kArmBackLowBox(4, 6);
-const ButtonLocation kArmBackSwitch(3, 10);
+const ButtonLocation kArmFrontHighBox(4, 12);
+const ButtonLocation kArmFrontExtraHighBox(3, 14);
+const ButtonLocation kArmFrontMiddle2Box(4, 10);
+const ButtonLocation kArmFrontMiddle1Box(4, 8);
+const ButtonLocation kArmFrontLowBox(4, 6);
+const ButtonLocation kArmFrontSwitch(3, 10);
 
 const ButtonLocation kArmAboveHang(3, 15);
 const ButtonLocation kArmBelowHang(3, 16);
@@ -86,10 +89,15 @@
 
 class Reader : public ::aos::input::JoystickInput {
  public:
-  Reader() : video_tx_("10.9.71.179", 5000) {
+  Reader() {
+    const uint16_t team = ::aos::network::GetTeamNumber();
+
     drivetrain_input_reader_ = DrivetrainInputReader::Make(
-        DrivetrainInputReader::InputType::kPistol,
+        team == 971 ? DrivetrainInputReader::InputType::kPistol
+                    : DrivetrainInputReader::InputType::kSteeringWheel,
         ::y2018::control_loops::drivetrain::GetDrivetrainConfig());
+    video_tx_.reset(new ProtoTXUdpSocket<VisionControl>(
+        StringPrintf("10.%d.%d.179", team / 100, team % 100), 5000));
   }
 
   void RunIteration(const ::aos::input::driver_station::Data &data) override {
@@ -349,7 +357,7 @@
       LOG(ERROR, "Sending superstructure goal failed.\n");
     }
 
-    video_tx_.Send(vision_control_);
+    video_tx_->Send(vision_control_);
   }
 
  private:
@@ -391,7 +399,7 @@
 
   ::aos::common::actions::ActionQueue action_queue_;
 
-  ProtoTXUdpSocket<VisionControl> video_tx_;
+  ::std::unique_ptr<ProtoTXUdpSocket<VisionControl>> video_tx_;
 };
 
 }  // namespace joysticks
diff --git a/y2018/vision/image_streamer.cc b/y2018/vision/image_streamer.cc
index 93f8c58..f6da93c 100644
--- a/y2018/vision/image_streamer.cc
+++ b/y2018/vision/image_streamer.cc
@@ -334,13 +334,16 @@
 
   ProtoUdpClient<VisionControl> udp_client(
       5000, [&camera0, &camera1](const VisionControl &vision_control) {
-        LOG(INFO, "Got control packet\n");
+        bool cam0_active = false;
         if (camera1) {
+          cam0_active = !vision_control.high_video();
           camera0->set_active(!vision_control.high_video());
           camera1->set_active(vision_control.high_video());
         } else {
+          cam0_active = true;
           camera0->set_active(true);
         }
+        LOG(INFO, "Got control packet, cam%d active\n", cam0_active ? 0 : 1);
       });
 
   // Default to camera0