mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[examples] Update ElevatorTrapezoidProfile example (#5466)
This commit is contained in:
@@ -32,13 +32,9 @@ class Robot : public frc::TimedRobot {
|
||||
m_goal = {0_m, 0_mps};
|
||||
}
|
||||
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
frc::TrapezoidProfile<units::meters> profile{m_constraints};
|
||||
|
||||
// Retrieve the profiled setpoint for the next timestep. This setpoint moves
|
||||
// toward the goal while obeying the constraints.
|
||||
m_setpoint = profile.Calculate(kDt, m_goal, m_setpoint);
|
||||
m_setpoint = m_profile.Calculate(kDt, m_goal, m_setpoint);
|
||||
|
||||
// Send setpoint to offboard controller PID
|
||||
m_motor.SetSetpoint(ExampleSmartMotorController::PIDMode::kPosition,
|
||||
@@ -53,8 +49,9 @@ class Robot : public frc::TimedRobot {
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
1_V, 1.5_V * 1_s / 1_m};
|
||||
|
||||
frc::TrapezoidProfile<units::meters>::Constraints m_constraints{1.75_mps,
|
||||
0.75_mps_sq};
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
frc::TrapezoidProfile<units::meters> m_profile{{1.75_mps, 0.75_mps_sq}};
|
||||
frc::TrapezoidProfile<units::meters>::State m_goal;
|
||||
frc::TrapezoidProfile<units::meters>::State m_setpoint;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user