This repository has been archived by the owner on Jan 13, 2025. 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
Driver Station Computer
committed
Dec 14, 2024
1 parent
f7e0feb
commit f6e5efd
Showing
9 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/com/team766/robot/candle_bot/AutonomousModes.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,19 @@ | ||
package com.team766.robot.candle_bot; | ||
|
||
import com.team766.framework.AutonomousMode; | ||
import com.team766.robot.example.procedures.*; | ||
|
||
public class AutonomousModes { | ||
public static final AutonomousMode[] AUTONOMOUS_MODES = | ||
new AutonomousMode[] { | ||
// Add autonomous modes here like this: | ||
// new AutonomousMode("NameOfAutonomousMode", () -> new MyAutonomousProcedure()), | ||
// | ||
// If your autonomous procedure has constructor arguments, you can | ||
// define one or more different autonomous modes with it like this: | ||
// new AutonomousMode("DriveFast", () -> new DriveStraight(1.0)), | ||
// new AutonomousMode("DriveSlow", () -> new DriveStraight(0.4)), | ||
|
||
new AutonomousMode("DoNothing", () -> new DoNothing()), | ||
}; | ||
} |
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,46 @@ | ||
package com.team766.robot.candle_bot; | ||
|
||
import com.team766.framework.Context; | ||
import com.team766.framework.Procedure; | ||
import com.team766.hal.JoystickReader; | ||
import com.team766.hal.RobotProvider; | ||
import com.team766.logging.Category; | ||
import com.team766.robot.example.procedures.*; | ||
|
||
/** | ||
* This class is the glue that binds the controls on the physical operator | ||
* interface to the code that allow control of the robot. | ||
*/ | ||
public class OI extends Procedure { | ||
private JoystickReader joystick0; | ||
private JoystickReader joystick1; | ||
private JoystickReader joystick2; | ||
|
||
public OI() { | ||
loggerCategory = Category.OPERATOR_INTERFACE; | ||
|
||
joystick0 = RobotProvider.instance.getJoystick(0); | ||
joystick1 = RobotProvider.instance.getJoystick(1); | ||
joystick2 = RobotProvider.instance.getJoystick(2); | ||
} | ||
|
||
public void run(final Context context) { | ||
while (true) { | ||
// wait for driver station data (and refresh it using the WPILib APIs) | ||
context.waitFor(() -> RobotProvider.instance.hasNewDriverStationData()); | ||
RobotProvider.instance.refreshDriverStationData(); | ||
|
||
if(joystick0.getButtonPressed(1)){ | ||
Robot.candle.LED(); | ||
} | ||
|
||
if(joystick0.getButtonPressed(2)){ | ||
Robot.candle.stop(); | ||
|
||
} | ||
|
||
// Add driver controls here - make sure to take/release ownership | ||
// of mechanisms when appropriate. | ||
} | ||
} | ||
} |
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 for robot-specific code. Copy this example package for each robot, | ||
eg reva, revb, burrobotprime, gatorade, etc. | ||
|
||
Each package will contain the following: | ||
* `Robot.java` - contains static references to that robot's mechanisms. | ||
* `OI.java` - procedure for reading joystick input, controlling the robot via the Operator Interface. | ||
* `AutonomousModes.java` - contains array of autonomous procedures for this robot. | ||
* `mechanisms` - sub-package containing mechanisms for this robot. | ||
* `procedures` - sub-package containing procedures for this robot. | ||
|
||
Once you've created the appropriate package for this robot, remember to update | ||
`com.team766.hal.GenericRobotMain` to reference this code. This will typically involve | ||
updating the following imports: | ||
|
||
import com.team766.robot.example.AutonomousModes; | ||
import com.team766.robot.example.OI; | ||
import com.team766.robot.example.Robot; | ||
|
||
By organizing your code with a sub-package for each robot, with the exception of `GenericRobotMain`, | ||
the code for each of our robots should be able to co-exist across branches. | ||
|
||
NOTE: **You should only update `GenericRobotMain` on the branch that's specific to your robot.** |
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,28 @@ | ||
package com.team766.robot.candle_bot; | ||
|
||
import com.team766.framework.AutonomousMode; | ||
import com.team766.framework.Procedure; | ||
import com.team766.hal.RobotConfigurator; | ||
import com.team766.robot.candle_bot.mechanisms.candle; | ||
import com.team766.robot.example.mechanisms.*; | ||
|
||
public class Robot implements RobotConfigurator { | ||
public static candle candle; | ||
// Declare mechanisms (as static fields) here | ||
|
||
@Override | ||
public void initializeMechanisms() { | ||
candle = new candle(); | ||
// Initialize mechanisms here | ||
} | ||
|
||
@Override | ||
public Procedure createOI() { | ||
return new OI(); | ||
} | ||
|
||
@Override | ||
public AutonomousMode[] getAutonomousModes() { | ||
return AutonomousModes.AUTONOMOUS_MODES; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/team766/robot/candle_bot/mechanisms/ExampleMechanism.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,23 @@ | ||
package com.team766.robot.candle_bot.mechanisms; | ||
|
||
import com.team766.framework.Mechanism; | ||
import com.team766.hal.MotorController; | ||
import com.team766.hal.RobotProvider; | ||
|
||
public class ExampleMechanism extends Mechanism { | ||
private MotorController leftMotor; | ||
private MotorController rightMotor; | ||
|
||
public ExampleMechanism() { | ||
leftMotor = RobotProvider.instance.getMotor("exampleMechanism.leftMotor"); | ||
rightMotor = RobotProvider.instance.getMotor("exampleMechanism.rightMotor"); | ||
} | ||
|
||
public void setMotorPower(final double leftPower, final double rightPower) { | ||
checkContextOwnership(); | ||
|
||
leftMotor.set(leftPower); | ||
rightMotor.set(rightPower); | ||
} | ||
} | ||
|
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 @@ | ||
Add mechanism classes here |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/team766/robot/candle_bot/mechanisms/candle.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,21 @@ | ||
package com.team766.robot.candle_bot.mechanisms; | ||
import com.ctre.phoenix.led.CANdle; | ||
import com.team766.framework.Mechanism; | ||
|
||
|
||
public class candle extends Mechanism { | ||
private CANdle candle; | ||
public candle() { | ||
candle = new CANdle(0); | ||
|
||
} | ||
public void LED(){ | ||
candle.setLEDs(179, 105, 2); | ||
} | ||
|
||
public void stop(){ | ||
candle.setLEDs(0,0,0); | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/team766/robot/candle_bot/procedures/DoNothing.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,9 @@ | ||
package com.team766.robot.candle_bot.procedures; | ||
|
||
import com.team766.framework.Context; | ||
import com.team766.framework.Procedure; | ||
|
||
public class DoNothing extends Procedure { | ||
|
||
public void run(final Context context) {} | ||
} |
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 @@ | ||
Add procedure classes here |