2
0
mirror of https://github.com/team2059/Zaphod synced 2024-12-18 20:12:28 -05:00

Added NetworkTables support and fixed minor auto logic issues

This commit is contained in:
Adam Long 2014-10-18 15:31:39 +00:00
parent 1fd59a0a84
commit ca3e5f513c
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#include "HHRobot.h" #include "HHRobot.h"
#include "NetworkTables/NetworkTable.h"
#include "HHBase.h" #include "HHBase.h"
HHRobot::HHRobot(): HHRobot::HHRobot():
ControlSystem(new JoystickController()), ControlSystem(new JoystickController()),
@ -8,6 +9,7 @@ HHRobot::HHRobot():
dashboard(new HHDashboard()), dashboard(new HHDashboard()),
autoseq(new HHAuto()), autoseq(new HHAuto()),
sonar(new HHSonar()){ sonar(new HHSonar()){
netTable = NetworkTable::GetTable("datatable");
} }
bool HHRobot::CheckJoystickValues(){ bool HHRobot::CheckJoystickValues(){
float x=ControlSystem->rightJoystickAxisValues[1]; 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 //TODO Pass the shooting power and sonar distance as variables to the RunAuto function
//Shoot at a power //Shoot at a power
if(step == 1){ if(step == 1 && time < 500){
shooter->StartShootingSequence(0.78); shooter->StartShootingSequence(0.78);
}else{ }else{
step = 2; step = 2;
@ -62,12 +64,15 @@ void HHRobot::RunAuto(){
if(step == 2){ if(step == 2){
return; return;
} }
//Important periodic things
netTable->PutNumber("AutoStep",step); //Debugging purposes
time++;
} }
//Main function used to handle periodic tasks on the robot //Main function used to handle periodic tasks on the robot
void HHRobot::Handler(){ void HHRobot::Handler(){
int targetAngle; int targetAngle;
bool allowCompressing = true; bool allowCompressing;
//Periodic tasks that should be run by every loop //Periodic tasks that should be run by every loop
ControlSystem->UpdateJoysticks(); ControlSystem->UpdateJoysticks();
shooter->UpdateShooterPosition(targetAngle); shooter->UpdateShooterPosition(targetAngle);

View File

@ -15,6 +15,7 @@ class HHRobot{
private: private:
Jaguar *right1, *right2, *right3, *left1, *left2, *left3; Jaguar *right1, *right2, *right3, *left1, *left2, *left3;
JoystickController *ControlSystem; JoystickController *ControlSystem;
NetworkTable *netTable;
HHShooter *shooter; HHShooter *shooter;
HHCollector *collector; HHCollector *collector;
HHCompressor *compressorSystem; HHCompressor *compressorSystem;