You can tell the program which motors are flipped in the "Motor and Sensor Setup" window, where you configure controllers. There're checkboxes on the right that allow you to enable specific options for each motor.

Thu Dec 06, 2012 7:45 pm

MHTS

Guru

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

Re: NXT Light Sensor IR

Alder wrote:

Just a question for programs like this, will it always work to use

Code:

bMotorReflected[motorD] = true; bMotorReflected[motorE] = false;

Or will sometimes I have to do something else like in this code?By the way, thx for all the help.

I don't use bMotorReflected. It should work but I would recommend doing this only with the Motor and Sensor setup dialog which will generate the pragmas with the correct "reversed" keyword. Don't mix them. Use one or the other or you will confuse yourself (or others) pretty quickly. I would still recommend doing it the pragma way because that's a single place you need to go check for the motor polarities. If you use bMotorReflected, then you have to search all over the code to see where, when and who is programming the motor with different polarities. Imagine the scenario where you program a motor with bMotorReflected in one code path and then forgot about it. Later on you decided the polarity of a motor was wrong and you program it again with bMotorReflected in another code path. Very soon, you will have bugs when you execute one code path, the motor turns one way, but another code path, the motor turns the other way. That would be very messy to debug.

Thu Dec 06, 2012 7:52 pm

Alder

Rookie

Joined: Thu Oct 04, 2012 8:51 pmPosts: 22

Re: NXT Light Sensor IR

K, so when I change the code to work with the flipped motors, it just goes forward instead of spinning around and does nothing if the IR sensor is right in front of it. How do I get it to just stand still until the IR beacon is turned on?Code:

Nevermind!I finally understood what was wrong.Thanks again for all the help! (and bearing with my very slow understanding)

Tue Dec 11, 2012 5:37 pm

skatefriday

Novice

Joined: Tue Dec 11, 2012 9:19 pmPosts: 58

Re: NXT Light Sensor IR

MHTS wrote:

The above code will keep driving towards the IR. Obviously, you need to determine and add code on when it should stop. Also note that zone 5 of the IR seeker is quite wide. So although the code above will eventually reach the IR beacon, it is highly likely that it will approach the IR beacon at an angle. So your robot will probably not facing the peg directly in front.

+1. It is pretty much impossible to align tothe peg using the IR beacon alone. That's whythe FTC people put white tape on the platform.

The IR beacon can be used to determine onlywhich peg the beacon is on. This can be accomplishedby dead reckoning to the center of the platform, orientingthe receiver straight on and then taking a single reading.

If your dead reckoning is done right, if the beacon ison the center peg, you should see a reading of 5, lessthan that and the beacon is on the left peg, greater, onthe right.

You may then use a light sensor to find the appropriatewhite line to align precisely with the peg.

Mon Dec 24, 2012 12:39 am

MHTS

Guru

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

Re: NXT Light Sensor IR

skatefriday wrote:

MHTS wrote:

The above code will keep driving towards the IR. Obviously, you need to determine and add code on when it should stop. Also note that zone 5 of the IR seeker is quite wide. So although the code above will eventually reach the IR beacon, it is highly likely that it will approach the IR beacon at an angle. So your robot will probably not facing the peg directly in front.

+1. It is pretty much impossible to align tothe peg using the IR beacon alone. That's whythe FTC people put white tape on the platform.

The IR beacon can be used to determine onlywhich peg the beacon is on. This can be accomplishedby dead reckoning to the center of the platform, orientingthe receiver straight on and then taking a single reading.

If your dead reckoning is done right, if the beacon ison the center peg, you should see a reading of 5, lessthan that and the beacon is on the left peg, greater, onthe right.

You may then use a light sensor to find the appropriatewhite line to align precisely with the peg.

Who is online

Users browsing this forum: No registered users and 1 guest

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