Fixing the Line follow

For my microprocessor class our final project is to have three robots run on a grid that has 6 spots with 3 “items” in each spot. All the robot has to do is go to the spot then return home. Basically what happens in a factory. We have one small code finished that works but unfortunately it runs completely slow. So I decided to type up a new code which I can add here.
Basically my question is solving the problem when the robot freaks out at intersections. I have attempted to change the speed and time of delay for when it comes to an intersection but I keep getting a problem a few turns later.

All the files are there.
The main will run the followSeg() until the last couple of turns where it will run the Home() function to cut down on time. If there is anything else I can add, I’ll be glad to inform
Robot_1.zip (141 KB)

Hello,

Are you having the problem where the robot suddenly swerves to one side as it approaches the intersection? The problem I had with my 3pi was that it did not know the difference between the line it was following and the intersecting line. So if one of its sensors started to see a bit of the intersecting line, it would think that the line it was following had suddenly moved very far to one side. Since it was programmed to follow that line, it would swerve to follow its incorrect idea of where the line is.

As you observed, it is hard to follow the line fast, using relatively large PID constants, without experiencing this problem. That’s why our example maze-solving code uses such a slow speed.

There are a lot of ways you could try to handle it. On mine, I used normal PID constants for a fraction of a second, to help the 3pi get lined up nicely before it hit the intersection, and then I weakened them automatically to let it coast smoothly through the difficult part. When crossing T intersections the problem was particularly bad, so I programmed my 3pi to temporarily follow the outer edge of the line instead of its center after identifying a T.

-Paul