Quote:
Originally Posted by SoftwareBug2.0
This still seems linear to me. All it's doing is waiting for some condition and deciding to go on to the next step or continue waiting.
What I was trying to ask is if you could do something like:
Code:
if goal is hot:
fire
drive forward
else:
turn
fire
|
This is one of the things I want to investigate during the off season. This is my untested theory so take it with a grain of salt.
TwoBallTwoHotGoalCommand
Code:
HotGoalFinder finder = new HotGoalFinder();
addSequential(new DriveStraightCommand(0.85, 240));
addSequential(finder, 0.5);
addSequential(new DecisionCommand (finder, new TurnandShootSeries(), new ShootCommand()));
addSequential(new DeployArmCommand(Arm.DEPLOY, RobotMap.pickupPower));
addSequential(new DriveStraightCommand(-0.85, 240));
addSequential(new WaitCommand(1));
addSequential(new DriveStraightCommand(0.85, 240));
addSequential(finder, 0.5);
addSequential(new HotGoalDecision(finder, new TurnandShootSeries(), new ShootCommand()));
HotGoalDecision
Code:
public class DecisionCommand extends Command {
public DecisionCommand (IProvidesDecision decision, Command trueCommand, Command falseCommand) {}
public void initialize() {
if (decision.getValue()) {
trueCommand.initialize();
} else {
falseCommand.initialize());
}
}
public void execute() {
if (decision.getValue()) {
trueCommand.execute();
} else {
falseCommand.execute());
}
etc...
}
IProvidesDescision
Code:
public interface IProvidesDecision {
boolean getValue();
}