Hi. What is Motion Magic exactly? Is it faster than regular PID control?
It isn’t faster, it’s much smoother though. It’s probably the best way to control an arm or elevator that moves large distances between setpoints.
It creates a motion profile with a specified max acceleration and max velocity, and follows the profile to the given position.
I’m largely simplifying here, there’s more to it. I’d suggest reading the official docs on it.
tldr; smoother than PID position control, not necessarily faster.
what do you mean by smoother?
As explained in the Wpilib docs, you can make a motion profile for closed-loop control that will interpolate the target of the PID to follow a maximum velocity and acceleration. What this does is it gives you a greater control of how the mechanism moves so that you can tune it to move smoother than you otherwise could with a basic PID.
What Motion Magic does (as explained here), is it generates a motion based on a given acceleration, cruise velocity, and (an optional) jerk value. The advantage of Motion Magic over basic PID + motion profiling is that it sends the PID, feedforward, and motion profiling parameters to the motor controller along with the desired end goal, and then the motor controller will calculate the output voltage based on the parameters by itself at a much faster rate and with less latency that if you were to calculate the voltage on the roborio and then send that voltage to the motor. Another nice benefit of Motion Magic over basic pid on the rio is that its less messy to set up and configure and you can tune it in phoenix Tuner X with no extra code.
tldr; it makes the motion profile itself, then runs the pid on the motor controller much faster than you could on the roborio, meaning it is smoother.
Someone correct me if I’m wrong