-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarrelPath.java
More file actions
96 lines (69 loc) · 3.53 KB
/
BarrelPath.java
File metadata and controls
96 lines (69 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot.commands.Auto;
import edu.wpi.first.wpilibj.command.CommandGroup;
import java.util.List;
import edu.wpi.first.wpilibj.geometry.Pose2d;
import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.geometry.Translation2d;
import edu.wpi.first.wpilibj.trajectory.Trajectory;
import edu.wpi.first.wpilibj.trajectory.TrajectoryConfig;
import edu.wpi.first.wpilibj.trajectory.TrajectoryGenerator;
import frc.robot.commands.*;
import edu.wpi.first.wpilibj.controller.PIDController;
import edu.wpi.first.wpilibj.controller.ProfiledPIDController;
import frc.robot.Constants.AutoConstants;
import frc.robot.Constants.SwerveDriveConstants;
import frc.robot.subsystems.*;
public class BarrelPath extends CommandGroup {
/** Add your docs here. */
public BarrelPath(SwerveDrive swerveDrive, ProfiledPIDController theta) {
// Create config for trajectory
TrajectoryConfig config = new TrajectoryConfig(2.1,
AutoConstants.kMaxAccelerationMetersPerSecondSquared)
// Add kinematics to ensure max speed is actually obeyed
// .setKinematics(SwerveDriveConstants.kDriveKinematics)
.setEndVelocity(2);
// TrajectoryConfig config1 = new TrajectoryConfig(1,
// AutoConstants.kMaxAccelerationMetersPerSecondSquared)
// // Add kinematics to ensure max speed is actually obeyed
// // .setKinematics(SwerveDriveConstants.kDriveKinematics)
// .setStartVelocity(1.5);
Trajectory traject = TrajectoryGenerator.generateTrajectory(
new Pose2d(0, 0, new Rotation2d(-Math.PI / 2)), List.of(
new Translation2d(0, -3),
new Translation2d(-1.63, -3.224939),
new Translation2d(-1.663700, -1.846359),
new Translation2d(-.180766, -1.846359),
new Translation2d(-.180766, -5.030811),
new Translation2d(1.439370, -5.430811),
new Translation2d(1.439370, -3.995877),
new Translation2d(-1.827272, -3.995877),
new Translation2d(-1.827272, -6.816515),
new Translation2d(0, -6.816515)
),
//direction robot moves
new Pose2d(-0.15, 0, new Rotation2d(Math.PI / 2)), config);
SwerveControllerCommand swerveControllerCommand1 = new SwerveControllerCommand(traject,
(0), swerveDrive::getPose, // Functional interface to feed supplier
SwerveDriveConstants.kDriveKinematics,
// Position controllers
new PIDController(AutoConstants.kPXController, 1, AutoConstants.kDXController),
new PIDController(AutoConstants.kPYController, 1, AutoConstants.kDYController), theta,
swerveDrive::setModuleStates,
swerveDrive
);
// SwerveControllerCommand swerveControllerCommand2 = new SwerveControllerCommand(traject1,
// (0), swerveDrive::getPose, // Functional interface to feed supplier
// SwerveDriveConstants.kDriveKinematics,
// // Position controllers
// new PIDController(AutoConstants.kPXController, 1, AutoConstants.kDXController),
// new PIDController(AutoConstants.kPYController, 1, AutoConstants.kDYController), theta,
// swerveDrive::setModuleStates,
// swerveDrive
// );
addSequential(swerveControllerCommand1);
// addSequential(swerveControllerCommand2);
}
}