| Author |
Message |
|
amcerbu
Novice
Joined: Sun Oct 21, 2012 10:01 pm Posts: 76
|
 Re: NXT Light Sensor IR
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 am Posts: 1023
|
 Re: NXT Light Sensor IR
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 pm Posts: 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:  |  |  |  | Code: #pragma config(Hubs, S1, HTMotor, HTServo, none, none) #pragma config(Sensor, S2, irSeeker, sensorI2CCustom) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C2_1, servo1, tServoNone) #pragma config(Servo, srvo_S1_C2_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone) #include "drivers/hitechnic-irseeker-v2.h" #define IRSEEKER_KP 10 #define FORWARD_POWER 50 #define BOUND(n) (((n) < -100)? -100: ((n) > 100)? 100: (n)) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main() { bMotorReflected[motorD] = true; bMotorReflected[motorE] = false;
int prevDir = HTIRS2readACDir(irSeeker); while (true) { int currDir = HTIRS2readACDir(irSeeker); if (currDir == 0) {
currDir = prevDir; }
int turnPower = (5 - currDir)*IRSEEKER_KP; motor[motorE] = BOUND(FORWARD_POWER + turnPower); motor[motorD] = BOUND(FORWARD_POWER + turnPower); prevDir = currDir;
wait1Msec(100); } } |  |  |  |  |
|
| Sun Dec 09, 2012 7:05 pm |
|
 |
|
Alder
Rookie
Joined: Thu Oct 04, 2012 8:51 pm Posts: 22
|
 Re: NXT Light Sensor IR
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
Rookie
Joined: Tue Dec 11, 2012 9:19 pm Posts: 14
|
 Re: NXT Light Sensor IR
+1. It is pretty much impossible to align to the peg using the IR beacon alone. That's why the FTC people put white tape on the platform. The IR beacon can be used to determine only which peg the beacon is on. This can be accomplished by dead reckoning to the center of the platform, orienting the receiver straight on and then taking a single reading. If your dead reckoning is done right, if the beacon is on the center peg, you should see a reading of 5, less than that and the beacon is on the left peg, greater, on the right. You may then use a light sensor to find the appropriate white line to align precisely with the peg.
|
| Mon Dec 24, 2012 12:39 am |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 Re: NXT Light Sensor IR
 |  |  |  | skatefriday wrote: +1. It is pretty much impossible to align to the peg using the IR beacon alone. That's why the FTC people put white tape on the platform. The IR beacon can be used to determine only which peg the beacon is on. This can be accomplished by dead reckoning to the center of the platform, orienting the receiver straight on and then taking a single reading. If your dead reckoning is done right, if the beacon is on the center peg, you should see a reading of 5, less than that and the beacon is on the left peg, greater, on the right. You may then use a light sensor to find the appropriate white line to align precisely with the peg. |  |  |  |  |
Actually, it is possible to seek and go to the IR beacon peg with IR seeking alone. Our team did it. Here are a few videos demonstrating that. http://www.youtube.com/watch?v=ou8zFzWXQ7Ihttp://www.youtube.com/watch?v=QJxVKs7WrBghttp://www.youtube.com/watch?v=tSgsu24BEd8http://www.youtube.com/watch?v=XFNdUPryXh4
|
| Mon Dec 24, 2012 2:33 am |
|
 |
|
ethanTesla
Rookie
Joined: Wed Oct 05, 2011 2:49 pm Posts: 12
|
 Re: NXT Light Sensor IR
How consistently does your autonomous score? Greater than 80%?
|
| Tue Feb 12, 2013 1:07 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|