Merge "Calibrate competition robot for final champs"
diff --git a/y2019/joystick_reader.cc b/y2019/joystick_reader.cc
index 4b0a04b..cd87bf8 100644
--- a/y2019/joystick_reader.cc
+++ b/y2019/joystick_reader.cc
@@ -287,6 +287,7 @@
       last_release_button_press_ = monotonic_now;
     }
 
+    LOG(INFO, "has_piece: %d\n", superstructure_queue.status->has_piece);
     if (data.IsPressed(kSuctionBall)) {
       grab_piece_ = true;
     } else if (data.IsPressed(kSuctionHatch)) {
@@ -296,6 +297,7 @@
                data.IsPressed(kReleaseButtonBoard) ||
                !superstructure_queue.status->has_piece) {
       grab_piece_ = false;
+      LOG(INFO, "releasing due to other thing\n");
     }
 
     if (data.IsPressed(kRocketBackwardUnpressed)) {
@@ -447,6 +449,7 @@
          data.IsPressed(kRelease)) ||
         data.IsPressed(kReleaseButtonBoard)) {
       grab_piece_ = false;
+      LOG(INFO, "Releasing due to button\n");
     }
 
     if (switch_ball_) {
diff --git a/y2019/vision/server/server.cc b/y2019/vision/server/server.cc
index 3ef8983..4d00cdf 100644
--- a/y2019/vision/server/server.cc
+++ b/y2019/vision/server/server.cc
@@ -244,6 +244,7 @@
       sensors->set_elevator(superstructure_status->elevator.position);
       sensors->set_intake(superstructure_status->intake.position);
       sensors->set_stilts(superstructure_status->stilts.position);
+      sensors->set_has_piece(superstructure_status->has_piece);
 
       ::std::string json;
       google::protobuf::util::MessageToJsonString(debug_data, &json);
diff --git a/y2019/vision/server/server_data.proto b/y2019/vision/server/server_data.proto
index 96a5859..1fe8ec2 100644
--- a/y2019/vision/server/server_data.proto
+++ b/y2019/vision/server/server_data.proto
@@ -47,6 +47,7 @@
   optional float elevator = 2;
   optional float intake = 3;
   optional float stilts = 4;
+  optional bool has_piece = 5;
 }
 
 // The overall package of data that we send to the webpage.
diff --git a/y2019/vision/server/www/index.html b/y2019/vision/server/www/index.html
index c970ce1..dc06ed6 100644
--- a/y2019/vision/server/www/index.html
+++ b/y2019/vision/server/www/index.html
@@ -63,6 +63,14 @@
           <div id="stilts" class="dof">
           </div>
         </div>
+
+        <div class="dof_container">
+          <div class="dof_name">
+            has_piece
+          </div>
+          <div id="has_piece" class="dof">
+          </div>
+        </div>
       </div>
     </div>
   </body>
diff --git a/y2019/vision/server/www/main.ts b/y2019/vision/server/www/main.ts
index 1f90527..5647d7b 100644
--- a/y2019/vision/server/www/main.ts
+++ b/y2019/vision/server/www/main.ts
@@ -22,11 +22,13 @@
   private elevator: number = -1;
   private intake: number = -1;
   private stilts: number = -1;
+  private has_piece: number = 0;
 
   private wrist_div: HTMLDivElement;
   private elevator_div: HTMLDivElement;
   private intake_div: HTMLDivElement;
   private stilts_div: HTMLDivElement;
+  private has_piece_div: HTMLDivElement;
 
   constructor() {
     const canvas = <HTMLCanvasElement>document.getElementById('field');
@@ -34,6 +36,7 @@
     this.elevator_div = <HTMLDivElement>document.getElementById('elevator');
     this.intake_div = <HTMLDivElement>document.getElementById('intake');
     this.stilts_div = <HTMLDivElement>document.getElementById('stilts');
+    this.has_piece_div = <HTMLDivElement>document.getElementById('has_piece');
 
     const ctx = canvas.getContext('2d');
 
@@ -65,6 +68,7 @@
       this.elevator = j.sensors.elevator;
       this.intake = j.sensors.intake;
       this.stilts = j.sensors.stilts;
+      this.has_piece = j.sensors.hasPiece;
     });
     socket.addEventListener('close', (event) => {
       setTimeout(() => {
@@ -91,6 +95,7 @@
     this.elevator_div.textContent = "";
     this.intake_div.textContent = "";
     this.stilts_div.textContent = "";
+    this.has_piece_div.textContent = "";
   }
 
   draw(ctx: CanvasRenderingContext2D): void {
@@ -113,6 +118,11 @@
     this.elevator_div.textContent = this.elevator.toFixed(3);
     this.intake_div.textContent = this.intake.toFixed(3);
     this.stilts_div.textContent = this.stilts.toFixed(3);
+    if (this.has_piece) {
+      this.has_piece_div.textContent = "t";
+    } else {
+      this.has_piece_div.textContent = "f";
+    }
 
     window.requestAnimationFrame(() => this.draw(ctx));
   }