Some questions about motion magic

Our team wants to use motion magic on our turning motor – talonsrx. To do this , l have dug into team 2767’s TalonSRX motor training courses. However , after watching it, l still have some questions about motion magic.

  • First , in the motion magic part of the vedio, team 2767’s mentor told us to start tuning motion magic from tuning kF. So, at this time , should l set all other parameters such as kP,kD,kI and so on to 0 and tune the kF only , and stop tuning until the talon srx can reach the desired speed closely?

  • Besides, after l have tuned the kf of my talonSRX , how can l calculate the other parameters(kP,kD,kCruiseVelocity and kCruiseAcceleration), if l just have phoneix tuner. Which one should l start tuning from ? Is there any specefic steps to do it?

Any suggestion on how to tune the motion magic parameters is appreciated!

I suggest reading this article from CTRE’s documentation, they explain there, among other things, how to tune PIDF gains.

1 Like

Jerry here … I am the mentor in the 2767 Talon SRX training.

When tuning motion magic you might follow these steps:

  1. Put the Talon in velocity mode
  2. Set the current limit to protect the motor and mechanics.
  3. Zero out F, P, I, D
  4. Command a midrange velocity (remember you are in velocity mode)
  5. Start increasing F until the motor runs about the commanded speed (with all the values set at zero, nothing will move until you start increasing F)
  6. Once you get F set to a level where the motor runs about the commanded speed, you then command the motor to run several different speeds. Pick a low, mid, high depending on the intended speed range you plan to use. Look at the error on all three speeds and decide if you need to tweak F a little. The goal it to get the motor to run approximately the commanded speed. It won’t be exact. It is a “best fit” given the range of motor speeds you plan to use.
  7. Change the mode to Motion Magic
  8. You will need to select a starting point for Accel, Cruise, and P. If F is about right, then the cruise speed you select is the speed the motor will run as it approaches target endpoint (remember that you have really switched to a position control loop once you select Motion Magic)
  9. You then tune P, I, D just like you would for a normal position loop. Cruise will determine your max speed while the motor runs toward the target. Accel sets the ramp rate on motor acceleration and then slowdown.
  10. I would advise setting the cruise at a middle of the road speed. Set your accel slow enough so that you can see it speed up and then slow down. Make sure you see the expected cause and effect of the values. Increasing cruise should indeed increased the speed. Slowing accel does does indeed make it start and stop slower. Then as you increase P (you will need to have some small P value for anything to run) , the accuracy of the finish point gets better and better. But if P gets to high, it will oscillate about the commanded endpoint target.
  11. The Stryke Force Talon training course Chapter 8 starting at 30:11 walks thought the whole process.

As far as how to tune a PID loop, back up a few chapters in the talon training course. There is a full explanation. Once you get F set, Motion magic is tuned just like a position loop. The only difference is you now have Cruise and Accel to help control the start, stop and cruise rates.

Hopefully this provides a little bit of clarity.

CTR does a great job of walking you though the process if you want to approach it mathematically. The above approach is more of a seat of you pants method using the actual hardware.

Jerry

5 Likes

Thanks Jerry!

If l only have a phoneix tuner , how can l change to the motion magic control mode?

Can the speed range be chosen anything as l want?

Which setpoint of Accel should l set ?

So , the kF parameter is also needed in motion magic, is that right?

Thanks for providing such useful resources on TalonSRX training!

James

Hello , is this the good performance?

1 Like

I would say that looks good.

1 Like

I have tried different groups of cruise velocity and accel , but their effect seems to be similar. But when l drive my swerve in teleop, they have a different effect. So, how can l judge which group of parameters fits me best?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.