I have a project where I need my robot to drive 1 meter forward and 1 meter backward continuously for several minutes. I am using the 2nd gen brain inertial capability. I am noticing a “consistent” drift in the negative direction that does not seem to stop. I have watched the value live on the screen while running and during bench testing. If the brain is sitting still the value will hold. when there is any vibration the value will go negative. I even have legs attached while testing to ensure the robot is not actually moving by getting the wheels off the ground. With 50 rotations of a motor and all of the drivetrain vibrations that gives, my rotation is already off -0.5 degree. On a side note, I am able to get the drive with no motor movement if I place the robot with legs onto a sturdy butcherblock table and lightly tap the top of the table with the parts box, or some other object to create a slight vibration. I don’t think motor interference is a factor here. These are just my observations to add to the discussion.
For what I am trying to do, half an inch is way to much. Especially when it keeps compounding in the same direction.
I think you’re going to have some significant challenges meeting that sort of requirement with Vex IQ, in my opinion.
Given what you’ve said that half an inch of inaccuracy over a 3 ft('ish, 1m) is too much, but that’s already just about a 1% error rate with elementary aimed electronics kit. It’s possible you may be able to get to what you’re trying to do, but I don’t think you get there with just the brain inertial. I think you’d have to explore using a lot more advanced computing & filtering (using acceleration values from the sensor, maybe comparisons with a separate gyro, Kalmann or IIR/FIR filtering, etc.) to stand a chance at getting to your requirements.
James or someone else might have some other ideas, but other than trying to manage some sort of shock isolation to reduce the effects of vibration, I think you’re going to have a difficult time reaching what you’re proposing.
I tried suspending the brain with rubber bands. While it did not seem to make the overall drift worse, it did not make it any better. What it did do was make it harder to easily press the buttons on the brain and then oscillate some after pressing a button. Pressing the buttons did then also induce vibrational drift.
I ended up writing a correction factor into the code to minimize the drift. It is not perfect but it is now usable for what I needed it to do.
instead of error=heading±1*braininertial, just do heading - braininertial
it will make it less confnusing
This code seems to have only the proportional control. I just tried to put together the integral and differential components as well and it works well. However, my code is just for driving backwards:
There is a great lecture on PID posted here
but it in the text code, but the blocks seem to be more accessible for most kids.