Rotation sensor update rate? (Optical shaft encoder vs rotation sensor?)

I would like some clarification on the status of the v5 rotation sensors’ update rate. Our team has a few rotation sensors, but we are weighing pros and cons of using the 3 wire optical shaft encoders instead (for the use of odometry). It has been established that the optical shaft encoders update every 10 milliseconds. However, I have seen that the rotation sensors only update every 20 milliseconds. For the use of odometry a higher update rate is desirable.

In other topics, such as this one, JP said that in vexos 1.0.13, they would be changing the update rate somehow. Is this an option that has to be changed in the user code? I cannot find anything related to the update rate in the vexcodePro API.

I guess what I’m trying to ask is what is the actual update rate of the v5 rotation sensor, and is there a way to change it?

Another question for more experienced teams would be: which sensor is better for odometry?

From my understanding the default is 20ms, but it can be configured in steps of 5ms down to 5ms, subject to the caveats noted in that thread you linked (the 10ms buffer copy, etc.).

I know that PROS has rotation_set_data_rate for this purpose, which in turn calls the SDK function vexDeviceAbsEncDataRateSet. I’m not sure if the VEXCode API has its own implementation or not, @jpearman can answer that.

4 Likes

The rotation sensor send a new value every 20mS to the V5 brain.

you need to subclass the rotation class and then you can use this protected method.

/**
 * @brief change data rate to user specified value, will be rounded to multiple of 5mS
 */
void datarate( uint32_t rate );
6 Likes

Is there a way to change the rate in VexCode Python?

No, and there’s little to be gained in doing that anyway.

2 Likes

I subclass the rotation class, and the fastest rate seems to be 10ms, not 5ms。is that right? thx