mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Add DifferentialDrive voltage constraint (#2075)
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
#include <frc/shuffleboard/Shuffleboard.h>
|
||||
#include <frc/trajectory/Trajectory.h>
|
||||
#include <frc/trajectory/TrajectoryGenerator.h>
|
||||
#include <frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h>
|
||||
#include <frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h>
|
||||
#include <frc2/command/InstantCommand.h>
|
||||
#include <frc2/command/RamseteCommand.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
@@ -44,11 +44,19 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
}
|
||||
|
||||
frc2::Command* RobotContainer::GetAutonomousCommand() {
|
||||
// Create a voltage constraint to ensure we don't accelerate too fast
|
||||
frc::DifferentialDriveVoltageConstraint autoVoltageConstraint(
|
||||
frc::SimpleMotorFeedforward<units::meters>(
|
||||
DriveConstants::ks, DriveConstants::kv, DriveConstants::ka),
|
||||
DriveConstants::kDriveKinematics, 10_V);
|
||||
|
||||
// Set up config for trajectory
|
||||
frc::TrajectoryConfig config(AutoConstants::kMaxSpeed,
|
||||
AutoConstants::kMaxAcceleration);
|
||||
// Add kinematics to ensure max speed is actually obeyed
|
||||
config.SetKinematics(DriveConstants::kDriveKinematics);
|
||||
// Apply the voltage constraint
|
||||
config.AddConstraint(autoVoltageConstraint);
|
||||
|
||||
// An example trajectory to follow. All units in meters.
|
||||
auto exampleTrajectory = frc::TrajectoryGenerator::GenerateTrajectory(
|
||||
|
||||
Reference in New Issue
Block a user