PIDControl with brain inertial

Hi guys, hope you’re well Lately i’ve been strugling with autonomous so I used caution tape one but instead of using the gyroscope, I used the brain inertial but for no reason when I run the program, the robot starts to drift Does any of you have a solution? Thank you for your understanding.

1 Like

It may be the brain inertial or it may potentially be the fact that the KP is pretty low which leads to drifting.

2 Likes

Legacy gyro and the brain inertial sensor work in opposite directions, that is, legacy gyro turning counter-clockwise will increase rotation value, the brain’s internal IMU will increase rotation value when turning clockwise.
For blocks one possible fix is to multiply the rotation value by (-1) to be able to use the same code. Text would allow more options.

and for future, no need to create multiple topics asking the same question, I closed the other one.

5 Likes

Yes I know but it should 'nt be a probleme for going straight bc for going straight the heading is 0

1 Like

But if it could stick to exactly zero, you wouldn’t need PID.

Because the inertial is opposite of the gyro, you have to fix the math one way or another if you want to use it. If you don’t fix the math, the robot is not going to drive like you want it to.

1 Like

yes i solved the probleme of drifting currently the new problem is pid isnt correcting the movement of the robot

My French is a little rusty but I think you need to change “définir position” to “définir puissance” since you want to adjust the velocity settings of the motors. This should be done for both cases: forward and reverse.

1 Like

is it to hard to use a gyro?

I dont have a gyro and it will take time to buy one

oh. Thats unfortanate.

Your code seems to indicate you have a Gen 2 brain? If so, gyro is built in.

true, but still inconsistant I’m pretty sure.

Sometimes the brain inertial for 2nd gen are a little bit wonky. In our robot we tried multiple tests with an inertial but they are unpredictable.

yes same about me I guess that the probleme is coming from the inertial sensor

I’ve written full PID code using the IQ2 brain’s inertial sensor, had it drive straight at 80% power for about 10 feet over linoleum tile, turn 180 degrees, drive back 10 feet, one last 180, and it was a half inch off from where it started.

Brain inertial is plenty fine.

2 Likes

Looking at your second screenshot in comparison to the first, it looks like you’ve changed the error calculation to a ‘+’ instead of a ‘-’, and in combination with multiplying by -1, you’ve changed what the math should be doing back to being opposite of what it should be relative to the original CTR Drive Straight code.

Also, your Kp value of 1.5 could be too strong and cause the bot to wobble. You could try making it something like 0.5 or 0.25 and see what difference that makes.

1 Like

Did you fix your code? The code you posted a bit over a week ago appears to have errors. It would not work with either the older Gen 1 gyro or the G 2 internal sensor.
Otherwise, our results with the Gen 2 internal sensors is pretty much the same as EngineerMike described. We’ve had very good results from the Gen 2 internal sensor, using it on multiple brains for the last three years.

Sorry, I misread the date. I’m referring to the code posted on 2/20. Did you change the block “définir position” to read “définir puissance” ? From VEXcode IQ:

French
Screenshot 2024-02-25 191113

English:
Screenshot 2024-02-25 191128

1 Like

yes I’ve fixed all the errors but still not working i think the issue is coming from the inertial sensor because a week ago the brain fell down

I would just try and buy a gyro tbh