9 #include <frc2/command/button/NetworkButton.h> 23 m_chooser.SetDefaultOption(
"Example 1", AutoPath::kEx1);
24 m_chooser.AddOption(
"Example 2", AutoPath::kEx2);
25 m_chooser.AddOption(
"Example 3", AutoPath::kEx3);
26 m_chooser.AddOption(
"Example 4", AutoPath::kEx4);
27 frc::SmartDashboard::PutData(
"Auto Path", &
m_chooser);
34 m_drive.SetDefaultCommand(frc2::RunCommand(
49 units::meters_per_second_t(yInput * AutoConstants::kMaxSpeed),
61 frc2::JoystickButton(&
m_primaryController, (
int)frc::XboxController::Button::kBumperLeft).WhenPressed(
68 frc2::JoystickButton(&
m_primaryController, (
int)frc::XboxController::Button::kBumperLeft).WhenReleased(
87 units::meters_per_second_t(0.0),
88 units::radians_per_second_t(0.0),
false);
96 return new frc2::SequentialCommandGroup(
98 frc2::ParallelRaceGroup(
102 frc2::InstantCommand(
111 return new frc2::SequentialCommandGroup(
113 frc2::InstantCommand(
122 return new frc2::SequentialCommandGroup(
124 frc2::ParallelRaceGroup(
128 frc2::InstantCommand(
137 return new frc2::SequentialCommandGroup(
138 frc2::ParallelRaceGroup(
142 frc2::InstantCommand(
151 return new frc2::SequentialCommandGroup(
152 frc2::InstantCommand(
165 frc::ProfiledPIDController<units::radians> thetaController{
169 thetaController.EnableContinuousInput(units::radian_t(-wpi::math::pi), units::radian_t(wpi::math::pi));
186 return swerveControllerCommand;
192 std::vector<frc::Trajectory::State> states;
193 printf(
"Converting array...");
194 for (
int i = 0; i < length; i++)
196 printf(
"looping through timestamps...");
198 a[i][0] * 1_s, a[i][1] * 1_mps, a[i][2] * 1_mps_sq,
199 frc::Pose2d(a[i][3] * 1_m, a[i][4] * -1.0 * 1_m, a[i][5] * -1.0 * 1_deg), curvature_t(0)
202 printf(
"Finished looping, returning Trajectory");
203 return frc::Trajectory(states);
208 for (
auto &state:trajectory.States())
210 double time = state.t.to<
double>();
211 double x = state.pose.X().to<
double>();
212 double y = state.pose.Y().to<
double>();
213 printf(
"%.3f, %.3f, %.3f\n", time, x, y);
void SetDefaultCommands()
void Drive(meters_per_second_t xSpeed, meters_per_second_t ySpeed, radians_per_second_t rot, bool fieldRelative)
void PrintTrajectory(frc::Trajectory &trajectory)
constexpr double kDThetaController
frc2::SwerveControllerCommand2< DriveConstants::kNumSwerveModules > GetSwerveCommand(double path[][6], int length, bool primaryPath)
constexpr double kDeadzoneXY
constexpr double kPYController
frc::XboxController m_primaryController
constexpr double kDeadzoneY
const frc::TrapezoidProfile< units::radians >::Constraints kThetaControllerConstraints
frc::Trajectory convertArrayToTrajectory(double a[][6], int length)
frc2::Command * GetAutonomousCommand(AutoPath path)
constexpr double kDeadzoneX
frc::SendableChooser< AutoPath > m_chooser
constexpr double kPThetaController
static double Deadzone(double inputValue, double deadzone)
If an inputValue is smaller than its deadzone, returns 0, otherwise returns the inputValue.
void ResetOdometry(Pose2d pose)
constexpr double kDXController
constexpr double kDeadzoneRot
constexpr auto kDriveAngularSpeed
constexpr double kPXController
constexpr double kDYController
void SetModuleStates(SwerveModuleStates desiredStates)
Sets the drive SpeedControllers to a power from -1 to 1.
void ConfigureButtonBindings()
SwerveDriveKinematics< kNumSwerveModules > kDriveKinematics
The kinematics object converts inputs into 4 individual swerve module turn angle and wheel speeds...