![]() |
Line Tracking Code Help
1 Attachment(s)
Hello,
I'm one of the programmers for team 2929 for Emerald Ridge. Recently our robot was bagged and tagged and I’ve been working on our code for the line tracking sensors, because when we worked on the line tracking in autonomous, the robot only went backwards only, and one time did the spin of death, violently turning left continuously. So I was hoping if anyone sees any bugs in the robot code I’m posting, it would be great if someone could help me find and fix them. Thanks in advance! |
Re: Line Tracking Code Help
If your robot is running backwards, then just take the opposite numbers of the motor values (-1 instead of 1) and continue.
Looking over your code, though, there's a better way of doing it. First of all, I would advise against running a motor at full speed when trying to turn, because you should just be making gradual adjustments. Second, a more accurate autonomous can be achieved by just slightly increasing the speed of whichever side of the robot you want to turn and continuing on. That's how we did it, and we were extremely consistent in our autonomous at Alamo. |
Re: Line Tracking Code Help
Quote:
TIA, Mike |
Re: Line Tracking Code Help
My raw autonomous code wouldn't be much use to you, as its deeply integrated in our system and would be difficult to read if you don't know what everything does. But here's the basic idea:
Code:
if (leftSensorTripped) { |
Re: Line Tracking Code Help
Quote:
Mike |
Re: Line Tracking Code Help
Our line following algorithm uses PID control. Basically, we combined the readings of the three light sensors into a 3-bit value (0-7) and used it to index a table. If the line is right at the center, it maps to 0.0. If the line is slightly to the left, it maps to 1.0, more to the left maps to 2.0. If the line is slightly to the right, its maps to -1.0 and -2.0 if further right. 999.0 is just a number used to indicate no valid line is found. The number -2.0 to 2.0 is then used as the current input in PID control calculation and the setpoint is 0.0 (the center). The turning power is proportional on how far we are "off course". The speed driving forward is inversely proportional to the turning power. So the harder we turn, the slower we go. Our algorithm is actually more complicated than that but a simplified version is shown below.
Code:
UINT32 |
Re: Line Tracking Code Help
my mentor and i did it in binary case statements and it worked well very confusing though
|
| All times are GMT -5. The time now is 03:56 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi