Hello everyone,

I have been working with the new trajectories and I was not able to find an equivalent getRate() function for the Mag Srx Encoders. I was thinking of having a custom function to return me the rate of the encoder but I wanted to check with the community to see if there is a function included in the Phoenix library that I missed.

Are you running them through the Talons?

You can use talon.getSelectedSensorVelocity and convert it from encoder edges per decisecond to m/s.

Yes, I am running them through talons.

So the formula would be multiplying the value from talon.getSelectedSensorVelocity by:

`((1/4096)*(wheel_circumference_in_meters))/10`

Is this the correct way to do it or am I missing out on something here?

That looks good, but I would avoid hard coding numbers more than once in your code.

Watch out there, doing `1/4096`

will give you 0. You should do `1.0/4096.0`

or just divide by 4096 at the end.

I usually end up putting a `.0`

at the end of all my numbers so the math Iām doing is for `double`

s instead of integers.

This was a major issue I faced a couple of months ago. Apparently, I forgot it again Thanks!

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