Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ public class Constants {

public static final int kBaseTrajPeriodMs = 0;
public static final double kNeutralDeadband = 0.01;

public static double kIntakeSpeed = 0.4;
public static double kOuttakeSpeed = -0.3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*----------------------------------------------------------------------------*/
/* 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;

import org.usfirst.frc4079.RobotBuilderProject1.Constants;

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(Constants.kIntakeSpeed);
} else if (Robot.oi.gamePad.getLeftBumper()) {
Robot.intake.run(Constants.kOuttakeSpeed);
} 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();
Copy link
Member

Choose a reason for hiding this comment

The 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 isFinished returns true, which it never does (line 41). This line is never reached. Is setting the intake power to 0 sufficient for stopping the intake?

Copy link

@jyue86 jyue86 Jan 3, 2019

Choose a reason for hiding this comment

The 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();
}
}