Hi yall, This is our first year using encoders and I understand how to get velocity and using PID loops (I hope), but I am unable to use the raw velocity in our TalonSRX because the ControlMode.Velocity control is unimplemented, so I was wondering how to convert our velocity from the PID loop into a percentage so we can use it for ControlMode.PercentOutput, I’ve exhausted all my ideas and I hope yall can help!
What do you mean that ControlMode.Velocity is unimplemented? Do you not have an encoder set up to record velocity/position? Is your goal to completely avoid using PID by trying to convert velocity to a percent output, because I don’t think that is realistic nor possible.
For the control mode, when I try to set the talonsrx I looked at the definition and Velocity has no current way to change the talons speed, its empty in the case of velocity.
We do have an encoder connected to our talon which is able to get our position and velocity readings luckily.
Also sorry for not clarifying but we do want to use PID loops, the only problem is, the answer we get back from it is in terms of the velocity and we wanted to find a way to convert it to a percentage in order to use another the percent output control mode in the talon because we know that one is able to change motor controller speeds
If you’re trying to read what your max velocity is, set it to 100% percent output and then read your encoders velocity with talon.getSelectedSensorVelocity(). If you want to set your velocity using PID, use talon.set(ControlMode.Velocity, targetVelocity).
I am unsure of what you mean by your talons speed is empty in the case of velocity. Can you share your code? Velocity is in terms of ticks per 100ms I believe for the talons.
Are you saying that the TalonSRX Velocity example doesn’t work?
Alright I think I see what happened, I probably forgot to config the PID constants on the talon so it might of kept it at 0 so when I tried ControlMode.Velocity it didnt move at all, ill try that next time im able to work on the robot, but thank you for the example hopefully when I follow it the velocity input will work!
Here’s a way to convert velocity to percentage:
Say the falcon 500 has a max free velocity of 6380 rpm, you will have:
percentOutput = (currentSpeed) / 6380 * 100
The currentSpeed can be measured through the value of encoders
Of ControlMode.Velocity is implemented, I would recommend using the built in method instead of calculating the percent output itself
That sounds good if the velocty does work, thank you for the help though!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.