Autonomous Help

:frowning: We need help on our autonomous code. It does not follow the line in a straight manner. Our sensor set up is similar to the attachment.

The robot starts going straight, but then just keeps going back and forth between the outer most sensors until it is completely off the tape. We programmed the outer ones to be only 45’s. Once off, it just spins in circles. We are sporting a two wheel drivetrain with casters on four corners of the robot. :ahh:

We are also having problems with the 884’s. Sometimes the motor speeds are different when set to the same value on the joysticks or program, resulting in it turning all the time. But when we set the motors to full forward or full back, the robot goes straight. We have calibrated the victors several times and replaced them at least three times. This is a problem because if we go to dead reckoning the robot will not go straight. :confused:

Our competition is on Thursday 3-11-04, Friday 3-12-04, and Saturday 3-13-04. So any immediate help would be greatly appreciated here or at the competition.

Sudeep - Team Frog Force (503)
[email protected]

503.doc (19.5 KB)

503.doc (19.5 KB)

are you testing it with a second (clone) bot?

if your drawing is somewhat to scale you might try moving your sensors further out, and move them so they are as far forward as possible

then have the center middle pair turn the bot mildly, and have the outer ones turn the bot harder

is it possible you have your sensors backwards, you turn the wrong way when they detect?

about your drivetrain - what are you using? if the drive motors are not consistant maybe you have something binding up? chain too tight? gears crushed into each other? the drivetrain should be pretty smooth when you turn the wheel with your hand - and you are right, it should be somewhat consistant when you make multiple runs with the same settings.

We are using drill motors for the drive train. There is no sign of binding because when we set the motors to 255 and 0 it does perfect 360. We have tried moving the sensors closer together, farther apart, placing them in the middle. The sensors are not backwards because when we try running the tape under it with our hands it does what is is programmed to do. The problem is when the robot is on the floor.

just the drill motors? no gearing down?

what size wheels do you have?

here’s a few things you can try:

  1. make sure your sensors can see the line. are the individual indicator lights lighting up? try adjusting the sensitivity a little.
    2)are the casters causing your bot to turn too fast? I welded the casters on my test bot straight and it helped.
    3)if your inner sensors are working, are they just not turning hard enough? try making the turn tighter.

We have adjusted the sensors to see the line. If we have the Inner Sensors turn sharply, the robot will be totally off the line the middle three are used for straight line. the outer most ones are used to turn 45s.

when all else fails, try making the bot go slower

this has fixed many problems with all sorts of auton code. sometimes the inertia of the robot is just too much for it to work.

also, make sure you keep at least a small amount of forward motion in the program, otherwise you’ll end up oscillating back and forth across the line, not going anywhere.

can we see your code? also are your vic’s set to coast or brake?

Ok, the code just for lining following is attached. I might add that we used the same code on a old robot with the speed from 254 - 190 for max and it worked perfectly. But, the old Robot sported 4 wheel drive, unlike this years. The victors are set to break during autonomus mode. On the old robot we tested with and with out the breaks and found out that the response is too slow.

For making te robot go slower, we set it to go 160 and 150 for the max, and it still did the same thing, but slower. When tried to set it 140 and below the motors did not turn at all.

Are any of you attending the EMU Competition? We will be there arond 7:15 am. Team 503. (The people with a massive frog on the back of our shirts) And yes we are testing it with a clone robot.

Autonomous Code For Line Only-503.txt (4.18 KB)

Autonomous Code For Line Only-503.txt (4.18 KB)

oh wow… that is THE least effecent way to write it… lol. how bout a switch statement? or nested IFs? this is almost unreadable, and very hard on both the computer and the programer. errors in this type of set up are very hard to catch.

Are you attempting to line follow with four sensors?

Deleting the long string of else ifs at the end that do nothing might be a good idea, just to clean it up some.

Woah…That is some interesting code :ahh: . One of my suggestions, just to make things easier, would be to place those sensor readings in variables, and name them things like line_sensor_center, or whatever. That way, you, and anyone else looking at your code can read it easier. Another thing that someone else said was something about switch statements and nested-ifs. Personally, I think the switch would be easier to use. Do you know how to code that? If not, there is a great website for C: (

Well, actually, it is for C++, but the concepts discussed in the lessons is applicable in both languages. Also, something you should look into is maybe forming some extra functions at the bottom of “user_routines_fast.c”. The way we did it was to create seperate functions for turning left, turning right, going straight, and recorrecting . Whenever we would go off the line and hit the right sensor, we would “veer right” until the center sensor would read the line, then tell it to “recorrect” and adjust it’s angle back to its initial value. That takes some thought to sort through, but it seems to work for us. If you would like to see an example of that code, I would be happy to provide it for you. Good luck at competition.


               error C2143: syntax error : missing ';' before '}'  

 ^^^---Single most common programming error in ANY language---^^^

We got the autonomous working great tonight by putting the calibration of the 884s back to default. We write the code like that so that if some other team mates needs to read the code, they can easly understand it. In years past some one renamed the aliases and when other people went to read it at competition they had no clue what was what. Also we made a table with each part that has to be programmed, the alias, and the name of the part. We basicly memerized the names and orders and aliases. writing indivual “if” and “else if” statements are easy to think out on the fly. We are sporting 7 sensors now and it works great. We made no functions in fast, but in regular, we made each part of the robot a seperate function. We also deleted the un used conditions also we took out all of the pre-mapped things that became useless to us. Thanks for all of your help, see you at competiton.