Motion Magic (Duty Cycle)
Great for arms where cosine gravity and jerk-limited motion are desirable. Matches Ironclad's Arm pattern.
MotionMagicConfigs mm = new MotionMagicConfigs();
mm.MotionMagicCruiseVelocity = Gains.motionMagicCruiseVelocity;
mm.MotionMagicAcceleration = Gains.motionMagicAcceleration;
mm.MotionMagicJerk = Gains.motionMagicJerk;
fx.getConfigurator().apply(mm);
MotionMagicDutyCycle ctrl = new MotionMagicDutyCycle(0);
fx.setControl(ctrl.withPosition(targetPosition));
Pattern we use:
- Keep a
wantedPositionfield and publish triggers likeatWantedPosition()usingMathUtil.isNear() - Seed the motor’s position to a CANCoder on boot if using a remote absolute sensor (see Remote Sensor)