View unanswered posts | View active topics It is currently Tue Sep 23, 2014 1:30 pm






Reply to topic  [ 6 posts ] 
NXT turning angle 
Author Message
Rookie

Joined: Tue Nov 29, 2011 8:07 am
Posts: 3
Post NXT turning angle
Hi,
I don't understand why my robot is giving back a wrong value for turnedRight
the robot scans to its right until it doesn't see the obstacle anymore.
constDeg- is a constant for the number i found for turning the engine wheels into degrees...
here is a part of my program:
(The two motors are sychronized- BC)

float turnedRight=0;
//first the robot scans right
nSyncedTurnRatio=-100;
nMotorEncoder[motorC]=0;
motor[motorC] = 10;
while (SensorValue(S2)<120 && SensorValue(S2)>0);
motor[motorC] = 0;
turnedRight= nMotorEncoder[motorC]/constDeg;

at this part turnedRight always gets an angle that is too big.
if I just do this part in the program it will work, but if this part comes after the robot is walking straight it doesn't work right.

In addition- What should be the right turning speed for scanning?

THANKS SO MUCH!!!


Tue Nov 29, 2011 8:15 am
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: NXT turning angle
You need to specify more on what you want to do. What value are you getting for turnRight? What value were you expecting? What are you scanning for? What are you scanning with?

_________________
sudo rm -rf /


Tue Nov 29, 2011 12:09 pm
Profile
Rookie

Joined: Tue Nov 29, 2011 8:07 am
Posts: 3
Post Re: NXT turning angle
Ok, thanks-
I am scanning an obstacle, which will always be in front of me (90 degrees), using the sonar sensor.
I stop 15 cm before it, and scan it to the right.
I always get different values, because the obstacle is always set in a different place. but the angle i get is always too big. he also sometimes scans much too far.
the angle should never exceed 90 , but it sometimes does...
what is wrong with my scanning?


Tue Nov 29, 2011 12:24 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: NXT turning angle
I am sorry, I still don't understand the scenario exactly. Let me see if I got it:
There is an object directly in front of you.
You go forward until you're 15cm from it.
This part I'm not sure about. Do you turn to the right while scanning for another obstacle, and stop when you have found it?

_________________
sudo rm -rf /


Tue Nov 29, 2011 12:55 pm
Profile
Rookie

Joined: Tue Nov 29, 2011 8:07 am
Posts: 3
Post Re: NXT turning angle
I scan the obstacle until i don't see it anymore, I want to know how wide it is on the right part of it


Tue Nov 29, 2011 12:58 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: NXT turning angle
Ah, now I understand. Well, the ultrasonic puts out a signal which spreads in an expanding cone. Take a look at this diagram http://www.vexforum.com/wiki/index.php/ ... nge_Finder to see what I'm talking about. It's for the VEX ultrasonic, but the concept should be the same. Perhaps the sensor is picking up the edge of the object in it's far left field of 'vision'. I would also like to point out one small detail in your code. While this works:
Code:
motor[motorC] = 10;
while (SensorValue(S2)<120 && SensorValue(S2)>0);
motor[motorC] = 0;


It is usually far clearer to write this:
Code:
while (SensorValue(S2)<120 && SensorValue(S2)>0){
  motor[motorC] = 10;
}
motor[motorC] = 0;

_________________
sudo rm -rf /


Tue Nov 29, 2011 1:24 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.