I want to reset the inertial sensor’s rotation after each turn. There is a function in VexCode " void (resetRotation)" which resets the rotation. Does PROS have a similar function without calibrating the sensor? Thanks in advance.
I am puzzled too. Honestly, I expected that IMU and any other sensor has something similar to motor’s tare_position but apparently not.
You could just store the rotation of the inertial sensor in a double value. Lets say your double value was called “angle”; you would have a loop to constantly set angle’s value to the inertial sensor’s rotation, but then after the turn is completed, you can set angle back to zero. That’s what I would do to get around that, anyways.
Hi, Welcome to the vexforum!
As far as I can tell, there are no provided methods to reset the rotation. Instead, each time you want to “reset” your sensor you will have to store reference point and calculate your heading based on that. Just as @Iogician suggested.
With that being said, I think there is a good reason why the PROS API does not provide a method for this. An inertial sensor is intended to track your global rotation - in relation to the field as a whole. That means, if the robot turned a degree less in one turn, you can measure that during the next step and compensate. If you keep reseting the reference point after each turn, you will accumulate error much faster than the inertial sensor drifts over time. Disturbances such as momentum after stopping or the robot getting stuck on something would be immediately discarded if you reset constantly.
Instead of blindly resetting the sensor after each turn, try to reset the sensor’s reference point at times when you are confident about the robot’s heading. This could be after lining up with the tape on the field, the wall, a goal or any other accurate measurement that can crosscheck the sensor’s accuracy.
“soon” you will be able to do this. https://github.com/purduesigbots/pros/pull/260
Thanks everyone for the helpful replies. @pinecone if it’s absolutely necessary for us to tare the sensor, I recommend we go the storing-value-in-a-double route. That seems like the most simple solution.
In the mean time you can use OkapiLib’s wrapper for the IMU, which has a reset method:
PROS will have this feature eventually (I’ve been working on it recently). Here’s the current progress: https://github.com/purduesigbots/pros/pull/260. It’ll be shipped with the next kernel update.