Skip to content

Commit e3da220

Browse files
Also adding the newly-named files as part of the Shooter subsystem breakup.
1 parent 468e7c1 commit e3da220

22 files changed

+1168
-1
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.autonomousroutines;
9+
10+
import org.mayheminc.robot2020.commands.*;
11+
import org.mayheminc.robot2020.commands.DriveStraightOnHeading.DistanceUnits;
12+
13+
import edu.wpi.first.wpilibj2.command.*;
14+
15+
public class DriveStraightOnly extends SequentialCommandGroup {
16+
/**
17+
* Add your docs here.
18+
*/
19+
public DriveStraightOnly() {
20+
21+
addCommands(new DriveZeroGyro(0.0));
22+
23+
addCommands(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 50, 0));
24+
25+
addCommands(new DriveStraightOnHeading(0.3, DistanceUnits.INCHES, 100, 270));
26+
27+
// addCommands(new ShooterSetHoodAbs(Shooter.HOOD_INITIATION_LINE_POSITION));
28+
// addCommands(new DriveStraightOnHeading(0.4, DistanceUnits.INCHES, 100, 0));
29+
30+
}
31+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package org.mayheminc.robot2020.commands;
2+
3+
import org.mayheminc.robot2020.RobotContainer;
4+
5+
// import org.mayheminc.robot2019.Robot;
6+
// import org.mayheminc.robot2019.subsystems.Drive;
7+
8+
// import edu.wpi.first.wpilibj.command.Command;
9+
import edu.wpi.first.wpilibj2.command.CommandBase;
10+
11+
/**
12+
*
13+
*/
14+
public class DriveStraight extends CommandBase {
15+
16+
double m_targetPower;
17+
18+
/**
19+
*
20+
* @param arg_targetPower +/- motor power [-1.0, +1.0]
21+
* @param arg_distance Distance in encoder counts
22+
*/
23+
public DriveStraight(double arg_targetSpeed) {
24+
addRequirements(RobotContainer.drive);
25+
26+
m_targetPower = arg_targetSpeed;
27+
}
28+
29+
// Called just before this Command runs the first time
30+
@Override
31+
public void initialize() {
32+
}
33+
34+
// Called repeatedly when this Command is scheduled to run
35+
@Override
36+
public void execute() {
37+
RobotContainer.drive.speedRacerDrive(m_targetPower, 0, false);
38+
}
39+
40+
// Make this return true when this Command no longer needs to run execute()
41+
@Override
42+
public boolean isFinished() {
43+
return (false);
44+
}
45+
46+
// Called once after isFinished returns true
47+
@Override
48+
public void end(boolean interrupted) {
49+
RobotContainer.drive.stop();
50+
}
51+
52+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
import edu.wpi.first.wpilibj2.command.CommandBase;
12+
13+
public class FeederSet extends CommandBase {
14+
double m_speed;
15+
16+
/**
17+
* Creates a new ShooterSetFeeder.
18+
*/
19+
public FeederSet(double speed) {
20+
// Use addRequirements() here to declare subsystem dependencies.
21+
addRequirements(RobotContainer.feeder);
22+
23+
m_speed = speed;
24+
}
25+
26+
// Called when the command is initially scheduled.
27+
@Override
28+
public void initialize() {
29+
RobotContainer.feeder.setSpeed(m_speed);
30+
}
31+
32+
// Called once the command ends or is interrupted.
33+
@Override
34+
public void end(boolean interrupted) {
35+
36+
RobotContainer.feeder.setSpeed(0.0);
37+
38+
}
39+
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.CommandBase;
13+
14+
public class HoodAdjust extends CommandBase {
15+
16+
double m_adjust;
17+
18+
/**
19+
* Creates a new ShooterAdjustHood.
20+
*/
21+
public HoodAdjust(double adjust) {
22+
// Use addRequirements() here to declare subsystem dependencies.
23+
addRequirements(RobotContainer.hood);
24+
25+
m_adjust = adjust;
26+
}
27+
28+
// Called when the command is initially scheduled.
29+
@Override
30+
public void initialize() {
31+
RobotContainer.hood.setPosition(RobotContainer.hood.getPosition() + m_adjust);
32+
}
33+
34+
// Returns true when the command should end.
35+
@Override
36+
public boolean isFinished() {
37+
return true;
38+
}
39+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.InstantCommand;
13+
14+
public class HoodSetAbs extends InstantCommand {
15+
double m_set;
16+
17+
/**
18+
* Creates a new HoodSetAbs.
19+
*/
20+
public HoodSetAbs(double set) {
21+
// Use addRequirements() here to declare subsystem dependencies.
22+
addRequirements(RobotContainer.hood);
23+
24+
m_set = set;
25+
}
26+
27+
// Called when the command is initially scheduled.
28+
@Override
29+
public void initialize() {
30+
RobotContainer.hood.setPosition(m_set);
31+
}
32+
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.InstantCommand;
13+
14+
public class HoodSetRel extends InstantCommand {
15+
double m_adjust;
16+
17+
/**
18+
* Creates a new ShooterSetHood.
19+
*/
20+
public HoodSetRel(double adjust) {
21+
// Use addRequirements() here to declare subsystem dependencies.
22+
addRequirements(RobotContainer.hood);
23+
24+
m_adjust = adjust;
25+
}
26+
27+
// Called when the command is initially scheduled.
28+
@Override
29+
public void initialize() {
30+
double pos = RobotContainer.hood.getPosition();
31+
RobotContainer.hood.setPosition(pos + m_adjust);
32+
}
33+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.CommandBase;
13+
14+
public class HoodSetVBus extends CommandBase {
15+
double m_power;
16+
17+
/**
18+
* Creates a new ShooterSetHoodVBus.
19+
*/
20+
public HoodSetVBus(double power) {
21+
// Use addRequirements() here to declare subsystem dependencies.
22+
addRequirements(RobotContainer.hood);
23+
m_power = power;
24+
}
25+
26+
// Called when the command is initially scheduled.
27+
@Override
28+
public void initialize() {
29+
RobotContainer.hood.setVBus(m_power);
30+
}
31+
32+
// Called every time the scheduler runs while the command is scheduled.
33+
@Override
34+
public void execute() {
35+
}
36+
37+
// Called once the command ends or is interrupted.
38+
@Override
39+
public void end(boolean interrupted) {
40+
RobotContainer.hood.setVBus(0.0);
41+
}
42+
43+
// Returns true when the command should end.
44+
@Override
45+
public boolean isFinished() {
46+
return false;
47+
}
48+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*----------------------------------------------------------------------------*/
2+
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3+
/* Open Source Software - may be modified and shared by FRC teams. The code */
4+
/* must be accompanied by the FIRST BSD license file in the root directory of */
5+
/* the project. */
6+
/*----------------------------------------------------------------------------*/
7+
8+
package org.mayheminc.robot2020.commands;
9+
10+
import org.mayheminc.robot2020.RobotContainer;
11+
12+
import edu.wpi.first.wpilibj2.command.InstantCommand;
13+
14+
// NOTE: Consider using this command inline, rather than writing a subclass. For more
15+
// information, see:
16+
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
17+
public class HoodZero extends InstantCommand {
18+
public HoodZero() {
19+
// Use addRequirements() here to declare subsystem dependencies.
20+
addRequirements(RobotContainer.hood);
21+
}
22+
23+
// Called when the command is initially scheduled.
24+
@Override
25+
public void initialize() {
26+
RobotContainer.hood.zero();
27+
}
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.mayheminc.robot2020.commands;
2+
3+
// import org.mayheminc.robot2020.Robot;
4+
5+
import edu.wpi.first.wpilibj2.command.CommandBase;
6+
7+
/**
8+
*
9+
*/
10+
public class PrintAutonomousTimeRemaining extends CommandBase {
11+
String Message = "";
12+
public PrintAutonomousTimeRemaining(String msg) {
13+
this.Message = msg;
14+
}
15+
16+
// Called just before this Command runs the first time
17+
@Override
18+
public void initialize() {
19+
// DriverStation.reportError(Message + " At: " + Robot.autonomousTimeRemaining() + "\n", false);
20+
}
21+
22+
// Make this return true when this Command no longer needs to run execute()
23+
@Override
24+
public boolean isFinished() {
25+
return true;
26+
}
27+
}

src/main/java/org/mayheminc/robot2020/commands/ShooterFireWhenReady.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public class ShooterFireWhenReady extends CommandBase {
1818
*/
1919
public ShooterFireWhenReady() {
2020
// Use addRequirements() here to declare subsystem dependencies.
21-
// addRequirements(RobotContainer.shooter);
21+
addRequirements(RobotContainer.shooterWheel);
22+
addRequirements(RobotContainer.feeder);
2223
}
2324

2425
// Called when the command is initially scheduled.

0 commit comments

Comments
 (0)