2844:Hey man, our team would was wondering if you could help us out with some of the programming, as we are having troubles with it once again for this years challenge. Below is one of the many codes we have written, but we would like to be able to integrate the IR seeker into it. Would you be able to help us again?

The code is very well done. I see you really learn from last year. Good job. First, one thing at a time. I need to get more info to understand your robot design. Also, I would like to help you on the forum instead of via private message because that will also benefit other teams. So I don't have to answer similar questions from another team. You can post smaller issues than the whole thing to the forum. Here are the questions I need answers with:1. According to your pragmas, you have two IR seekers, IRleft and IRright but the IR code you have only dealt with IRright.2. Also, the center zone of the IR is 5 but your code is testing with 7. Why? Are you mounting your IR sensor straight ahead or at an angle?3. What is the RightFlap servo and what do the angle values do?

2844:1: There are two IR's on the robot, one mounted on the left, and one on the right. Allowing for different lineups from all sides. only one used per autonomous, either left side, or the right side.2: Yes, right now the IR's are on a mount that can bend back and forth until we figured out our programming issues. Right now they are at a 45 degree angle from the robot frame. Can be changed easily3: The RightFlap servo is a servo already on the bot, just being used right now to see if the coding would work when it saw the IR. Angles are just the folding down of a block flap.

Sun Jan 05, 2014 1:56 am

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Assuming the IR seeker is mounted on the side of the robot pointing to the pendulum direction so when the robot moves forward, it is moving parallel to the pendulum. Your current main code is implementing a state machine. So you could just have the state machine moving the robot forward until the IRSeeker is reading a value 5. However, because of the inaccuracy of the wide zone 5 (see thread viewtopic.php?f=52&t=2780&p=16146&hilit=IR+seeker+inaccuracy#p16146), it may be better to mount the IR seeker pointing forward where the robot is moving so that when the IR beacon is directly on the right side of the robot, the IR seeker will read a value of 8 (or 2 if the IR beacon is directly on the left side of the robot). Then, you can code the state machine to do the following:

Alright lets say the robot is facing forward, and the IR gets put on 2. It goes forward and hits the IR basket, now, what would I need to put in there for it to go forward enough to clear the baskets/ramp, and continue on? The same goes for if its put on basket 1,3, and 4, how do we get it to know to go forward enough afterwards to clear the baskets/ramp?

Do we just add the set inches forward in case 0 and 1 like we have before?

Sun Jan 05, 2014 5:43 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Team2844 wrote:

Alright lets say the robot is facing forward, and the IR gets put on 2. It goes forward and hits the IR basket, now, what would I need to put in there for it to go forward enough to clear the baskets/ramp, and continue on? The same goes for if its put on basket 1,3, and 4, how do we get it to know to go forward enough afterwards to clear the baskets/ramp?

Do we just add the set inches forward in case 0 and 1 like we have before?

Okay, what is facing forward? Facing the basket or parallel to the pendulum? Assuming you are facing the direction parallel to the pendulum, so now at step zero, the robot starts moving forward until the IR beacon is directly aligned on the side of the robot, then it transitions to step 2. Are you asking what's next? If so, let's think about it for a moment. Since you don't know which basket had the IR beacon, the only thing you can do is to note your starting encoder position before the game starts. If you zero the motor encoders at the beginning and knowing what exact spot you park your robot to begin with and how far is your robot away from the point where it can clear the pendulum (let's say 36 inches). So when you are aligned with the IR beacon, you can read the encoders and figure out how many inches you have traveled after autonomous started. So subtract it from the 36 inches, that's how much you should go forward to clear the pendulum, right?

Sun Jan 05, 2014 10:15 pm

Team2844

Novice

Joined: Mon Oct 18, 2010 9:31 pmPosts: 91

Re: IR Seeker Auto?

Yes, sorry about the confusion. We would be parallel to the pendulum, so it hits the beacon, flips the servo, then subtracts the distance traveled, and continues on around the pendulum. I'm now trying to work on programming that, yet, confusing myself again how to program it.

I have the zeroing out of the motor encoder at the beginning

So after the IR:?(nMotorEncoder[motorLeft] + nMotorEncoder[motorRight]) - drive distance still needed

I'm completely confused

I've tried something like this, but it gets stuck on step 2, flips the servo out at the right time though, and stops after the 48 inches... which is step 3, but showing step 2 on the screen, stuck.

