This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
110 changed files
with
4,762 additions
and
526 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
63 changes: 63 additions & 0 deletions
63
3494_2017_repo/src/org/usfirst/frc/team3494/robot/commands/auto/AngleTurn.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,63 @@ | ||
package org.usfirst.frc.team3494.robot.commands.auto; | ||
|
||
import org.usfirst.frc.team3494.robot.Robot; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
/** | ||
* Turns the robot using the gyro board mounted to the RoboRIO. The angle to | ||
* turn by must be specified in the constructor. | ||
* | ||
* @since 0.0.2 | ||
* @see org.usfirst.frc.team3494.robot.Robot | ||
* @see org.usfirst.frc.team3494.robot.subsystems.Drivetrain | ||
*/ | ||
public class AngleTurn extends Command { | ||
|
||
private double angle; | ||
private static double tolerance = Robot.prefs.getDouble("angle tolerance", 2.5); | ||
|
||
public AngleTurn(double angle) { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.driveTrain); | ||
this.angle = angle; | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
Robot.ahrs.reset(); | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
protected void execute() { | ||
if (!((Robot.ahrs.getAngle() > this.angle - tolerance) && (Robot.ahrs.getAngle() < this.angle + tolerance))) { | ||
System.out.println(this.angle); | ||
if (this.angle > 0) { | ||
Robot.driveTrain.adjustedTankDrive(-0.4, 0.4); | ||
Robot.driveTrain.resetRight(); | ||
return; | ||
} else if (this.angle < 0) { | ||
Robot.driveTrain.adjustedTankDrive(0.4, -0.4); | ||
Robot.driveTrain.resetRight(); | ||
return; | ||
} else { | ||
Robot.driveTrain.adjustedTankDrive(0.4, 0.4); | ||
} | ||
} | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
protected boolean isFinished() { | ||
return ((Robot.ahrs.getAngle() > this.angle - tolerance) && (Robot.ahrs.getAngle() < this.angle + tolerance)); | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
protected void interrupted() { | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
3494_2017_repo/src/org/usfirst/frc/team3494/robot/commands/auto/CartesianTurnDrive.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,68 @@ | ||
package org.usfirst.frc.team3494.robot.commands.auto; | ||
|
||
import org.usfirst.frc.team3494.robot.Robot; | ||
import org.usfirst.frc.team3494.robot.UnitTypes; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
import edu.wpi.first.wpilibj.command.Scheduler; | ||
|
||
/** | ||
* WIP coordinate drive system. | ||
* | ||
* @see org.usfirst.frc.team3494.robot.commands.auto.AngleTurn | ||
* @see org.usfirst.frc.team3494.robot.commands.auto.DistanceDrive | ||
* @since 0.0.2 | ||
*/ | ||
public class CartesianTurnDrive extends Command { | ||
|
||
private double rise; | ||
private double run; | ||
private double hypot; | ||
private double angle; | ||
private boolean isDone = false; | ||
|
||
public CartesianTurnDrive(double rise, double run) { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.driveTrain); | ||
this.rise = rise; | ||
this.run = run; | ||
// angle = inverse tan(rise/run) | ||
this.angle = Math.toDegrees(Math.atan2(rise, run)); | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
Robot.ahrs.reset(); | ||
Robot.driveTrain.resetRight(); | ||
double run2 = this.run * this.run; | ||
double rise2 = this.rise * this.rise; | ||
this.hypot = Math.sqrt(run2 + rise2); | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
protected void execute() { | ||
Scheduler.getInstance().add(new AngleTurn(this.angle)); | ||
Robot.driveTrain.resetRight(); | ||
if (Robot.driveTrain.getRightDistance(UnitTypes.INCHES) > this.hypot) { | ||
Robot.driveTrain.adjustedTankDrive(0.3, 0.3); | ||
} else { | ||
this.isDone = true; | ||
} | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
protected boolean isFinished() { | ||
return this.isDone; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
this.isDone = false; | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
protected void interrupted() { | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
3494_2017_repo/src/org/usfirst/frc/team3494/robot/commands/intake/RunIntake.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,54 @@ | ||
package org.usfirst.frc.team3494.robot.commands.intake; | ||
|
||
import org.usfirst.frc.team3494.robot.Robot; | ||
|
||
import edu.wpi.first.wpilibj.command.Command; | ||
|
||
/** | ||
* Runs the intake. Default command for Intake subsystem. | ||
*/ | ||
public class RunIntake extends Command { | ||
|
||
boolean running = false; | ||
double speed; | ||
|
||
public RunIntake() { | ||
// Use requires() here to declare subsystem dependencies | ||
// eg. requires(chassis); | ||
requires(Robot.intake); | ||
} | ||
|
||
// Called just before this Command runs the first time | ||
protected void initialize() { | ||
} | ||
|
||
// Called repeatedly when this Command is scheduled to run | ||
protected void execute() { | ||
if (Robot.oi.xbox_lt.get()) { | ||
this.speed = 1; | ||
this.running = !this.running; | ||
} else if (Robot.oi.xbox_rt.get()) { | ||
this.speed = -1; | ||
this.running = !this.running; | ||
} | ||
if (running) { | ||
Robot.intake.runIntake(this.speed); | ||
} else { | ||
Robot.intake.stopAll(); | ||
} | ||
} | ||
|
||
// Make this return true when this Command no longer needs to run execute() | ||
protected boolean isFinished() { | ||
return false; | ||
} | ||
|
||
// Called once after isFinished returns true | ||
protected void end() { | ||
} | ||
|
||
// Called when another command which requires one or more of the same | ||
// subsystems is scheduled to run | ||
protected void interrupted() { | ||
} | ||
} |
Oops, something went wrong.