Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
import com.ctre.phoenix6.signals.InvertedValue;
import com.ctre.phoenix6.signals.MotorAlignmentValue;
import first.robot.simulation.DrivetrainSim;
import first.robot.simulation.FuelSim;
import first.robot.simulation.SingleFlywheelSim;
import org.wpilib.drive.DifferentialDrive;
import org.wpilib.framework.OpModeRobot;
import org.wpilib.hardware.imu.OnboardIMU;
import org.wpilib.hardware.imu.OnboardIMU.MountOrientation;

// [FullRobot]
// [RobotWithSimPart1]
// [RobotTop]
/**
Expand Down Expand Up @@ -56,12 +58,19 @@ public class Robot extends OpModeRobot {
// [/DrivetrainSim]
// [/RobotWithSimPart1]

// [AdditionalMotors]
public TalonFX intakeLauncher = new TalonFX(4, CANBus.systemcore(0));
public TalonFX feeder = new TalonFX(5, CANBus.systemcore(0));
// [/AdditionalMotors]

// [IntakeLauncherSim]
private SingleFlywheelSim intakeLauncherSim = SingleFlywheelSim.forIntakeLauncher(intakeLauncher);
// [/IntakeLauncherSim]
// [FeederSim]
private SingleFlywheelSim feederSim = SingleFlywheelSim.forFeeder(feeder);

// [/FeederSim]

// [RobotWithSimPart2]
// [AllConfigs]
/**
Expand Down Expand Up @@ -99,8 +108,15 @@ public Robot() {
public void simulationPeriodic() {
drivetrainSim.periodic();
// [/DriveSimPeriodic]
// [MotorSimPeriodic]
intakeLauncherSim.periodic();
feederSim.periodic();
// [/MotorSimPeriodic]

// [FuelSimPeriodic]
FuelSim.periodic();
// [/FuelSimPeriodic]
}
// [/RobotWithSimPart2]
// [/FullRobot]
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void start() {
autoTimer.restart(); // Reset the timer to zero at the start of auto

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's autoTimer here but it's timer in the Rev solution. Should probably pick one and use it throughout

}

// [SimpleAuto]
/*
* This method runs periodically, using the same period as the Robot instance.
*
Expand All @@ -39,4 +40,5 @@ public void periodic() {
robot.drivetrain.arcadeDrive(0.5, 0.0); // Drive forward at half speed with no rotation
}
}
// [/SimpleAuto]
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,33 @@ public void periodic() {
// [/DriveSimPeriodic]
// [/FullDrivetrain]

// [launchFuel]
if (xboxController.getRightBumperButton()) {
// shoot
// launch
robot.intakeLauncher.setThrottle(0.9);
robot.feeder.setThrottle(0.75);

// [/launchFuel]
// [intakeFuel]
} else if (xboxController.getLeftBumperButton()) {
// intake
robot.intakeLauncher.setThrottle(0.8);
robot.feeder.setThrottle(-1.0);

// [/intakeFuel]
// [outakeFuel]
} else if (xboxController.getAButton()) {
// outake
robot.intakeLauncher.setThrottle(-0.8);
robot.feeder.setThrottle(1.0);

// [/outakeFuel]
// [stopMotors]
} else {
// stop
robot.intakeLauncher.setThrottle(0.0);
robot.feeder.setThrottle(0.0);
}
// [/stopMotors]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private enum Mode {
static Supplier<Pose2d> robotPoseSupplier = () -> Pose2d.kZero;

/** Updates the fuel sim. */
public static void update() {
public static void periodic() {
updateMode();
updateVisualization();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.wpilib.hardware.imu.OnboardIMU;
import org.wpilib.hardware.imu.OnboardIMU.MountOrientation;

// [FullRobot]
// [RobotWithSimPart1]
// [RobotTop]
/**
Expand Down Expand Up @@ -53,12 +54,19 @@ public class Robot extends OpModeRobot {
// [/DrivetrainSim]
// [/RobotWithSimPart1]

// [AdditionalMotors]
public SparkMax intakeLauncher = new SparkMax(0, 4, MotorType.kBrushless);
public SparkMax feeder = new SparkMax(0, 5, MotorType.kBrushless);
// [/AdditionalMotors]

// [IntakeLauncherSim]
private SingleFlywheelSim intakeLauncherSim = SingleFlywheelSim.forIntakeLauncher(intakeLauncher);
// [/IntakeLauncherSim]
// [FeederSim]
private SingleFlywheelSim feederSim = SingleFlywheelSim.forFeeder(feeder);

// [/FeederSim]

// [RobotWithSimPart2]
// [AllConfigs]
/**
Expand Down Expand Up @@ -101,8 +109,14 @@ public void simulationPeriodic() {
drivetrainSim.periodic();
// [/DriveSimPeriodic]
intakeLauncherSim.periodic();
// [MotorSimPeriodic]
feederSim.periodic();
FuelSim.update();
// [/MotorSimPeriodic]

// [FuelSimPeriodic]
FuelSim.periodic();
// [/FuelSimPeriodic]
}
// [/RobotWithSimPart2]
}
// [/FullRobot]
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class MyAuto extends PeriodicOpMode {
private final Robot robot;
private Timer timer = new Timer();

/** The Robot instance is passed into the opmode via the constructor. */
public MyAuto(Robot robot) {
this.robot = robot;
}
Expand All @@ -24,6 +25,13 @@ public void start() {
timer.restart();
}

// [SimpleAuto]
/*
* This method runs periodically, using the same period as the Robot instance.
*
* Additional periodic methods may be configured with addPeriodic(),
* which can have periods that differ from the main Robot instance.
*/
@Override
public void periodic() {
if (timer.hasElapsed(4)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (timer.hasElapsed(4)) {
if (timer.hasElapsed(4)) { // Drive for 4 seconds after the start of auto

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment was in the CTRE but not REV. I thought it's a good comment to have on both

Expand All @@ -32,4 +40,5 @@ public void periodic() {
robot.drivetrain.arcadeDrive(0.5, 0.0); // Drive forward at half speed with no rotation
}
}
// [/SimpleAuto]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,33 @@ public void periodic() {
// [/DriveSimPeriodic]
// [/FullDrivetrain]

// [launchFuel]
if (xboxController.getRightBumperButton()) {
// shoot
// launch
robot.intakeLauncher.setThrottle(0.9);
robot.feeder.setThrottle(0.75);

// [/launchFuel]
// [intakeFuel]
} else if (xboxController.getLeftBumperButton()) {
// intake
robot.intakeLauncher.setThrottle(0.8);
robot.feeder.setThrottle(-1.0);

// [/intakeFuel]
// [outakeFuel]
} else if (xboxController.getAButton()) {
// outtake
robot.intakeLauncher.setThrottle(-0.8);
robot.feeder.setThrottle(1.0);

// [/outakeFuel]
// [stopMotors]
} else {
// stop
robot.intakeLauncher.setThrottle(0.0);
robot.feeder.setThrottle(0.0);
}
// [/stopMotors]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private enum Mode {
static Supplier<Pose2d> robotPoseSupplier = () -> Pose2d.kZero;

/** Updates the fuel sim. */
public static void update() {
public static void periodic() {
updateMode();
updateVisualization();
}
Expand Down
Binary file added public/learning-course/stage1/stage1a/3dField.mp4
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 8 additions & 8 deletions src/config/sidebarConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ export const sidebarSections: Record<string, SidebarSection[]> = {
label: 'Drivetrain Simulation',
slug: 'learning-course/stage1/stage1a/drivetrain-sim',
},
// {
// label: 'TBD',
// slug: 'stage-1a-commands/the-command-body',
// },
// {
// label: 'TBD',
// slug: 'stage-1a-commands/commands-and-mechanisms',
// },
{
label: 'Simple Auto',
slug: 'learning-course/stage1/stage1a/simple-auto',
},
{
label: 'Additional Motors',
slug: 'learning-course/stage1/stage1a/kitbot-additional-motors',
},
],
},
{
Expand Down
Loading