-
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.
Showing
11 changed files
with
236 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"waypoints": [ | ||
{ | ||
"anchorPoint": { | ||
"x": 1.92, | ||
"y": 0.5 | ||
}, | ||
"prevControl": null, | ||
"nextControl": { | ||
"x": 3.0042032480370326, | ||
"y": 0.5 | ||
}, | ||
"holonomicAngle": 180.0, | ||
"isReversal": false, | ||
"velOverride": null, | ||
"isLocked": false, | ||
"isStopPoint": false, | ||
"stopEvent": { | ||
"names": [], | ||
"executionBehavior": "parallel", | ||
"waitBehavior": "none", | ||
"waitTime": 0 | ||
} | ||
}, | ||
{ | ||
"anchorPoint": { | ||
"x": 6.371669585444434, | ||
"y": 0.5 | ||
}, | ||
"prevControl": { | ||
"x": 5.336015096499199, | ||
"y": 0.5 | ||
}, | ||
"nextControl": null, | ||
"holonomicAngle": 180.0, | ||
"isReversal": false, | ||
"velOverride": null, | ||
"isLocked": false, | ||
"isStopPoint": false, | ||
"stopEvent": { | ||
"names": [], | ||
"executionBehavior": "parallel", | ||
"waitBehavior": "none", | ||
"waitTime": 0 | ||
} | ||
} | ||
], | ||
"markers": [] | ||
} |
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,49 @@ | ||
{ | ||
"waypoints": [ | ||
{ | ||
"anchorPoint": { | ||
"x": 3.599129905026728, | ||
"y": 3.264765928028098 | ||
}, | ||
"prevControl": null, | ||
"nextControl": { | ||
"x": 3.622136041599105, | ||
"y": 3.264765928028098 | ||
}, | ||
"holonomicAngle": 180.0, | ||
"isReversal": false, | ||
"velOverride": null, | ||
"isLocked": false, | ||
"isStopPoint": false, | ||
"stopEvent": { | ||
"names": [], | ||
"executionBehavior": "parallel", | ||
"waitBehavior": "none", | ||
"waitTime": 0 | ||
} | ||
}, | ||
{ | ||
"anchorPoint": { | ||
"x": 6.341533284570328, | ||
"y": 0.924179893472571 | ||
}, | ||
"prevControl": { | ||
"x": 5.341533284570328, | ||
"y": 0.924179893472571 | ||
}, | ||
"nextControl": null, | ||
"holonomicAngle": 0, | ||
"isReversal": false, | ||
"velOverride": null, | ||
"isLocked": false, | ||
"isStopPoint": false, | ||
"stopEvent": { | ||
"names": [], | ||
"executionBehavior": "parallel", | ||
"waitBehavior": "none", | ||
"waitTime": 0 | ||
} | ||
} | ||
], | ||
"markers": [] | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
package frc.robot.auto; | ||
|
||
import com.pathplanner.lib.PathConstraints; | ||
import com.pathplanner.lib.PathPlanner; | ||
import com.pathplanner.lib.PathPlannerTrajectory; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import edu.wpi.first.wpilibj2.command.WaitCommand; | ||
import frc.robot.Superstructure; | ||
import frc.robot.subsystems.Arm; | ||
import frc.robot.subsystems.Drive; | ||
|
||
public class ArmSimTest extends SequentialCommandGroup{ | ||
// Trajectories | ||
private final PathPlannerTrajectory traj1 = PathPlanner.loadPath("LowScoreTaxiBump", new PathConstraints(4, 3)); | ||
|
||
private final Drive drive_; | ||
private final frc.robot.RobotState robot_state_; | ||
|
||
// private final DriveTrajectory follow = new DriveTrajectory() | ||
|
||
|
||
// Constructor | ||
public ArmSimTest(Superstructure superstructure, Arm arm) { | ||
public ArmSimTest(Superstructure superstructure, Arm arm, Drive drive, frc.robot.RobotState robot_state) { | ||
drive_ = drive; | ||
robot_state_ = robot_state; | ||
addCommands( | ||
superstructure.setPosition(Superstructure.Position.STOW), | ||
new WaitCommand(1.0), | ||
superstructure.setPosition(Superstructure.Position.CUBE_L2) | ||
superstructure.setPosition(Superstructure.Position.CUBE_L1), | ||
new WaitCommand(2.5), | ||
superstructure.setIntakePercent(0.5), | ||
new InstantCommand(() -> new DriveTrajectory(traj1).followTrajectoryCommand(true, robot_state_, drive_)) | ||
|
||
); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
package frc.robot.auto; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
import frc.robot.RobotState; | ||
import frc.robot.Superstructure; | ||
import frc.robot.subsystems.Arm; | ||
|
||
public class AutoSelector { | ||
// private Command auto_command_ = null; | ||
|
||
public AutoSelector() { | ||
; | ||
} | ||
|
||
public Command run(RobotState robot_state, Superstructure superstructure, Arm arm) { | ||
return new ArmSimTest(superstructure, arm); | ||
} | ||
// public Command run(RobotState robot_state, Superstructure superstructure, Arm arm) { | ||
// return new ArmSimTest(superstructure, arm); | ||
// } | ||
} |
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,79 @@ | ||
package frc.robot.auto; | ||
|
||
import com.pathplanner.lib.PathPlannerTrajectory; | ||
import com.pathplanner.lib.PathPlannerTrajectory.PathPlannerState; | ||
import com.pathplanner.lib.commands.PPSwerveControllerCommand; | ||
|
||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.RobotState; | ||
import frc.robot.subsystems.Drive; | ||
|
||
public class DriveTrajectory extends CommandBase{ | ||
private final PathPlannerTrajectory traj_; | ||
private final Timer timer_; | ||
private double t; | ||
|
||
public DriveTrajectory(PathPlannerTrajectory traj) { | ||
traj_ = traj; | ||
timer_ = new Timer(); | ||
} | ||
|
||
|
||
@Override | ||
public void initialize() { | ||
timer_.start(); | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
t = timer_.get(); | ||
} | ||
|
||
public Pose2d getTrajectoryPose(double time) { | ||
final PathPlannerState state = (PathPlannerState) traj_.sample(t); | ||
return new Pose2d(new Translation2d(state.poseMeters.getX(), state.poseMeters.getY()), state.holonomicRotation); | ||
} | ||
|
||
public Command followTrajectoryCommand(boolean isFirstTrajectory, RobotState robot_state_, Drive drive_) { | ||
return new SequentialCommandGroup( | ||
new InstantCommand(() -> { | ||
if(isFirstTrajectory) { | ||
robot_state_.reset(traj_.getInitialHolonomicPose()); | ||
SmartDashboard.putNumber("Trajectory Total Time", traj_.getTotalTimeSeconds()); | ||
} | ||
}), | ||
new PPSwerveControllerCommand( | ||
traj_, | ||
robot_state_::getPosition, | ||
drive_.getKinematics(), | ||
Constants.kXController, | ||
Constants.kYController, | ||
Constants.kThetaController, | ||
drive_::setModuleStates, | ||
true, | ||
drive_ | ||
) | ||
); | ||
} | ||
|
||
public double getTrajectoryTime() { | ||
return traj_.getTotalTimeSeconds(); | ||
} | ||
|
||
public static class Constants { | ||
public static double kP = 0.5; | ||
|
||
public static PIDController kXController = new PIDController(kP, 0, 0); | ||
public static PIDController kYController = new PIDController(kP, 0, 0); | ||
public static PIDController kThetaController = new PIDController(kP, 0, 0); | ||
} | ||
|
||
} |
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
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