Skip to content
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

align to speaker #94

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions src/main/java/frc/robot/subsystems/Bass.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import org.littletonrobotics.junction.LoggedRobot;

import java.util.List;


import java.lang.annotation.Target;
import java.util.Optional;

Expand All @@ -14,6 +17,9 @@
import com.pathplanner.lib.util.PathPlannerLogging;
import com.pathplanner.lib.util.HolonomicPathFollowerConfig;
import com.pathplanner.lib.auto.AutoBuilder;
import com.pathplanner.lib.path.GoalEndState;
import com.pathplanner.lib.path.PathConstraints;
import com.pathplanner.lib.path.PathPlannerPath;
import com.pathplanner.lib.commands.PathPlannerAuto;

import edu.wpi.first.wpilibj.DriverStation;
Expand All @@ -23,6 +29,7 @@
import edu.wpi.first.math.filter.SlewRateLimiter;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.ChassisSpeeds;
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
import edu.wpi.first.math.kinematics.SwerveModulePosition;
Expand Down Expand Up @@ -104,6 +111,33 @@ public Bass() {
this // Reference to this subsystem to set requirements
);
PathPlannerLogging.setLogCurrentPoseCallback(pose -> Logger.recordOutput("Chassis/targetPose",pose));

// Create a list of bezier points from poses. Each pose represents one waypoint.
// The rotation component of the pose should be the direction of travel. Do not
// use holonomic rotation.
List<Translation2d> bezierPoints = PathPlannerPath.bezierFromPoses(
new Pose2d(1.0, 1.0, Rotation2d.fromDegrees(0)),
new Pose2d(3.0, 1.0, Rotation2d.fromDegrees(0)),
new Pose2d(5.0, 3.0, Rotation2d.fromDegrees(90)));

// Create the path using the bezier points created above
PathPlannerPath path = new PathPlannerPath(
bezierPoints,
new PathConstraints(3.0, 3.0, 2 * Math.PI, 4 * Math.PI),
// The constraints for this path. If using a differential drivetrain, the angularmconstraints have no effect.

new GoalEndState(0.0, Rotation2d.fromDegrees(-90))
// Goal end state. You can set a holonomic rotation here. If using a differential drivetrain, the rotation will have no effect.
);

// Prevent the path from being flipped if the coordinates are already correct
path.preventFlipping = false;
}

public Command alignToSpeaker(){
return runOnce(( -> {

}));
}

@Override
Expand Down
Loading