Does your gyro affect the functionality of a P Loop working?

Just wondering if you have a dodgy gyro, whether that will affect whteher a P Loop works. By dodgy i mean if you program it to turn left for 90, i will go like 180, meaning the gyro is clearly wrong. If you have a gyro like this does that mean a P Loop wont work?

It may not be the gyro. Can you post your code?

3 Likes

its caution tapes, however i have commited alot of time to learning and understanding how it works.
However, the issue may be with my kP, because i have been having trouble find that value as well

We need to see your code. You can’t just say

because almost invariably with coding issues someone left something out, so you can’t just say, ā€œIt’s Caution Tape’s,ā€ because you probably made an error that they didn’t. And by the way, kP should be a variable, like when you click Make a variable. It should not be something you type into every instance of your block.

1 Like

What have you done to check if the gyro is working correctly or not? If this code is a P-loop for turning using the data from the gyro, then they gyro would certainly need to work correctly for the code to work.

I programmed it to go foward 200mm and then turn right for 180 degrees, but then it ends up going like 260 degrees

Using the code you copied from Caution Tape or doing some more basic testing?

My first suggestion would be to confirm that the gyro is working correctly and learn a little more about how the gyro works to aid with your fault finding.
There are a few ways to do this, but I would suggest creating a program that calibrates the gyro and then prints the heading value to line 1 of the screen, and rotation value to line 2. You can then see exactly what the gyro is doing as you move the robot through the various turns manually (i.e. just turn the robot by hand).

Is the gyro drifing?
Are the values you are seeing what you would expect based on how you moved the robot?

1 Like

I have done this. The gyro overturns roughly 80 degrees

If the gyro is not returning accurate values, then these are unlikely to be consistently innacurate and so you will not be able to code around the issue.
By that I mean the amount of error is unlikely to be the same all the time, so you can’t fix it in code since next time, the amount of error may be different.
If you are sure your gyro is at fault, you’ll need to replace it before you continue trying to tune your code.

1 Like

No. He and I are saying, get an example program that only prints gyro heading and gyro rotation to the brain. (And calibrates it.) Then set your robot on the floor, get it in the program, and turn it back and forth slowly and check what it prints to the brain. If and only if it reports incorrect values when you do that, change your gyro and check the new one. Otherwise, you have at least one error in your code that I’ve seen, and coding bugs are going to be your thing. Don’t do something like using your buggy code to check your gyro, use an example program to print to the brain.

2 Likes

The first two ā€˜spin’ lines on your Straight myBlock do not match Caution Tape’s code. I would suggest reviewing all of it before proceeding further.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.