SRX Velocity Closed Loop "Anti-Gravity" Feedforward

arm
talonsrx
pid

#1

I have a relatively heavy arm that is controlled by a Talon SRX with an encoder attached. I want to use the Talon SRX’s built in Velocity Closed Loop control to move it at a constant speed, but am running into issues where gravity is overpowering the PID greatly. When I used Position mode I was able to dynamically change the feedforward so that the arm did not accelerate due to gravity, but with Velocity closed loop I noticed that feedforward does not have the same effect. Is there a way to add this “anti-gravity” force in Velocity Closed Loop mode?


Keeping an arm raised
#2

So last year my team had a wrist on the robot that I had to control. Although I didn’t use Velocity Control Mode, I did do a manual PID with Percent Output to overcome the gravity with Feedforward and make the PID handle the actual movement.


This is our code from actually this year for off-season event. We first figured out what power we needed to hold at max holding power(straight out position) which came out to be 40% and applied cosine of the angle that we were at to get our anti-gravity. Then we added PID to actually move it from position to position.
As for using velocity control, technically you should be able to tell it 0 velocity whenever you are at the desired position. When you tell it 0 velocity, it really shouldn’t move from where it is at. We use velocity drive for our robot and whenever we try to push the bot at 0 velocity, it DOESN’T MOVE.
I hope this helps :slight_smile:


#3

This thread is a good start. To add voltage to the output of the Talon’s PIDF controller, you should use the arbitrary feedforward. This is done via the Talon’s 4-input set method (or just part of the set block if you’re using LabVIEW).

Note that it ranges from [-1,1], so you express it as the percent output. Additionally, this is entirely separate from the F gain of the PIDF controller, which scales with the setpoint.


#4

This is exactly what I was looking for, thanks!