-
Notifications
You must be signed in to change notification settings - Fork 9
Started work on autons #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0718d6
Added a "test" auton
MalSwint 91985b3
Merge branch 'Team100:main' into main
MalSwint 751c6d1
Added a new auton
MalSwint daabbac
Added Slow Bump Zone constraint to the auton
MalSwint 548a765
Added a stop to score within auton 1
MalSwint 1bfffa6
Started integrating intake into auton 1
MalSwint 4435b3b
Auton 1 now spins the intake
MalSwint File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
139 changes: 139 additions & 0 deletions
139
comp/src/main/java/org/team100/frc2026/auton/Auton1.java
This file contains hidden or 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,139 @@ | ||
| package org.team100.frc2026.auton; | ||
|
|
||
| import static edu.wpi.first.wpilibj2.command.Commands.parallel; | ||
| import static edu.wpi.first.wpilibj2.command.Commands.sequence; | ||
| import static edu.wpi.first.wpilibj2.command.Commands.waitSeconds; | ||
|
|
||
| import java.util.List; | ||
| import java.util.ArrayList; | ||
|
|
||
| import org.team100.frc2026.Intake; | ||
| import org.team100.frc2026.auton.BumpZones; | ||
| import org.team100.frc2026.robot.Machinery; | ||
| import org.team100.lib.config.AnnotatedCommand; | ||
| import org.team100.lib.controller.se2.ControllerSE2; | ||
| import org.team100.lib.geometry.DirectionSE2; | ||
| import org.team100.lib.geometry.WaypointSE2; | ||
| import org.team100.lib.logging.LoggerFactory; | ||
| import org.team100.lib.subsystems.se2.commands.DriveWithTrajectoryFunction; | ||
| import org.team100.lib.subsystems.swerve.kinodynamics.SwerveKinodynamics; | ||
| import org.team100.lib.trajectory.TrajectorySE2; | ||
| import org.team100.lib.trajectory.TrajectorySE2Factory; | ||
| import org.team100.lib.trajectory.TrajectorySE2Planner; | ||
| import org.team100.lib.trajectory.constraint.TimingConstraint; | ||
| import org.team100.lib.trajectory.constraint.TimingConstraintFactory; | ||
| import org.team100.lib.trajectory.constraint.VelocityLimitRegionConstraint; | ||
| import org.team100.lib.trajectory.path.PathSE2Factory; | ||
|
|
||
| import edu.wpi.first.math.geometry.Pose2d; | ||
| import edu.wpi.first.math.geometry.Rotation2d; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
|
|
||
| /** An example of a simple sequence */ | ||
| public class Auton1 implements AnnotatedCommand { | ||
| private final LoggerFactory log; | ||
| private final ControllerSE2 controller; | ||
| private final Machinery machinery; | ||
| private final List<TimingConstraint> constraints; | ||
| private final TrajectorySE2Factory trajectoryFactory; | ||
| private final PathSE2Factory pathFactory; | ||
| private final TrajectorySE2Planner planner; | ||
|
|
||
| public Auton1( | ||
| LoggerFactory parent, | ||
| SwerveKinodynamics kinodynamics, | ||
| ControllerSE2 controller, | ||
| Machinery machinery) { | ||
| log = parent.name(name()); | ||
| this.controller = controller; | ||
| this.machinery = machinery; | ||
| constraints = new TimingConstraintFactory(kinodynamics).auto(log.type(this)); | ||
| // In meters/second | ||
| double maxBumpVelocity = 1; | ||
| List<TimingConstraint> new_constraints = new ArrayList<>(constraints); | ||
|
|
||
| // create a new VelocityRegionContstraint `slow_bu mp_zone` | ||
| VelocityLimitRegionConstraint slow_bump_zone = new VelocityLimitRegionConstraint(log, BumpZones.BLUE_BUMP_LEFT, maxBumpVelocity); | ||
| new_constraints.add(slow_bump_zone); | ||
| // constraints.add(slow_bump_zone); | ||
| trajectoryFactory = new TrajectorySE2Factory(new_constraints); | ||
| pathFactory = new PathSE2Factory(); | ||
| planner = new TrajectorySE2Planner(pathFactory, trajectoryFactory); | ||
| } | ||
|
|
||
| @Override | ||
| public String name() { | ||
| return "Auton 1"; | ||
| } | ||
|
|
||
| TrajectorySE2 t1(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(1, 0, 0), 1), | ||
| new WaypointSE2(AutonPositions.ABOVE_BALL_FIELD, | ||
| new DirectionSE2(1, 1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| TrajectorySE2 t2(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(0, -1, 0), 1), | ||
| new WaypointSE2(AutonPositions.MIDDLE_BALL_FIELD, | ||
| new DirectionSE2(0, -1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| TrajectorySE2 t3(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(-1, 1, 0), 1), | ||
| new WaypointSE2(StartingPositions.LEFT_BUMP, | ||
| new DirectionSE2(-1, 0, 0), 1), | ||
| new WaypointSE2(AutonPositions.SHOOT_LEFT, | ||
| new DirectionSE2(-1, -1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| TrajectorySE2 t4(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(-1, -1, 0), 1), | ||
| new WaypointSE2(AutonPositions.CLIMB_LEFT, | ||
| new DirectionSE2(-1, -1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| @Override | ||
| public Command command() { | ||
| DriveWithTrajectoryFunction n1 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t1); | ||
| DriveWithTrajectoryFunction n2 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t2); | ||
| DriveWithTrajectoryFunction n3 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t3); | ||
| DriveWithTrajectoryFunction n4 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t4); | ||
| return sequence( | ||
| n1.until(n1::isDone), | ||
| waitSeconds(1), | ||
| parallel( | ||
| n2, | ||
| machinery.m_intake.intake() | ||
| ).until(n2::isDone), | ||
| waitSeconds(1), | ||
| n3.until(n3::isDone), | ||
| waitSeconds(1), | ||
| n4.until(n4::isDone)); | ||
| } | ||
|
|
||
| @Override | ||
| public Pose2d start() { | ||
| return StartingPositions.LEFT_BUMP; | ||
| } | ||
|
|
||
| } |
19 changes: 19 additions & 0 deletions
19
comp/src/main/java/org/team100/frc2026/auton/AutonPositions.java
This file contains hidden or 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 org.team100.frc2026.auton; | ||
|
|
||
| import edu.wpi.first.math.geometry.Pose2d; | ||
| import edu.wpi.first.math.geometry.Rotation2d; | ||
|
|
||
| /** | ||
| * Areas that might be useful for autons | ||
| */ | ||
| public class AutonPositions { | ||
| public static final Pose2d ABOVE_BALL_FIELD = new Pose2d(7.75, 7, Rotation2d.kCW_90deg); | ||
| public static final Pose2d MIDDLE_BALL_FIELD = new Pose2d(7.75, 4, Rotation2d.kCW_90deg); | ||
| public static final Pose2d BELOW_BALL_FIELD = new Pose2d(7.75, 1, Rotation2d.kCW_90deg); | ||
|
|
||
| public static final Pose2d CLIMB_LEFT = new Pose2d(1.175, 4.25, new Rotation2d(-135 * (Math.PI / 180))); | ||
| public static final Pose2d CLIMB_RIGHT = new Pose2d(1.175, 3.1, new Rotation2d(135 * (Math.PI / 180))); | ||
|
|
||
| public static final Pose2d SHOOT_LEFT = new Pose2d(2.3, 5.1, new Rotation2d(-35 * (Math.PI / 180))); | ||
| public static final Pose2d SHOOT_RIGHT = new Pose2d(2.3, 2.7, new Rotation2d(35 * (Math.PI / 180))); | ||
| } | ||
110 changes: 110 additions & 0 deletions
110
comp/src/main/java/org/team100/frc2026/auton/AutonTest.java
This file contains hidden or 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,110 @@ | ||
| package org.team100.frc2026.auton; | ||
|
|
||
| import static edu.wpi.first.wpilibj2.command.Commands.sequence; | ||
| import static edu.wpi.first.wpilibj2.command.Commands.waitSeconds; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.team100.frc2026.robot.Machinery; | ||
| import org.team100.lib.config.AnnotatedCommand; | ||
| import org.team100.lib.controller.se2.ControllerSE2; | ||
| import org.team100.lib.geometry.DirectionSE2; | ||
| import org.team100.lib.geometry.WaypointSE2; | ||
| import org.team100.lib.logging.LoggerFactory; | ||
| import org.team100.lib.subsystems.se2.commands.DriveWithTrajectoryFunction; | ||
| import org.team100.lib.subsystems.swerve.kinodynamics.SwerveKinodynamics; | ||
| import org.team100.lib.trajectory.TrajectorySE2; | ||
| import org.team100.lib.trajectory.TrajectorySE2Factory; | ||
| import org.team100.lib.trajectory.TrajectorySE2Planner; | ||
| import org.team100.lib.trajectory.constraint.TimingConstraint; | ||
| import org.team100.lib.trajectory.constraint.TimingConstraintFactory; | ||
| import org.team100.lib.trajectory.path.PathSE2Factory; | ||
|
|
||
| import edu.wpi.first.math.geometry.Pose2d; | ||
| import edu.wpi.first.math.geometry.Rotation2d; | ||
| import edu.wpi.first.wpilibj2.command.Command; | ||
|
|
||
| /** An example of a simple sequence */ | ||
| public class AutonTest implements AnnotatedCommand { | ||
| private final LoggerFactory log; | ||
| private final ControllerSE2 controller; | ||
| private final Machinery machinery; | ||
| private final List<TimingConstraint> constraints; | ||
| private final TrajectorySE2Factory trajectoryFactory; | ||
| private final PathSE2Factory pathFactory; | ||
| private final TrajectorySE2Planner planner; | ||
|
|
||
| public AutonTest( | ||
| LoggerFactory parent, | ||
| SwerveKinodynamics kinodynamics, | ||
| ControllerSE2 controller, | ||
| Machinery machinery) { | ||
| log = parent.name(name()); | ||
| this.controller = controller; | ||
| this.machinery = machinery; | ||
| constraints = new TimingConstraintFactory(kinodynamics).auto(log.type(this)); | ||
| trajectoryFactory = new TrajectorySE2Factory(constraints); | ||
| pathFactory = new PathSE2Factory(); | ||
| planner = new TrajectorySE2Planner(pathFactory, trajectoryFactory); | ||
| } | ||
|
|
||
| @Override | ||
| public String name() { | ||
| return "Auton Test"; | ||
| } | ||
|
|
||
| TrajectorySE2 t1(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(-1, 0, 0), 1), | ||
| new WaypointSE2(new Pose2d(2, 4, Rotation2d.kZero), | ||
| new DirectionSE2(-1, 1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| TrajectorySE2 t2(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(1, 1, 0), 1), | ||
| new WaypointSE2(AutonPositions.ABOVE_BALL_FIELD, | ||
| new DirectionSE2(1, 1, 0), 1), | ||
| new WaypointSE2(AutonPositions.BELOW_BALL_FIELD, | ||
| new DirectionSE2(0, -1, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| // go back where we started. | ||
| TrajectorySE2 t3(Pose2d startingPose) { | ||
| List<WaypointSE2> waypoints = List.of( | ||
| new WaypointSE2(startingPose, | ||
| new DirectionSE2(0, 1, 0), 1), | ||
| new WaypointSE2(StartingPositions.RIGHT_BUMP, | ||
| new DirectionSE2(-1, 0, 0), 1)); | ||
| return planner.restToRest(waypoints); | ||
| } | ||
|
|
||
| @Override | ||
| public Command command() { | ||
| DriveWithTrajectoryFunction n1 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t1); | ||
| DriveWithTrajectoryFunction n2 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t2); | ||
| DriveWithTrajectoryFunction n3 = new DriveWithTrajectoryFunction( | ||
| log, machinery.m_drive, controller, | ||
| machinery.m_trajectoryViz, this::t3); | ||
| return sequence( | ||
| n1.until(n1::isDone), | ||
| waitSeconds(1), | ||
| n2.until(n2::isDone), | ||
| waitSeconds(1), | ||
| n3.until(n3::isDone)); | ||
| } | ||
|
|
||
| @Override | ||
| public Pose2d start() { | ||
| return StartingPositions.RIGHT_BUMP; | ||
| } | ||
|
|
||
| } |
31 changes: 31 additions & 0 deletions
31
comp/src/main/java/org/team100/frc2026/auton/BumpZones.java
This file contains hidden or 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,31 @@ | ||
| package org.team100.frc2026.auton; | ||
|
|
||
| import edu.wpi.first.math.geometry.Rectangle2d; | ||
| import edu.wpi.first.math.geometry.Translation2d; | ||
|
|
||
| public class BumpZones { | ||
| public static final Rectangle2d BLUE_BUMP_LEFT = | ||
| new Rectangle2d( | ||
| new Translation2d(5.2, 6.43), | ||
| new Translation2d(4.1, 4.6) | ||
| ); | ||
|
|
||
| public static final Rectangle2d BLUE_BUMP_RIGHT = | ||
| new Rectangle2d( | ||
| new Translation2d(5.2, 3.2), | ||
| new Translation2d(4.1, 1.64) | ||
| ); | ||
|
|
||
| public static final Rectangle2d RED_BUMP_RIGHT = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the whole field coordinate system is reversed when we play the other end, so you might want to call this something like "OPPONENT_BUMP_RIGHT" instead |
||
| new Rectangle2d( | ||
| new Translation2d(12.5, 6.43), | ||
| new Translation2d(11.32, 4.6) | ||
| ); | ||
|
|
||
| public static final Rectangle2d RED_BUMP_LEFT = | ||
| new Rectangle2d( | ||
| new Translation2d(12.5, 3.2), | ||
| new Translation2d(11.32, 1.64) | ||
| ); | ||
|
|
||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does "above" here mean "left"?