mirror of
https://github.com/team2059/Zaphod
synced 2025-01-07 22:14:14 -05:00
Added function to return values of the sonars, front, back, or an individual sonar. TODO: add a delay from when we turn on the sonar to when we turn it back off again
This commit is contained in:
parent
47a6b9050b
commit
de4a4f448a
@ -7,9 +7,7 @@ HHRobot::HHRobot():
|
||||
compressorSystem(new HHCompressor()),
|
||||
dashboard(new HHDashboard()),
|
||||
sonar(new HHSonar()){
|
||||
//comment
|
||||
}
|
||||
//Functions to get sonar values and return as INCH values
|
||||
bool HHRobot::checkJoystickValues(){
|
||||
float x=ControlSystem->rightJoystickAxisValues[1];
|
||||
float y=ControlSystem->rightJoystickAxisValues[2];
|
||||
|
@ -9,6 +9,59 @@ HHSonar::HHSonar(){
|
||||
AnalogChannel backLeftA=new AnalogChannel(SONAR_BACK_LEFT_ANA);
|
||||
AnalogChannel backRightA=new AnalogChannel(SONAR_BACK_RIGHT_ANA);
|
||||
}
|
||||
float HHSonar::getInches(const char* from){
|
||||
return 10.9f;
|
||||
float HHSonar::getInches(std::string from){
|
||||
switch(from){
|
||||
case "FRONT":
|
||||
frontLeftD->Set(1);
|
||||
float x=(frontLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
frontLeftD->Set(0);
|
||||
//TODO: Delay
|
||||
frontRightD->Set(1);
|
||||
float y=(frontRightA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
frontRightD->Set(0);
|
||||
//TODO: Delay
|
||||
return (x+y)/2;
|
||||
break;
|
||||
case "BACK":
|
||||
backLeftD->Set(1);
|
||||
float x=(backLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
backLeftD->Set(0);
|
||||
//TODO: Delay
|
||||
backRightD->Set(1);
|
||||
float y=(backRightA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
backRightD->Set(0);
|
||||
//TODO: Delay
|
||||
return (x+y)/2;
|
||||
break;
|
||||
case "FRONTLEFT":
|
||||
frontLeftD->Set(1);
|
||||
float x=(frontLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
frontLeftD->Set(0);
|
||||
//TODO: Delay
|
||||
return x;
|
||||
break;
|
||||
case "FRONTRIGHT":
|
||||
frontRightD->Set(1);
|
||||
float x=(frontRightA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
frontRightD->Set(0);
|
||||
//TODO: Delay
|
||||
return x;
|
||||
break;
|
||||
case "BACKLEFT":
|
||||
backLeftD->Set(1);
|
||||
float x=(backLeftA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
backLeftD->Set(0);
|
||||
//TODO: Delay
|
||||
return x;
|
||||
break;
|
||||
case "BACKRIGHT":
|
||||
backRightD->Set(1);
|
||||
float x=(backRightA->GetAverageVoltage()/0.00488f)/2.54f;
|
||||
backRightD->Set(0);
|
||||
//TODO: Delay
|
||||
return x;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,5 @@ class HHSonar{
|
||||
public:
|
||||
HHSonar();
|
||||
//from is (in string form) "FRONT", "BACK", "FRONTLEFT", "FRONTRIGHT"...
|
||||
float getInches(const char* from);
|
||||
float getInches(std::string from);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user