-
Notifications
You must be signed in to change notification settings - Fork 0
Update GamepadRunIntake #6
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /*----------------------------------------------------------------------------*/ | ||
| /* Copyright (c) 2018 FIRST. All Rights Reserved. */ | ||
| /* Open Source Software - may be modified and shared by FRC teams. The code */ | ||
| /* must be accompanied by the FIRST BSD license file in the root directory of */ | ||
| /* the project. */ | ||
| /*----------------------------------------------------------------------------*/ | ||
|
|
||
| package org.usfirst.frc4079.RobotBuilderProject1.commands; | ||
|
|
||
| import org.usfirst.frc4079.RobotBuilderProject1.Robot; | ||
|
|
||
| import edu.wpi.first.wpilibj.command.Command; | ||
|
|
||
| public class GamepadRunIntake extends Command { | ||
| public GamepadRunIntake() { | ||
| // Use requires() here to declare subsystem dependencies | ||
| // eg. requires(chassis); | ||
| requires(Robot.intake); | ||
| } | ||
|
|
||
| // Called just before this Command runs the first time | ||
| @Override | ||
| protected void initialize() { | ||
| } | ||
|
|
||
| // Called repeatedly when this Command is scheduled to run | ||
| @Override | ||
| protected void execute() { | ||
| if(Robot.oi.gamePad.getRightBumper()) { | ||
| Robot.intake.run(0.4); | ||
| } else if(Robot.oi.gamePad.getLeftBumper()) { | ||
| Robot.intake.run(-0.3); | ||
| } else { | ||
| Robot.intake.run(0); | ||
| } | ||
| } | ||
|
|
||
| // Make this return true when this Command no longer needs to run execute() | ||
| @Override | ||
| protected boolean isFinished() { | ||
| return false; | ||
| } | ||
|
|
||
| // Called once after isFinished returns true | ||
| @Override | ||
| protected void end() { | ||
| Robot.intake.stop(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm, the comment above this method says that this will be called only when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that isFinished() only returns false because it's suppose to start in teleopinit() and runs for the entirety of the teleop period (basically the rest of the match). In this case, end() is not really needed unless end() is called when the match ends. For setting the intake power to 0, I would hope that it would work to stop the intake. |
||
| } | ||
|
|
||
| // Called when another command which requires one or more of the same | ||
| // subsystems is scheduled to run | ||
| @Override | ||
| protected void interrupted() { | ||
| end(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: For this number and the one below (
0.4and-0.3), please extract them into a constant (in the current class or in theConstantsclass), to avoid magic numbers. You can name them something likeINTAKE_FORWARD_POWERor something more relevant.