Newbie Autonomous Question(s)

I’m from a rookie team and we are having some coding issues. We have one member on our team that can code just about anything, but he can only come about one day a week. Meanwhile, we are trying to accomplish things on our own. Everyone else that is working on coding began learning C about, oh, last week. Meaning we’re all clueless. Really, really, seriously clueless.

We are trying to get the autonomous mode to work. The problem is we have no clue where to begin. We don’t even know where to find the source code that is supposed to be on the FIRST site, or so we’ve been told.

Basically, we need a STEP BY STEP guide on how to begin our autonomous programming. We need to know how to initialize an autonomous mode, how to set it up to follow sensors, and how to set up a programmed list of directions (i.e. “Move forward 10 feet, turn 30 degrees, etc.”)

Any help would be GREATLY appreciated.

the default code can be found at www.innovationfirst.com
also, the place for putting default code is found in the user_routines_fast.c file.

www.innovationfirst.com
Click on “FIRST Robotics” then on “Documents” at the top. The source is on that page.

Look in ChiefDelphi’s white papers for help on getting started…there are 3-4 papers on just that. :slight_smile:

If you need more help, PM me and I’ll be glad to help.

Well, I’ll show you some code so you can get a start on it. The other stuff should be pretty similar, or at least require a similar level of thinking – so once you understand what’s going on here, you should be well on your way.

First, let’s say you want a function ‘void Turn_Robot (int angle)’ to turn the robot by some specified angle ‘angle.’ How do you do this? Well, without encoders or gyros, the answer is pray! But you’ll have to settle for a simple counter. E.g.,


/*
      Hopefully you can follow this.  I'll try to comment liberally (something that's rather hard for me ;)

      In your auto mode routine, you might say something like:
      if (!FinishedTurn) Turn_Robot (radian measure);
      else  {/* put other code here */}

      Note that you'll need a global variable FinishedTurn, initialized to false (0), and a handfull of defines.
*/
void Turn_Robot (int angle)
{
     // static means that we only set it to 0 the first time, and when it is
     // called again, it is persistant, meaning it won't lose its old value
     static unsigned int counter = 0;

     // we are going to count up from 0.  On the left side of the equation, we
     // have a unit of cycles, so we have to find out how to convert radians
     // to cycles.  This is done by an *emprically found constant*
     // CYCLES_PER_RADIAN (dependent on voltage, so beware).
     if (counter++ > abs(angle) * CYCLES_PER_RADIAN)
     {		// Robot has finished turning, ergo ...
        // we're done, so nicely set counter back to 0 for next time
        // set left and right drive to neutral, and set flag FinishedTurn to true
        counter = 0;
        LEFT_DRIVE = 127;
        RIGHT_DRIVE = 127;
        FinishedTurn = 1;
     }
     else {
        // We aren't done turning.  We have to set up some convention for
        // angle (turning PI/4 radians doens't mean anything without a
        // coordinate system, afterall!)  Ergo,
        if (angle > 0)
        {	// Positive angle means turn left
            LEFT_DRIVE = LTURN_SPD_LDRIVE;
            RIGHT_DRIVE = LTURN_SPD_RDRIVE;
        }
        else {	// Negative angle means turn right
            LEFT_DRIVE = RTURN_SPD_LDRIVE;
            RIGHT_DRIVE = pwm04 = RTURN_SPD_RDRIVE;
        }
        FinishedTurn = 0;  // NOTE: set this back to false; else, when called
                                 // after successful move, it will still be true!
     }
}

A similar Move_Robot function should be easy (the turn is slightly more complicated, so that’s why I included this one for you). Now, how to find out all those constants? Well, that’s the fun part (by the way, I put in their radians as the default, but you can set it up to any unit you feel like).

Okay, set the constant CYCLES_PER_RADIAN to some value, any value (I’d guess what you think, from judging how fast the robot can turn). Don’t do anything in your code, but call the function Turn_Robot (angle), with some angle you feel like turning. If the robot doesn’t turn enough, increase the constant by a variable amount, depending on how much is left to turn. If the robot turns too much, decrease the constant. (You might want to put tape on the floor marking off a 45 deg angle, or some such sort that is easily determined, so you can quickly tell what to do.)

Oh, and I haven’t tested this code, so beware (I’m frequently wrong ;)) As Knuth said, Beware, I’ve only proven the above code correct, I haven’t tested it.

well if u download the source codes from the sites listed above, they come ready to work. make sure u wire up the beacon right. to start try to see if ur senors pick up the beacon by using the tracking code. if the works then use teh navigate code. oh make sure that u use two of the same type servos or it wont work right. we had to fix this in the code to. this should get u started. make sure u hit the trigger when using the navigate code or it wont start.

