Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit ec9f479

Browse files
committed
added more functionality to intakeEject
1 parent a9fd436 commit ec9f479

3 files changed

Lines changed: 83 additions & 3 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.Robot;
4+
5+
import edu.wpi.first.wpilibj.command.Command;
6+
7+
/**
8+
*
9+
*/
10+
public class DefaultIntake extends Command {
11+
12+
public DefaultIntake() {
13+
// Use requires() here to declare subsystem dependencies
14+
// eg. requires(chassis);
15+
}
16+
17+
// Called just before this Command runs the first time
18+
protected void initialize() {
19+
}
20+
21+
// Called repeatedly when this Command is scheduled to run
22+
protected void execute() {
23+
// 1 and 5 represent the axes' index in driver station
24+
Robot.intakeEject.runLeftIntake(Robot.oi.manipulator.getRawAxis(1));
25+
Robot.intakeEject.runRightIntake(Robot.oi.manipulator.getRawAxis(5));
26+
}
27+
28+
// Make this return true when this Command no longer needs to run execute()
29+
protected boolean isFinished() {
30+
return false;
31+
}
32+
33+
// Called once after isFinished returns true
34+
protected void end() {
35+
}
36+
37+
// Called when another command which requires one or more of the same
38+
// subsystems is scheduled to run
39+
protected void interrupted() {
40+
}
41+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEject.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.usfirst.frc.team199.Robot2018.Robot;
44
import org.usfirst.frc.team199.Robot2018.RobotMap;
5+
import org.usfirst.frc.team199.Robot2018.commands.DefaultIntake;
56

67
import edu.wpi.first.wpilibj.DoubleSolenoid;
78
import edu.wpi.first.wpilibj.PowerDistributionPanel;
@@ -24,6 +25,7 @@ public class IntakeEject extends Subsystem implements IntakeEjectInterface {
2425
* Set the default command for a subsystem here.
2526
*/
2627
public void initDefaultCommand() {
28+
setDefaultCommand(new DefaultIntake());
2729
}
2830

2931
/**
@@ -60,16 +62,37 @@ public void stopIntake() {
6062
rightIntakeMotor.stopMotor();
6163
}
6264

65+
/**
66+
* Sets the left roller to run at the specified speed
67+
*
68+
* @param speed
69+
* Speed the left motor should run at
70+
*/
71+
public void runLeftIntake(double speed) {
72+
double actualSpeed = speed * Robot.getConst("Intake Motor Left Speed Multiplier", 1);
73+
leftIntakeMotor.set(actualSpeed);
74+
}
75+
76+
/**
77+
* Sets the left roller to run at the specified speed
78+
*
79+
* @param speed
80+
* Speed the left motor should run at
81+
*/
82+
public void runRightIntake(double speed) {
83+
double actualSpeed = speed * Robot.getConst("Intake Motor Right Speed Multiplier", 1);
84+
rightIntakeMotor.set(actualSpeed);
85+
}
86+
6387
/**
6488
* Spins the rollers
6589
*
6690
* @param speed
6791
* - positive -> rollers in, negative -> rollers out
6892
*/
6993
public void runIntake(double speed) {
70-
double actualSpeed = speed * Robot.getConst("Intake Motor Speed Multiplier", 1);
71-
leftIntakeMotor.set(actualSpeed);
72-
rightIntakeMotor.set(actualSpeed);
94+
runLeftIntake(speed);
95+
runRightIntake(speed);
7396
}
7497

7598
/**

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEjectInterface.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ public interface IntakeEjectInterface {
3030
*/
3131
public void stopIntake();
3232

33+
/**
34+
* Sets the left roller to run at the specified speed
35+
*
36+
* @param speed
37+
* Speed the left motor should run at
38+
*/
39+
public void runLeftIntake(double speed);
40+
41+
/**
42+
* Sets the right roller to run at the specified speed
43+
*
44+
* @param speed
45+
* Speed the right motor should run at
46+
*/
47+
public void runRightIntake(double speed);
48+
3349
/**
3450
* Spins the rollers
3551
*

0 commit comments

Comments
 (0)