-
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
47 changed files
with
1,048 additions
and
422 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package arachne.lib; | ||
|
||
import arachne.lib.scheduler.Schedulable; | ||
import arachne.lib.sequences.ActionConductor; | ||
import arachne.lib.sequences.Actionable; | ||
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard; | ||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; | ||
|
||
public class AutoManager<AutoT extends Enum<?> & Actionable> implements Schedulable | ||
{ | ||
protected static final String DASHBOARD_TAB = "Autonomous"; | ||
protected static final String SELECTION_KEY = "Auto selection"; | ||
|
||
protected final ActionConductor conductor; | ||
protected final SendableChooser<AutoT> autoChooser; | ||
|
||
public AutoManager(AutoT defaultAuto, AutoT[] autos) { | ||
this.conductor = new ActionConductor(); | ||
|
||
this.autoChooser = new SendableChooser<AutoT>(); | ||
this.autoChooser.setDefaultOption(defaultAuto.toString(), defaultAuto); | ||
|
||
for(AutoT auto : autos) { | ||
if(auto != defaultAuto) autoChooser.addOption(auto.toString(), auto); | ||
} | ||
|
||
Shuffleboard.getTab(DASHBOARD_TAB).add(SELECTION_KEY, autoChooser); | ||
} | ||
|
||
public void startAuto() { | ||
startAuto(autoChooser.getSelected()); | ||
} | ||
|
||
public void startAuto(AutoT auto) { | ||
stopAuto(); | ||
conductor.add(auto); | ||
} | ||
|
||
public void stopAuto() { | ||
conductor.interrupt(); | ||
} | ||
|
||
public boolean isRunning() { | ||
return conductor.hasActions(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
conductor.run(); | ||
} | ||
} |
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
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
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
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,37 @@ | ||
package arachne.lib.io.sensors; | ||
|
||
import arachne.lib.io.GettableBoolean; | ||
import arachne.lib.io.SettableBoolean; | ||
import arachne.lib.logging.ArachneLogger; | ||
|
||
public interface BooleanSensor extends GettableBoolean, SettableBoolean, Resettable | ||
{ | ||
public static final class Wrapper implements BooleanSensor { | ||
protected BooleanSensor sensor; | ||
|
||
public Wrapper wrap(BooleanSensor sensor) { | ||
this.sensor = sensor; | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean get() { | ||
if(sensor != null) return sensor.get(); | ||
|
||
ArachneLogger.getInstance().error("Tried to get BooleanSensor wrapper with no contained sensor, returning 0"); | ||
return false; | ||
} | ||
|
||
@Override | ||
public void accept(boolean value) { | ||
if(sensor != null) sensor.accept(value); | ||
else ArachneLogger.getInstance().error("Tried to set BooleanSensor wrapper with no contained sensor"); | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
if(sensor != null) sensor.reset(); | ||
else ArachneLogger.getInstance().error("Tried to reset BooleanSensor wrapper with no contained sensor"); | ||
} | ||
} | ||
} |
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,37 @@ | ||
package arachne.lib.io.sensors; | ||
|
||
import arachne.lib.io.GettableDouble; | ||
import arachne.lib.io.SettableDouble; | ||
import arachne.lib.logging.ArachneLogger; | ||
|
||
public interface DoubleSensor extends GettableDouble, SettableDouble, Resettable | ||
{ | ||
public static final class Wrapper implements DoubleSensor { | ||
protected DoubleSensor sensor; | ||
|
||
public Wrapper wrap(DoubleSensor sensor) { | ||
this.sensor = sensor; | ||
return this; | ||
} | ||
|
||
@Override | ||
public double get() { | ||
if(sensor != null) return sensor.get(); | ||
|
||
ArachneLogger.getInstance().error("Tried to get DoubleSensor wrapper with no contained sensor, returning 0"); | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void accept(double value) { | ||
if(sensor != null) sensor.accept(value); | ||
else ArachneLogger.getInstance().error("Tried to set DoubleSensor wrapper with no contained sensor"); | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
if(sensor != null) sensor.reset(); | ||
else ArachneLogger.getInstance().error("Tried to reset DoubleSensor wrapper with no contained sensor"); | ||
} | ||
} | ||
} |
Oops, something went wrong.