mirror of
https://github.com/team2059/Zaphod
synced 2024-12-18 20:12:28 -05:00
Fixed minor errors in the last rev
This commit is contained in:
parent
00a560968d
commit
aab9572a48
49
MyRobot.cpp
49
MyRobot.cpp
@ -10,14 +10,13 @@ class RobotDemo : public SimpleRobot
|
|||||||
{
|
{
|
||||||
RobotDrive myRobot;
|
RobotDrive myRobot;
|
||||||
float potVal, multiplier, throttle;
|
float potVal, multiplier, throttle;
|
||||||
bool collectorExtended, shooting, compressing;
|
bool collectorExtended, shooting, compressing, allowCompressing;
|
||||||
float upLimit;
|
float upLimit;
|
||||||
Joystick Rstick, Lstick;
|
Joystick Rstick, Lstick;
|
||||||
Solenoid collectorSole1, collectorSole2;
|
Solenoid collectorSole1, collectorSole2;
|
||||||
Compressor compressor;
|
Compressor compressor;
|
||||||
Jaguar Left1, Left2, Left3, Right1, Right2, Right3, RightArmMotor1, RightArmMotor2, LeftArmMotor1, LeftArmMotor2, CollectorMotor1;
|
Jaguar Left1, Left2, Left3, Right1, Right2, Right3, RightArmMotor1, RightArmMotor2, LeftArmMotor1, LeftArmMotor2, CollectorMotor1;
|
||||||
AnalogChannel armPot;
|
AnalogChannel armPot;
|
||||||
//Ultrasonic
|
|
||||||
AnalogChannel BallSonicLeft, BallSonicRight, WallSonicLeft, WallSonicRight;
|
AnalogChannel BallSonicLeft, BallSonicRight, WallSonicLeft, WallSonicRight;
|
||||||
DigitalOutput BallLeft, BallRight, WallLeft, WallRight;
|
DigitalOutput BallLeft, BallRight, WallLeft, WallRight;
|
||||||
public:
|
public:
|
||||||
@ -65,6 +64,7 @@ public:
|
|||||||
compressor.Start();
|
compressor.Start();
|
||||||
shooting = false;
|
shooting = false;
|
||||||
compressing = true;
|
compressing = true;
|
||||||
|
allowCompressing = true;
|
||||||
throttle=0;
|
throttle=0;
|
||||||
}
|
}
|
||||||
void DashboardSetup() {
|
void DashboardSetup() {
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
SmartDashboard::PutBoolean("Use Ultrasonic",true);
|
SmartDashboard::PutBoolean("Use Ultrasonic",true);
|
||||||
SmartDashboard::PutBoolean("Daniel Mode",false);
|
SmartDashboard::PutBoolean("Daniel Mode",false);
|
||||||
SmartDashboard::PutBoolean("CollectorState",false);
|
SmartDashboard::PutBoolean("CollectorState",false);
|
||||||
SmartDashboard::PutBoolean("Compressor Enabled", true);
|
SmartDashboard::PutBoolean("Compressor Enabled", allowCompressing);
|
||||||
SmartDashboard::PutBoolean("Compressor Running", compressing);
|
SmartDashboard::PutBoolean("Compressor Running", compressing);
|
||||||
//Battery voltage
|
//Battery voltage
|
||||||
}
|
}
|
||||||
@ -112,6 +112,7 @@ public:
|
|||||||
SmartDashboard::PutNumber("Ball Right", voltToDistance(BallSonicRight.GetAverageVoltage()));
|
SmartDashboard::PutNumber("Ball Right", voltToDistance(BallSonicRight.GetAverageVoltage()));
|
||||||
SmartDashboard::PutNumber("upLimit", upLimit);
|
SmartDashboard::PutNumber("upLimit", upLimit);
|
||||||
SmartDashboard::PutBoolean("Compressor Running", compressing);
|
SmartDashboard::PutBoolean("Compressor Running", compressing);
|
||||||
|
allowCompressing = SmartDashboard::GetBoolean("Compressor Enabled");
|
||||||
if(upLimit > 167) {
|
if(upLimit > 167) {
|
||||||
upLimit = 167;
|
upLimit = 167;
|
||||||
}
|
}
|
||||||
@ -238,21 +239,23 @@ public:
|
|||||||
myRobot.SetSafetyEnabled(false);
|
myRobot.SetSafetyEnabled(false);
|
||||||
int avgDist;
|
int avgDist;
|
||||||
int commandIndex=0;
|
int commandIndex=0;
|
||||||
|
int averageAmount=5;
|
||||||
int i=0;
|
int i=0;
|
||||||
int c=0;
|
int c=0;
|
||||||
float initalDriveTimeout=(SmartDashboard::GetNumber("Inital Drive Timeout"))*200;
|
float initalDriveTimeout=(SmartDashboard::GetNumber("Inital Drive Timeout"))*200;
|
||||||
//Incase the wall ultrasonic fails, there will be a timeout that will force the motors to stop after a given time.
|
//Incase the wall ultrasonic fails, there will be a timeout that will force the motors to stop after a given time.
|
||||||
float initalDriveTimeout=(SmartDashboard::GetNumber("Inital Drive Timeout"))*200;
|
|
||||||
//The time when the shooter motors will begin to fire the ball
|
|
||||||
float startShootingFirst=(SmartDashboard::GetNumber("First Shot Start"))*200;
|
float startShootingFirst=(SmartDashboard::GetNumber("First Shot Start"))*200;
|
||||||
//The time when the shooter motors will stop (set power to 0)
|
//The time when the shooter motors will begin to fire the ball
|
||||||
float stopShootingFirst=(SmartDashboard::GetNumber("First Shot Stop"))*200;
|
float stopShootingFirst=(SmartDashboard::GetNumber("First Shot Stop"))*200;
|
||||||
//The time to start when getting the second ball
|
//The time when the shooter motors will stop (set power to 0)
|
||||||
float getSecondBallStart=(SmartDashboard::GetNumber("Reverse direction start"))*200;
|
float getSecondBallStart=(SmartDashboard::GetNumber("Reverse direction start"))*200;
|
||||||
//The time to stop when getting the second ball
|
//The time to start when getting the second ball
|
||||||
float getSecondBallStop=(SmartDashboard::GetNumber("Reverse direction stop"))*200;
|
float getSecondBallStop=(SmartDashboard::GetNumber("Reverse direction stop"))*200;
|
||||||
//The power the shooter will use (in a percent)
|
//The time to stop when getting the second ball
|
||||||
float power=SmartDashboard::GetNumber("AutoPower");
|
float power=SmartDashboard::GetNumber("AutoPower");
|
||||||
|
//The power the shooter will use (in a percent)
|
||||||
|
float correction=SmartDashboard::GetNumber("AutoCorrection");
|
||||||
|
//The correction value for the X axis
|
||||||
compressing=false;
|
compressing=false;
|
||||||
collectorSole1.Set(false);
|
collectorSole1.Set(false);
|
||||||
collectorSole2.Set(true);
|
collectorSole2.Set(true);
|
||||||
@ -370,6 +373,16 @@ public:
|
|||||||
logMsg("Collector is extended, going to fire",17);
|
logMsg("Collector is extended, going to fire",17);
|
||||||
shootRobot(throttle);
|
shootRobot(throttle);
|
||||||
setMotorValue(6, 1, 1);
|
setMotorValue(6, 1, 1);
|
||||||
|
// if(collectorExtended){
|
||||||
|
// shooting = true;
|
||||||
|
// logMsg("Firing",13);
|
||||||
|
// logMsg("Collector is extended, going to fire",17);
|
||||||
|
// shootRobot(throttle);
|
||||||
|
// setMotorValue(6, 1, 1);
|
||||||
|
// }else{
|
||||||
|
// shooting = false;
|
||||||
|
// logMsg("Collector is NOT extended, not going to fire",17);
|
||||||
|
// }
|
||||||
}else if(Lstick.GetRawButton(1)==1) {
|
}else if(Lstick.GetRawButton(1)==1) {
|
||||||
//Move arm motors based on throttle
|
//Move arm motors based on throttle
|
||||||
shooting = true;
|
shooting = true;
|
||||||
@ -377,6 +390,17 @@ public:
|
|||||||
logMsg("Collector is extended, going to fire",17);
|
logMsg("Collector is extended, going to fire",17);
|
||||||
shootRobot(throttle);
|
shootRobot(throttle);
|
||||||
setMotorValue(6, 1, 1);
|
setMotorValue(6, 1, 1);
|
||||||
|
// if(collectorExtended == false) {
|
||||||
|
// shooting = false;
|
||||||
|
// logMsg("Collector is NOT extended, not going to fire",17);
|
||||||
|
// }
|
||||||
|
// if(collectorExtended == true&&(upLimit>=potToDegrees(armPot.GetAverageVoltage()))) {
|
||||||
|
// shooting = true;
|
||||||
|
// logMsg("Firing",13);
|
||||||
|
// logMsg("Collector is extended, going to fire",17);
|
||||||
|
// shootRobot(throttle);
|
||||||
|
// setMotorValue(6, 1, 1);
|
||||||
|
// }
|
||||||
} else if(Lstick.GetRawButton(1)==1&&(upLimit<=potToDegrees(armPot.GetAverageVoltage()))) {
|
} else if(Lstick.GetRawButton(1)==1&&(upLimit<=potToDegrees(armPot.GetAverageVoltage()))) {
|
||||||
shooting = false;
|
shooting = false;
|
||||||
logMsg("Stopping shooter motor",13);
|
logMsg("Stopping shooter motor",13);
|
||||||
@ -386,6 +410,13 @@ public:
|
|||||||
//Reverse the arm motors
|
//Reverse the arm motors
|
||||||
shooting = false;
|
shooting = false;
|
||||||
shootRobot(-0.1f);
|
shootRobot(-0.1f);
|
||||||
|
// if(collectorExtended == false) {
|
||||||
|
// logMsg("Collector is not extended, not going to fire",17);
|
||||||
|
// }
|
||||||
|
// if(collectorExtended == true) {
|
||||||
|
// shootRobot(-0.1f);
|
||||||
|
// logMsg("Collector is extended, going to fire",17);
|
||||||
|
// }
|
||||||
} else {
|
} else {
|
||||||
shooting = false;
|
shooting = false;
|
||||||
//Stop all motors
|
//Stop all motors
|
||||||
|
Loading…
Reference in New Issue
Block a user