Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adamfixeditforyou #1

Merged
merged 7 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/Commands/Acquisition/AcquisitionIn.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "AcquisitionIn.h"

AcquisitionIn::AcquisitionIn() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
Requires(Robot::storage.get());
Requires(Robot::acquisition.get());
}

// Called just before this Command runs the first time
Expand All @@ -13,9 +11,8 @@ void AcquisitionIn::Initialize() {

// Called repeatedly when this Command is scheduled to run
void AcquisitionIn::Execute() {
Robot::acquisition->Intake();
Robot::storage->MoveStorage(0.2);
Robot::storage->SetGatePosition(true);
//Robot::acquisition->Intake();
//Robot::acquisition->LowerArm();
}

// Make this return true when this Command no longer needs to run execute()
Expand All @@ -25,7 +22,8 @@ bool AcquisitionIn::IsFinished() {

// Called once after isFinished returns true
void AcquisitionIn::End() {

//Robot::acquisition->Stop();
//Robot::acquisition->RaiseArm();
}

// Called when another command which requires one or more of the same
Expand Down
35 changes: 35 additions & 0 deletions src/Commands/Acquisition/ToggleHopper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "ToggleHopper.h"

ToggleHopper::ToggleHopper() {
}

// Called just before this Command runs the first time
void ToggleHopper::Initialize() {

}

// Called repeatedly when this Command is scheduled to run
void ToggleHopper::Execute() {
if(RobotMap::doorPiston->Get() == true) {
Robot::acquisition->CloseHopper();
}
else
{
Robot::acquisition->OpenHopper();
}
}

// Make this return true when this Command no longer needs to run execute()
bool ToggleHopper::IsFinished() {
return true;
}

// Called once after isFinished returns true
void ToggleHopper::End() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
void ToggleHopper::Interrupted() {

}
24 changes: 24 additions & 0 deletions src/Commands/Acquisition/ToggleHopper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* ToggleHopper.h
*
* Created on: Feb 21, 2017
* Author: adnew
*/

#ifndef SRC_COMMANDS_ACQUISITION_TOGGLEHOPPER_H_
#define SRC_COMMANDS_ACQUISITION_TOGGLEHOPPER_H_

#include "../../CommandBase.h"
#include "../../Robot.h"

class ToggleHopper: public CommandBase {
public:
ToggleHopper();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
};

#endif /* SRC_COMMANDS_ACQUISITION_TOGGLEHOPPER_H_ */
2 changes: 1 addition & 1 deletion src/Commands/Auto/AutonomousCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


#include "Commands/Subsystem.h"
#include "../Robot.h"
#include "Robot.h"

/**
*
Expand Down
1 change: 0 additions & 1 deletion src/Commands/Drive/JoystickDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ void JoystickDrive::Initialize() {

// Called repeatedly when this Command is scheduled to run
void JoystickDrive::Execute() {
printf("running");
Robot::drive->TankDrive(Robot::oi->GetYDriverL() * fabs(Robot::oi->GetYDriverL()), Robot::oi->GetYDriverR() * fabs(Robot::oi->GetYDriverR()), false);
}

Expand Down
1 change: 0 additions & 1 deletion src/Commands/Drive/ShiftHigh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

ShiftHigh::ShiftHigh() {
// Use Requires() here to declare subsystem dependencies
Requires(Robot::drive.get());
}

// Called just before this Command runs the first time
Expand Down
1 change: 0 additions & 1 deletion src/Commands/Drive/ShiftLow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

ShiftLow::ShiftLow() {
// Use Requires() here to declare subsystem dependencies
Requires(Robot::drive.get());
}

// Called just before this Command runs the first time
Expand Down
3 changes: 1 addition & 2 deletions src/Commands/Gear/GearIn.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "GearIn.h"

GearIn::GearIn() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
Requires(Robot::gear.get()); //Don't let controller confuse the robot by mashing both buttons
}

// Called just before this Command runs the first time
Expand Down
3 changes: 1 addition & 2 deletions src/Commands/Gear/GearOut.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "GearOut.h"

GearOut::GearOut() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
Requires(Robot::gear.get()); //Don't let controller confuse the robot by mashing both buttons
}

// Called just before this Command runs the first time
Expand Down
37 changes: 37 additions & 0 deletions src/Commands/Shooter/FireBallsHigh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <Commands/Shooter/FireBallsHigh.h>

FireBallsHigh::FireBallsHigh() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
}

// Called just before this Command runs the first time
void FireBallsHigh::Initialize() {

}

// Called repeatedly when this Command is scheduled to run
void FireBallsHigh::Execute() {
Robot::shooter->SetAngle(true);
if (Robot::shooter->UpToSpeed()) //Is the shooter up to speed?
Robot::shooter->SetGatePosition(false); //TODO make the shooter alternate sides while held
else
Robot::shooter->SetGatePosition(true);
}

// Make this return true when this Command no longer needs to run execute()
bool FireBallsHigh::IsFinished() {
return false;
}

// Called once after isFinished returns true
void FireBallsHigh::End() {
Robot::shooter->SetGatePosition(true);
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
void FireBallsHigh::Interrupted() {

}

24 changes: 24 additions & 0 deletions src/Commands/Shooter/FireBallsHigh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* FireBallsHigh.h
*
* Created on: Feb 19, 2017
* Author: adnew
*/

#ifndef SRC_COMMANDS_SHOOTER_FIREBALLSHIGH_H_
#define SRC_COMMANDS_SHOOTER_FIREBALLSHIGH_H_

#include "../../CommandBase.h"
#include "../../Robot.h"
class FireBallsHigh: public Command {
public:
FireBallsHigh();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
};


#endif /* SRC_COMMANDS_SHOOTER_FIREBALLSHIGH_H_ */
37 changes: 37 additions & 0 deletions src/Commands/Shooter/FireBallsLow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <Commands/Shooter/FireBallsLow.h>

FireBallsLow::FireBallsLow() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
}

// Called just before this Command runs the first time
void FireBallsLow::Initialize() {

}

// Called repeatedly when this Command is scheduled to run
void FireBallsLow::Execute() {
Robot::shooter->SetAngle(false);
if (Robot::shooter->UpToSpeed()) //Is the shooter up to speed?
Robot::shooter->SetGatePosition(false); //TODO make the shooter alternate sides while held
else
Robot::shooter->SetGatePosition(true);
}

// Make this return true when this Command no longer needs to run execute()
bool FireBallsLow::IsFinished() {
return false;
}

// Called once after isFinished returns true
void FireBallsLow::End() {
Robot::shooter->SetGatePosition(true);
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
void FireBallsLow::Interrupted() {

}

24 changes: 24 additions & 0 deletions src/Commands/Shooter/FireBallsLow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* FireBallsLow.h
*
* Created on: Feb 19, 2017
* Author: adnew
*/

#ifndef SRC_COMMANDS_SHOOTER_FIREBALLSLOW_H_
#define SRC_COMMANDS_SHOOTER_FIREBALLSLOW_H_

#include "../../CommandBase.h"
#include "../../Robot.h"
class FireBallsLow: public Command {
public:
FireBallsLow();
void Initialize() override;
void Execute() override;
bool IsFinished() override;
void End() override;
void Interrupted() override;
};


#endif /* SRC_COMMANDS_SHOOTER_FIREBALLS_H_ */
2 changes: 1 addition & 1 deletion src/Commands/Shooter/RunShooter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void RunShooter::Initialize() {

// Called repeatedly when this Command is scheduled to run
void RunShooter::Execute() {
if (!Robot::shooter->IsRunning())
if (!Robot::shooter->IsRunning()) //Toggle the shooter flywheel
Robot::shooter->RunFlywheel(GetDesiredSpeed());
else
Robot::shooter->RunFlywheel(0);
Expand Down
9 changes: 5 additions & 4 deletions src/Commands/Storage/RunStorage.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "RunStorage.h"
#define SHOOTER_ACCEPTABLE_ERROR 50

RunStorage::RunStorage() {
// Use Requires() here to declare subsystem dependencies
// eg. Requires(Robot::chassis.get());
Requires(Robot::storage.get());
}

// Called just before this Command runs the first time
Expand All @@ -13,11 +13,12 @@ void RunStorage::Initialize() {

// Called repeatedly when this Command is scheduled to run
void RunStorage::Execute() {
if (fabs(Robot::shooter->GetFlywheelSpeed() - RunShooter::GetDesiredSpeed()) < SHOOTER_ACCEPTABLE_ERROR){
//Either Acquisition is running or the shooter is sunning and ready to fire
if (Robot::oi->GetAcquisition() || (Robot::oi->GetFiring() && Robot::shooter->UpToSpeed())){
Robot::storage->MoveStorage(0.2);
}
else
} else {
Robot::storage->MoveStorage(0.0);
}
}

// Make this return true when this Command no longer needs to run execute()
Expand Down
1 change: 1 addition & 0 deletions src/Commands/Storage/RunStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <Commands/Shooter/RunShooter.h>
#include "../../CommandBase.h"
#include "Robot.h"

class RunStorage: public Command {
public:
Expand Down
30 changes: 22 additions & 8 deletions src/OI.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <Commands/Shooter/FireBallsHigh.h>
#include <Commands/Shooter/FireBallsLow.h>
#include <Commands/Shooter/RunShooter.h>
#include <Commands/Shooter/RunVisionShooter.h>
#include "OI.h"

#include <WPILib.h>
#include "Robot.h"
#include "Commands/Acquisition/AcquisitionIn.h"
#include "Commands/Acquisition/ToggleHopper.h"
#include "Commands/Climbing/StartClimber.h"
#include "Commands/Climbing/StopClimber.h"
#include "Commands/Drive/ShiftHigh.h"
Expand All @@ -14,7 +17,6 @@
#include "Commands/Storage/RunStorage.h"
#include "Commands/Shooter/RunShooter.h"


bool OI::controllerLeft;

OI::OI(){
Expand Down Expand Up @@ -52,10 +54,10 @@ void OI::MapButtons(){
driveShiftHighGear.reset(new JoystickButton(driverR.get(), SHIFT_HIGH_GEAR));
driveShiftHighGear->WhenPressed(new ShiftHigh());

drivePTOOn.reset(new JoystickButton(controllerR.get(), SHIFT_PTO_ON));
drivePTOOn.reset(new JoystickButton(driverR.get(), SHIFT_PTO_ON));
drivePTOOn->WhenPressed(new StartClimber());

drivePTOOff.reset(new JoystickButton(controllerL.get(), SHIFT_PTO_OFF));
drivePTOOff.reset(new JoystickButton(driverL.get(), SHIFT_PTO_OFF));
drivePTOOff->WhenPressed(new StopClimber());

toggleShooter.reset(new JoystickButton(controllerL.get(), TOGGLE_SHOOTER));
Expand All @@ -64,9 +66,6 @@ void OI::MapButtons(){
toggleVisionShooter.reset(new JoystickButton(controllerL.get(), TOGGLE_VISION_SHOOTER));
toggleVisionShooter->WhenPressed(new RunVisionShooter());

storageFeedShooter.reset(new JoystickButton(controllerL.get(), STORAGE_FEED_SHOOTER));
storageFeedShooter->WhileHeld(new RunStorage());

extendGear.reset(new JoystickButton(controllerL.get(), EXTEND_GEAR));
extendGear->WhenPressed(new GearOut());

Expand All @@ -76,10 +75,17 @@ void OI::MapButtons(){
acqIn.reset(new JoystickButton(controllerL.get(), ACQ_IN));
acqIn->WhileHeld(new AcquisitionIn());

toggleHopper.reset(new JoystickButton(controllerL.get(), TOGGLE_HOPPER));
toggleHopper->WhenPressed(new ToggleHopper());

turnToBoiler.reset(new JoystickButton(driverR.get(), DRIVE_TO_BOILER));
turnToGear.reset(new JoystickButton(driverR.get(), DRIVE_TO_GEAR));
shooterAngleFar.reset(new JoystickButton(driverR.get(), SHOOTER_ANGLE_FAR));
shooterAngleShort.reset(new JoystickButton(driverR.get(), SHOOTER_ANGLE_SHORT));

shooterAngleFar.reset(new JoystickButton(controllerL.get(), SHOOT_FAR));
shooterAngleFar->WhileHeld(new FireBallsHigh());

shooterAngleShort.reset(new JoystickButton(controllerL.get(), SHOOT_SHORT));
shooterAngleShort->WhileHeld(new FireBallsLow());
}

double OI::GetYControllerL(){
Expand Down Expand Up @@ -109,3 +115,11 @@ double OI::GetYDriverR(){
else
return lJoystick2->GetY();
}

bool OI::GetAcquisition(){
return acqIn->Get();
}

bool OI::GetFiring(){
return shooterAngleFar->Get() || shooterAngleShort->Get();
}
Loading