-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from gwhs/ARMS2
Arms2
- Loading branch information
Showing
11 changed files
with
595 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/frc/robot/commands/Arm/SpinNoteContainerMotor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.Arm; | ||
import frc.robot.subsystems.ArmSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class SpinNoteContainerMotor extends Command { | ||
|
||
private double velocity; | ||
private double acceleration; | ||
|
||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final ArmSubsystem armSubsystem; | ||
|
||
public SpinNoteContainerMotor(ArmSubsystem armSubsystem, double velocity, double acceleration) { | ||
this.armSubsystem = armSubsystem; | ||
this.velocity = velocity; | ||
this.acceleration = acceleration; | ||
addRequirements(armSubsystem); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
armSubsystem.spinPizzaBoxMotor(velocity, acceleration); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return true; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/frc/robot/commands/Arm/StopNoteContainerMotor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) FIRST and other WPILib contributors. | ||
// Open Source Software; you can modify and/or share it under the terms of | ||
// the WPILib BSD license file in the root directory of this project. | ||
|
||
package frc.robot.commands.Arm; | ||
import frc.robot.subsystems.ArmSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class StopNoteContainerMotor extends Command { | ||
|
||
|
||
|
||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final ArmSubsystem armSubsystem; | ||
|
||
public StopNoteContainerMotor(ArmSubsystem armSubsystem) { | ||
this.armSubsystem = armSubsystem; | ||
addRequirements(armSubsystem); | ||
} | ||
|
||
// Called when the command is initially scheduled. | ||
@Override | ||
public void initialize() {} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
armSubsystem.stopPizzaBoxMotor(); | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) {} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package frc.robot.commands.Arm; | ||
import frc.robot.subsystems.ArmSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
|
||
public class SwingBack extends Command{ | ||
|
||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final ArmSubsystem armSubsystem; | ||
private double velocity; | ||
private double acceleration; | ||
private double motorAng; | ||
private double tolerance; | ||
|
||
|
||
// Called when the command is initially scheduled. | ||
|
||
public SwingBack( ArmSubsystem armSubsystem, double velocity, | ||
double acceleration, double tolerance) { | ||
this.armSubsystem = armSubsystem; | ||
this.velocity = velocity; | ||
this.acceleration = acceleration; | ||
this.tolerance = tolerance; | ||
addRequirements(armSubsystem); | ||
} | ||
public void initialize() { | ||
armSubsystem.setAngle(0, velocity, acceleration); | ||
|
||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
@Override | ||
public void execute() { | ||
|
||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
armSubsystem.stopArmMotor(); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
motorAng = armSubsystem.encoderGetAngle(); | ||
return Math.abs(motorAng) < tolerance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package frc.robot.commands.Arm; | ||
import frc.robot.subsystems.ArmSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
|
||
public class SwingForward extends Command{ | ||
|
||
private double motorAng; | ||
private double angle; | ||
private double velocity; | ||
private double acceleration; | ||
private double tolerance; | ||
|
||
|
||
|
||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final ArmSubsystem armSubsystem; | ||
// Called when the command is initially scheduled. | ||
|
||
|
||
public SwingForward(ArmSubsystem armSubsystem, double angle, double velocity, double acceleration, double tolerance) | ||
{ | ||
this.armSubsystem = armSubsystem; | ||
this.angle = angle; | ||
this.velocity = velocity; | ||
this.acceleration = acceleration; | ||
this.tolerance = tolerance; | ||
addRequirements(armSubsystem); | ||
} | ||
public void initialize() { | ||
armSubsystem.setAngle(angle, velocity, acceleration); | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
|
||
@Override | ||
public void execute() {} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
armSubsystem.stopArmMotor(); | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
motorAng = armSubsystem.encoderGetAngle(); | ||
return Math.abs(motorAng - angle) < tolerance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package frc.robot.commands.Arm; | ||
import frc.robot.subsystems.ArmSubsystem; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
|
||
public class SwingServo extends Command{ | ||
|
||
@SuppressWarnings({"PMD.UnusedPrivateField", "PMD.SingularField"}) | ||
private final ArmSubsystem armSubsystem; | ||
private double targetAng; | ||
// Called when the command is initially scheduled. | ||
|
||
|
||
public SwingServo(ArmSubsystem armSubsystem) | ||
{ | ||
this.armSubsystem = armSubsystem; | ||
addRequirements(armSubsystem); | ||
} | ||
public void initialize() { | ||
if(Math.abs(armSubsystem.getServoAngle() - 180) < .25) { | ||
targetAng = 0; | ||
armSubsystem.setServoAngle(0); | ||
} else { | ||
targetAng = 180; | ||
armSubsystem.setServoAngle(180); | ||
} | ||
} | ||
|
||
// Called every time the scheduler runs while the command is scheduled. | ||
|
||
@Override | ||
public void execute() { | ||
} | ||
|
||
// Called once the command ends or is interrupted. | ||
@Override | ||
public void end(boolean interrupted) { | ||
} | ||
|
||
// Returns true when the command should end. | ||
@Override | ||
public boolean isFinished() { | ||
double motorAng = armSubsystem.getServoAngle(); | ||
|
||
return Math.abs(motorAng - targetAng) < .25; | ||
} | ||
} |
Oops, something went wrong.