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

Indicates if the joysticks were plugged in during an invalid state (boolean on the dashboard)

This commit is contained in:
Adam Long 2014-06-10 14:46:31 -04:00
parent d05dfd3e8d
commit 080079610b
3 changed files with 27 additions and 6 deletions

View File

@ -4,16 +4,29 @@ ZaphodDashboard::ZaphodDashboard()
{
//Add Dashboard Initalizations here (for now)
SmartDashboard::PutNumber("Shooting Power", 0.0f);
SmartDashboard::PutBoolean("Joysticks Valid", false);
}
float ZaphodDashboard::getKeyValue(const char* key)
float ZaphodDashboard::getFloatValue(const char* key)
{
float value = SmartDashboard::GetNumber(key);
return value;
}
bool ZaphodDashboard::putKeyValue(const char* key, float value)
bool ZaphodDashboard::putFloatValue(const char* key, float value)
{
SmartDashboard::PutNumber(key,value);
return true;
}
bool ZaphodDashboard::getBoolValue(const char* key)
{
bool value = SmartDashboard::GetBoolean(key);
return value;
}
bool ZaphodDashboard::putBoolValue(const char* key, bool value)
{
SmartDashboard::PutBoolean(key,value);
return true;
}

View File

@ -7,6 +7,8 @@ class ZaphodDashboard
ZaphodDashboard();
//Array used to track the values in the dashboard
bool DashboardValues[];
float getKeyValue(const char* key);
bool putKeyValue(const char* key, float value);
float getFloatValue(const char* key);
bool putFloatValue(const char* key, float value);
bool getBoolValue(const char* key);
bool putBoolValue(const char* key, bool value);
};

View File

@ -64,10 +64,13 @@ bool ZaphodRobot::checkJoystickValues()
float y = ControlSystem->rightJoystickAxisValues[2];
if((-.1 < x && x < .1) && (-.1 < y && y < .1))
{
dashboard->putBooleanValue("Joysticks Valid", true);
return true;
}
else
{
dashboard->putBooleanValue("Joysticks Valid", false);
return true;
return false;
}
}
@ -91,7 +94,7 @@ void ZaphodRobot::driveRobot(float x, float y)
void ZaphodRobot::updateDashboard()
{
dashboard->putKeyValue("Shooting Power", ControlSystem->throttle);
dashboard->putFloatValue("Shooting Power", ControlSystem->throttle);
}
//Main function used to handle periodic tasks on the robot
@ -104,7 +107,10 @@ void ZaphodRobot::handler()
//TODO Need to implement a timing system to not break the spike (this function doesn't run the compressor at the moment)
compressorSystem->compressorSystemPeriodic();
collector->updateCollector(shooter->isShooting, shooter->getAngle());
driveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]);
if(checkJoystickValues())
{
driveRobot(ControlSystem->rightJoystickAxisValues[3]+ControlSystem->rightJoystickAxisValues[1], -ControlSystem->rightJoystickAxisValues[2]);
}
updateDashboard();
//Button assignments to actions