mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -4,9 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.elevatorexponentialsimulation.subsystems;
|
||||
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
import static edu.wpi.first.units.Units.Volts;
|
||||
|
||||
import edu.wpi.first.math.controller.ElevatorFeedforward;
|
||||
import edu.wpi.first.math.controller.PIDController;
|
||||
import edu.wpi.first.math.system.plant.DCMotor;
|
||||
@@ -114,9 +111,7 @@ public class Elevator implements AutoCloseable {
|
||||
// With the setpoint value we run PID control like normal
|
||||
double pidOutput = m_pidController.calculate(m_encoder.getDistance(), m_setpoint.position);
|
||||
double feedforwardOutput =
|
||||
m_feedforward
|
||||
.calculate(MetersPerSecond.of(m_setpoint.velocity), MetersPerSecond.of(next.velocity))
|
||||
.in(Volts);
|
||||
m_feedforward.calculateWithVelocities(m_setpoint.velocity, next.velocity);
|
||||
|
||||
m_motor.setVoltage(pidOutput + feedforwardOutput);
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.elevatorprofiledpid;
|
||||
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
import static edu.wpi.first.units.Units.Volts;
|
||||
|
||||
import edu.wpi.first.math.controller.ElevatorFeedforward;
|
||||
import edu.wpi.first.math.controller.ProfiledPIDController;
|
||||
import edu.wpi.first.math.trajectory.TrapezoidProfile;
|
||||
@@ -54,8 +51,6 @@ public class Robot extends TimedRobot {
|
||||
// Run controller and update motor output
|
||||
m_motor.setVoltage(
|
||||
m_controller.calculate(m_encoder.getDistance())
|
||||
+ m_feedforward
|
||||
.calculate(MetersPerSecond.of(m_controller.getSetpoint().velocity))
|
||||
.in(Volts));
|
||||
+ m_feedforward.calculate(m_controller.getSetpoint().velocity));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.examples.elevatorsimulation.subsystems;
|
||||
|
||||
import static edu.wpi.first.units.Units.MetersPerSecond;
|
||||
import static edu.wpi.first.units.Units.Volts;
|
||||
|
||||
import edu.wpi.first.math.controller.ElevatorFeedforward;
|
||||
import edu.wpi.first.math.controller.ProfiledPIDController;
|
||||
import edu.wpi.first.math.system.plant.DCMotor;
|
||||
@@ -104,8 +101,7 @@ public class Elevator implements AutoCloseable {
|
||||
|
||||
// With the setpoint value we run PID control like normal
|
||||
double pidOutput = m_controller.calculate(m_encoder.getDistance());
|
||||
double feedforwardOutput =
|
||||
m_feedforward.calculate(MetersPerSecond.of(m_controller.getSetpoint().velocity)).in(Volts);
|
||||
double feedforwardOutput = m_feedforward.calculate(m_controller.getSetpoint().velocity);
|
||||
m_motor.setVoltage(pidOutput + feedforwardOutput);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user