without getRate method, and without using getSpeed (because it gives int values)?
I don’t have Get rate, and I need speed values not int but double, as well as my getSpeed method, it gives values in int.
Why does getRate() not work for your application? By definition of the function, it gets the distance per second traveled, scaled by the distance per pulse (setDistancePerPulse), and outputs as a double. I don’t believe getSpeed is even still a usable function for Encoder.
What encoders are you using? Different libraries use different methods to get the rate of the encoder.
You can always just cast the int to a double in order to divide the encoder position by the change in time.
Example:
(double)getPosition()
Show your code how you’re trying to get the measurement. It will help those of us who want to help you see what you’re trying to accomplish, and what isn’t working.
For example, where are your encoders connected? To the Rio, to the motor controller? Are they integrated?
Can’t help you out much without knowing what you’re trying to do.
If your encoder does not have an explicit call that returns it’s measured velocity in meters per second, you’re going to have to implement that particular behavior in your drivetrain (or whatever subsystem has the encoders) on your own.
For example, the Talon FXs getVelocity() method returns native units per 100/ms. In your own code, you would have to create a method that converts that to meters/sec if you wanted to implement something like Trajectory following according to the WPILib docs.
Functions like getRate are not available to me since I use Studica’s TitanQuadMotorController and their Maverick motors, and if I create an encoder in code from TitanQuadEncoder, there are very few methods available to me that do not have getRate(), but I think I found a way , when creating this encoder, there is a getPeriod() method - it gives the period between the last two ticks of the encoder, therefore dividing the distance per pulse by this time, I can find the speed per tick. The only question is how accurate it will be…
I’m using studica’s Maveric motors (they have an encoder built in) and I’m reading the TitanMotorController’s encoder values.
No, I can’t do that, there is a getSpeedEncoder method, I looked at the sources, and it should return double values, but it returns the same values if I called the getRPM( gives engine rpm in int) method, absolutely the same, most likely for to calculate the encoder speed, the getRPM() method is used, well, in order not to bother, inside the encoder class…
Probably not very accurate given the measurement noise potential.
According to their API, there is a getSpeed() method. Is it not providing you what you need?
(Assuming of course, that’s the library you’re using in your development).
No, I can’t do that, there is a getSpeedEncoder method, I looked at the sources, and it should return double values, but it returns the same values if I called the getRPM( gives engine rpm in int) method, absolutely the same, most likely for to calculate the encoder speed, the getRPM() method is used, well, in order not to bother, inside the encoder class…
I just want to connect the encoders directly to the controller now, and use the normal encoder class, there are several advantages to this, 1) I will reduce the delay a lot, since I will bypass the CAN bus
2) I can use the Encoder class, which has a wonderful getRate() method
Question about the getRate() method. I give the encoder the distance per tick in the constructor when creating the object and the distance per tick converges, the full revolution of the wheel is about 320 millimeters, which is what it should be, but when I call gateRate to get the speed of the encoder mm / sec, then at maximum revolutions I get 67.3 , although at the maximum speed of 530 mm / s, what’s the problem? Distance per tick: 0.21888145537305936mm
I linked to what I was thinking was the titanquadencoder api in a prior post.
Is that correct? There’s not a getRate() method in that documentation.
Is the getRate() method from the motor controller, or some other API provider?
Yes, you are right, there is no such method. I switched to the regular Encoder class, where there is a getRate() method
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.