k i am from a first year team from fl and basically we have alot of problems with programming some kid told me bout encoders and buildin a cirui would be the best way to go if any one can help me plz help

Don’t feel too bad…We’re clueless too! And to make things worse, they never sent us the CDROM that was supposed to come with the new Edubot Controller, so we didn’t even have the CBot compiler until I borrowed a copy from another team! If you find that step-by-step let us know!

if you need help, the best method is to try and figure something out, and when you get stuck on a particular thing, ask a specific question. we can’t really show you the entire process (message boards aren’t very good for that), but we can definitely try to answer specific questions or provide advice on specific topics.

http://www.rec.ri.cmu.edu/education/edubot/2004_content/index.htm has a lot of tutorials that are very helpful, such as running a motor for 1 second, and another one called making a timed turn.

I’m following the instructions in the 2004 introduction to programming guide, but when i followed their instructions to insert the code b/w the “Getdata” and “Putdata”, but when i pressed the make button, it did not compile. What is wrong? :confused:

Saying that it didn’t compile without giving us any error messages is not helpful at all. You should also show us the exact modifcations that you did.

Our robot will not follow a line of tape. (The banners are calibrated correctly.)

Let me explain our setup:
pwm01 = Left Drive Wheel
pwm02 = Right Drive Wheel

rc_digi_in01 = Left Banner (WHITE Sig.)
rc_digi_in02 = Right Banner (WHITE Sig.)

Our Autonomus Code:

		if (rc_dig_in01 == 1 && rc_dig_in02 == 1) 
		{
			pwm01 = 117;
			pwm02 = 117;
		}
		
		if (rc_dig_in02 == 1 && rc_dig_in01 < 1) 
		{
			pwm01 = 117;
			pwm02 = 113;
		}
		
		if (rc_dig_in02 < 1 && rc_dig_in01 == 1) 
		{
			pwm01 = 113;
			pwm02 = 117;
		}

		if (rc_dig_in01 < 1 && rc_dig_in02 < 1) 
		{
			pwm01 = 137;
			pwm02 = 137;
		}

Our pwm output is reversed since we are driving the robot backwards in autonomus mode. (The locations I stated above are in autonomus mode.)

The problem is our robot will not do anything if the sensors are not seeing the tape. It just stops.

We are clueless, and any help would be appreciated. (This is the first time I worked with any C++] programming other than the old “Hello, World!” program. :wink: (If you see any bugs in our code, please respond! :confused: ))

LBK Rules; VB Programmer being suddenly forced to C by FIRST (or IFI, I don’t know which). (BTW: I just got back from a meeting about an hour ago.)

Couple of problems:
First, when you’re going off the line, you correct yourself wrong. If your left sensor goes off the line, you drive the right side harder, meaning you actually go further left. That’s an easy mistake to make. :slight_smile:

Second, somebody correct me if I’m wrong, the pins are pull ups, meaning that they are normally 1, unless they recieve a signal, which makes them 0. So you need to switch the test for 0s and 1s.

Third, make the power that the motors are driven at a little higher. I’m not sure if your problem was that it wasn’t moving, but the way it is now, it will either move really slow or not at all.

P.S. Being a newbie isn’t bad. I’m on a newbie team too. :slight_smile:

The banner sensors have two signal wires, one of which is Normally Open and one of which is Normally Closed. So, his code is correct (in that aspect), assuming it is wired correctly.

Oh, yeah, forgot that. Well, make sure you have the correct wire attched.

also, remember the built-in deadzone on the Victors, which is approximately 10 in either direction, so 117 and 137 are right on the edge of this deadzone - the robot is going to move almost not at all. i’d recommend something close to 150 and 100 or so at the least. your problem is probably that you’re setting both of the motors inside the deadzone, so the robot doesn’t move.

hey i am a new team and i am i a great need is there a code for the stupid banner sensore some plz help

What sort of code? I assume you mean line following or something similar. Do a search for banner or line or something like that. There’s tons of stuff that has already been said about this sort of thing. If you can’t find what you need, post again.

The Victor 884 speed controllers have a deadpan (no movement spot) between 117 and 137 with 127 as neutral. Therefore, you are not getting outside the speed controllers “don’t move” range.

Increase the numbers to something like 90 and 164.

Phil

Our Victors don’t have a deadpan. going 107:147 makes our robot overshoot the line. (I thought the 883 had the deadpan, and not the 884.)

Our team has been trying to code the banners, and we just can’t get it to work right.

If somebody can please post some working line fowolling code, I know all of us newbies woud greatly appreciate it.