Code:

case 0:SetIRTarget(8);SetDriveTarget(48.0);step++;break;

case 1:if (g_irseekEnabled == false){step++;}break;

case 2:servoTarget[RightFlap] = 241;step++;break;

case 3:if (g_driveEnabled == false){step++;}break;

case 4:SetTurnTarget(-90.0)servoTarget[RightFlap] = 140;step++;break;

case 5:if (g_turnEnabled == false){step++;}break;

And so on....

}

Sun Jan 05, 2014 11:28 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Team2844 wrote:

Yes, sorry about the confusion. We would be parallel to the pendulum, so it hits the beacon, flips the servo, then subtracts the distance traveled, and continues on around the pendulum. I'm now trying to work on programming that, yet, confusing myself again how to program it.

I have the zeroing out of the motor encoder at the beginning

So after the IR:?(nMotorEncoder[motorLeft] + nMotorEncoder[motorRight]) - drive distance still needed

I'm completely confused

I've tried something like this, but it gets stuck on step 2, flips the servo out at the right time though, and stops after the 48 inches... which is step 3, but showing step 2 on the screen, stuck.

First, SetIRSeekTarget is already starting the robot to move forward, so you don't need the SetDriveTarget(48.0). Basically, SetIRSeekTarget is going to move the robot forward until it reaches the IR beacon on the right side and then stopped. Then at step 2, you dump the block but it may take time to complete the dump, so you need to give it a delay (300 msec). At step 4, you read the left and right motor encoders, average them and convert it back to number of inches traveled so far. Then you subtract it from 36.0. That's how far you need to travel to clear the pendulum. Then you call SetDriveTarget to drive the robot forward that much. Then I don't know what you want to do... Probably turn some amount to go around the pendulum, then probably go forward some amount and then turn some more to point towards the ramp, then go forward some distance up the ramp...

Its still getting stuck at step 2 though. And i don't see why. The time is in there.

That, and doesn't the SetDriveTarget you have in case 4, zero the encoders when it starts its case, before looking at the left and right motor encoders values from the IR case. Making the encoders useless to look at since they would already reset?

Mon Jan 06, 2014 1:06 am

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Team2844 wrote:

Its still getting stuck at step 2 though. And i don't see why. The time is in there.

That, and doesn't the SetDriveTarget you have in case 4, zero the encoders when it starts its case, before looking at the left and right motor encoders values from the IR case. Making the encoders useless to look at since they would already reset?

Good call, you found a bug. But you already knew where it was. It got stuck in step 2. So the question is: who is supposed to advance step 2 to step 3? So the answer is: After clearing the timer, it needs to advance to step 3. So what do you think how it should be fixed? And yes, SetDriveTarget will zero the encoders but do you see we read the encoders before calling SetDriveTarget? So you shouldn't have to worry about that.BTW, there are two bugs. After fixing the "stuck at step 2", you will be stuck at step 4 as well. Same problem though.

Mon Jan 06, 2014 2:27 am

Team2844

Novice

Joined: Mon Oct 18, 2010 9:31 pmPosts: 91

Re: IR Seeker Auto?

Would it be the fact that there is no step++; in the 2 cases?

Mon Jan 06, 2014 12:03 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Team2844 wrote:

Would it be the fact that there is no step++; in the 2 cases?

Yep. If the step++ is not there, step 2 will be executed over and over again, keep setting the RightFlap angle and clearing Timer T1 over and over again. Generally, every step in a state machine should have a way to get out of that state and move on to another one.

Mon Jan 06, 2014 2:51 pm

Team2844

Novice

Joined: Mon Oct 18, 2010 9:31 pmPosts: 91

Re: IR Seeker Auto?

Alright. I added in the step++; to the cases, but im running into a new problem. After it does the IR, it comes out readin negative -35inches, when really it ran 35 inches forward. Now, when it tries to go the 65 inches that I have set in. It really is telling itself 100 inches, since its starting from -35in. Working on fixing this.. trying to atleast.

Mon Jan 06, 2014 8:33 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: IR Seeker Auto?

Make sure you connected the motors with the correct polarity (i.e. red wire goes to + and black goes to - on the Tetrix motor controller). If the wiring is correct, run the following program and manually rotate the wheels and see what the encoder numbers look like. Also make sure the encoders are connected in the correct orientation.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum