generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set brake mode, add auton, add reset angle and bindings
- Loading branch information
Prog694
committed
Dec 1, 2023
1 parent
70a6147
commit b4133c3
Showing
5 changed files
with
78 additions
and
3 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
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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/stuypulse/robot/commands/auton/EightFootAuton.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,37 @@ | ||
/************************ PROJECT PHIL ************************/ | ||
/* Copyright (c) 2023 StuyPulse Robotics. All rights reserved.*/ | ||
/* This work is licensed under the terms of the MIT license. */ | ||
/**************************************************************/ | ||
|
||
package com.stuypulse.robot.commands.auton; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.pathplanner.lib.PathConstraints; | ||
import com.pathplanner.lib.PathPlanner; | ||
import com.pathplanner.lib.PathPlannerTrajectory; | ||
import com.pathplanner.lib.PathPoint; | ||
import com.stuypulse.robot.subsystems.swerve.SwerveDriveFollowTrajectory; | ||
|
||
public class EightFootAuton extends SequentialCommandGroup { | ||
private static final PathConstraints CONSTRAINTS = new PathConstraints(0.01, 0.01); | ||
private static final PathPlannerTrajectory PATH = PathPlanner.generatePath(CONSTRAINTS, Arrays.asList( | ||
new PathPoint(new Translation2d(), new Rotation2d(), new Rotation2d()), | ||
new PathPoint(new Translation2d(0, 0), new Rotation2d(), new Rotation2d()) | ||
)); | ||
|
||
public EightFootAuton() { | ||
addCommands( | ||
new SwerveDriveFollowTrajectory(PATH) | ||
.robotRelative() | ||
.withStop() | ||
); | ||
} | ||
|
||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/stuypulse/robot/commands/swerve/SwerveDriveResetHeading.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,22 @@ | ||
package com.stuypulse.robot.commands.swerve; | ||
|
||
import com.stuypulse.robot.subsystems.swerve.Odometry; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class SwerveDriveResetHeading extends InstantCommand { | ||
|
||
public SwerveDriveResetHeading(Rotation2d heading) { | ||
super(() -> { | ||
Odometry o = Odometry.getInstance(); | ||
o.reset(new Pose2d(o.getTranslation(), heading)); | ||
}); | ||
} | ||
|
||
public SwerveDriveResetHeading() { | ||
this(new Rotation2d()); | ||
} | ||
|
||
} |
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