Hello, this is my first year programming and we are trying to make our arm smoothly raise to a desired position. We already have a bang-bang solution that is functional, but we would like a better option. I was told to look into the Motion Magic feature of Talon FXs and we eventually arrived at the setArmPosition method in the Arm subsystem. However, when we run it with the button nothing happens, I know the command is getting the run because we can see the encoder be reset in shuffleboard, but nothing was happening before the resetEncoders call was added. Can anyone look at that function and possibly tell me why its wrong? I may be in over my head as a first year here but any help would be great.
Thank you in advance.
This is our implementation of Motion Magic that we have working on our Arm and Wrist subsystem:
(The code could use some cleaning up, but it serves its purpose for now)
Looking at your code I see you are feeding Motion Magic the profile rather than a position. The way motion magic works is depending on your current position, it calculates a motion profile for you to get to the desired position. Meaning you would feed it the sensor units you would want it to go to, rather than a profile.
This documentation really helped us in getting started with Motion Magic and getting all the correct values and this other Chief Delphi post that answers a lot of other questions that we had.
Our programmers are currently working on tuning our arm control using Motion Magic so I researched it a bit to see if we were doing things the right way. When I looked at your code, I was surprised to see that your P for moving down was twice the value for when moving up. I would have expected it to be reverse, but I can’t say that I fully understand why. Can you explain why P would be higher for moving down? Is it due to having to work against the arbitrary feed forward that always pushing up? (is arbitrary feed forward pushing up when you tell the Motion Magic to lower the arm?)
Thanks for helping understand things a little more.
For our arm we have two 80 pound shocks aiding it up so the force to need to go up is a lot easier than to go down that’s why we had to “double” the value.