-
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.
Merge pull request #64 from 2202Programming/dev
Post Season 2017
- Loading branch information
Showing
21 changed files
with
338 additions
and
93 deletions.
There are no files selected for viewing
Binary file not shown.
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,52 @@ | ||
package auto.commands; | ||
|
||
import com.kauailabs.navx.frc.AHRS; | ||
|
||
import PID.PIDController; | ||
import auto.ICommand; | ||
import auto.IStopCondition; | ||
import drive.DriveControl; | ||
import drive.IDrive; | ||
import input.SensorController; | ||
import robot.Global; | ||
|
||
public class BangBangTurnCommand implements ICommand { | ||
|
||
private double power, degreesToTurn; | ||
private IDrive drive; | ||
private AHRS navx; | ||
|
||
public BangBangTurnCommand(double degreesToTurn, double power) { | ||
this.degreesToTurn=degreesToTurn; | ||
this.power=power; | ||
|
||
} | ||
|
||
public void init() { | ||
//set the objects and set external control | ||
drive=(IDrive)Global.controlObjects.get("DRIVE"); | ||
drive.setDriveControl(DriveControl.EXTERNAL_CONTROL); | ||
navx=(AHRS)SensorController.getInstance().getSensor("NAVX"); | ||
//reset navx so we turn degrees from when this command is called | ||
navx.reset(); | ||
} | ||
|
||
public boolean run() { | ||
double angle=navx.getAngle(); | ||
if (angle>degreesToTurn) {//turn in the right direction | ||
drive.setLeftMotors(-power); | ||
drive.setRightMotors(power); | ||
} | ||
else { | ||
drive.setLeftMotors(power); | ||
drive.setRightMotors(-power); | ||
} | ||
//If we have turned more positive or more negative than our angle, we are done turning. Otherwise, keep going. | ||
return Math.abs(angle)<Math.abs(degreesToTurn); | ||
} | ||
|
||
public void stop() { | ||
drive.setDriveControl(DriveControl.DRIVE_CONTROLLED); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package auto.commands; | ||
|
||
import auto.ICommand; | ||
import babbage.Shooter; | ||
import robot.Global; | ||
|
||
public class ShootCommand implements ICommand { | ||
private Shooter shooter; | ||
@Override | ||
public void init() { | ||
shooter = (Shooter) Global.controlObjects.get("SHOOTER"); | ||
shooter.setAutoShoot(true); | ||
} | ||
|
||
@Override | ||
public boolean run() { | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
shooter.setAutoShoot(false); | ||
} | ||
|
||
} |
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,22 @@ | ||
package auto.stopConditions; | ||
|
||
import auto.IStopCondition; | ||
|
||
public class AndStopCondition implements IStopCondition { | ||
IStopCondition first; | ||
IStopCondition second; | ||
|
||
public AndStopCondition(IStopCondition firstCondition, IStopCondition secondCondition) { | ||
first = firstCondition; | ||
second = secondCondition; | ||
} | ||
|
||
public void init() { | ||
first.init(); | ||
second.init(); | ||
} | ||
|
||
public boolean stopNow() { | ||
return first.stopNow() && second.stopNow(); | ||
} | ||
} |
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,22 @@ | ||
package auto.stopConditions; | ||
|
||
import auto.IStopCondition; | ||
|
||
public class OrStopCondition implements IStopCondition { | ||
IStopCondition first; | ||
IStopCondition second; | ||
|
||
public OrStopCondition(IStopCondition firstCondition, IStopCondition secondCondition) { | ||
first = firstCondition; | ||
second = secondCondition; | ||
} | ||
|
||
public void init() { | ||
first.init(); | ||
second.init(); | ||
} | ||
|
||
public boolean stopNow() { | ||
return first.stopNow() || second.stopNow(); | ||
} | ||
} |
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
Oops, something went wrong.