Feedforward Interfaces
Esta página aún no está traducida. Se muestra la versión en inglés.
EasyMotor accepts any object that implements one of these two interfaces, so you can use the ready-made feedforward classes or write your own. Both live in the package dev.easyfamily.EasyStack.controllable.
#EasyFeedforward
Calculates a motor power from the wanted velocity and acceleration. EasyFFController implements it.
calculate(velocity, acceleration): returns the power for that velocity and acceleration.calculate(velocity): the same, with acceleration equal to zero.
Java
motor.setVelocityFeedforward(new EasyFFController(0.05, 0.0004));A custom feedforward is a short class:
Java
public class MyFeedforward implements EasyFeedforward {
public double calculate(double velocity, double acceleration) {
return 0.04 * Math.signum(velocity) + 0.0005 * velocity + 0.0001 * acceleration;
}
}#EasyPositionFeedforward
Calculates a power that also depends on the position, such as an arm that needs more power when it is horizontal. It has only one method, so you can write it as a lambda.
calculate(position, velocity, acceleration): returns the power.
Java
motor.setPositionFeedforward((position, velocity, acceleration) ->
0.12 * Math.cos(position) + 0.0004 * velocity);#Which One to Use
- Velocity feedforward: flywheels and anything that must hold a speed.
- Position feedforward: arms and lifts, where gravity changes with the position. For the two most common cases you do not need to write one: setPositionFeedforward on
EasyMotoralso accepts anEasyArmFeedforwardor anEasyElevatorFeedforwarddirectly.
Última actualización 2026-11-16