mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[examples] Update ElevatorTrapezoidProfile example (#5466)
This commit is contained in:
@@ -17,8 +17,10 @@ public class Robot extends TimedRobot {
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
private final SimpleMotorFeedforward m_feedforward = new SimpleMotorFeedforward(1, 1.5);
|
||||
|
||||
private final TrapezoidProfile.Constraints m_constraints =
|
||||
new TrapezoidProfile.Constraints(1.75, 0.75);
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
private final TrapezoidProfile m_profile =
|
||||
new TrapezoidProfile(new TrapezoidProfile.Constraints(1.75, 0.75));
|
||||
private TrapezoidProfile.State m_goal = new TrapezoidProfile.State();
|
||||
private TrapezoidProfile.State m_setpoint = new TrapezoidProfile.State();
|
||||
|
||||
@@ -36,13 +38,9 @@ public class Robot extends TimedRobot {
|
||||
m_goal = new TrapezoidProfile.State();
|
||||
}
|
||||
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
var profile = new TrapezoidProfile(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(
|
||||
|
||||
Reference in New Issue
Block a user