From ca3e5f513c734870e595f01e2578dd79d3ade246 Mon Sep 17 00:00:00 2001 From: Adam Long Date: Sat, 18 Oct 2014 15:31:39 +0000 Subject: [PATCH] Added NetworkTables support and fixed minor auto logic issues --- src/HHRobot.cpp | 9 +++++++-- src/HHRobot.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/HHRobot.cpp b/src/HHRobot.cpp index c46939b..4919849 100644 --- a/src/HHRobot.cpp +++ b/src/HHRobot.cpp @@ -1,4 +1,5 @@ #include "HHRobot.h" +#include "NetworkTables/NetworkTable.h" #include "HHBase.h" HHRobot::HHRobot(): ControlSystem(new JoystickController()), @@ -8,6 +9,7 @@ HHRobot::HHRobot(): dashboard(new HHDashboard()), autoseq(new HHAuto()), sonar(new HHSonar()){ + netTable = NetworkTable::GetTable("datatable"); } bool HHRobot::CheckJoystickValues(){ float x=ControlSystem->rightJoystickAxisValues[1]; @@ -54,7 +56,7 @@ void HHRobot::RunAuto(){ } //TODO Pass the shooting power and sonar distance as variables to the RunAuto function //Shoot at a power - if(step == 1){ + if(step == 1 && time < 500){ shooter->StartShootingSequence(0.78); }else{ step = 2; @@ -62,12 +64,15 @@ void HHRobot::RunAuto(){ if(step == 2){ return; } + //Important periodic things + netTable->PutNumber("AutoStep",step); //Debugging purposes + time++; } //Main function used to handle periodic tasks on the robot void HHRobot::Handler(){ int targetAngle; - bool allowCompressing = true; + bool allowCompressing; //Periodic tasks that should be run by every loop ControlSystem->UpdateJoysticks(); shooter->UpdateShooterPosition(targetAngle); diff --git a/src/HHRobot.h b/src/HHRobot.h index ce5e971..1c1ba95 100644 --- a/src/HHRobot.h +++ b/src/HHRobot.h @@ -15,6 +15,7 @@ class HHRobot{ private: Jaguar *right1, *right2, *right3, *left1, *left2, *left3; JoystickController *ControlSystem; + NetworkTable *netTable; HHShooter *shooter; HHCollector *collector; HHCompressor *compressorSystem;