Subject:
|
Problems with "built-in" IR proximity sensor
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Mon, 29 Nov 1999 20:40:41 GMT
|
Original-From:
|
Stefano Franchi <franchi@csli.Stanford.EDU>
|
Viewed:
|
781 times
|
| |
| |
Hi all,
I have been trying to use the IR beam + light detector to simulate an
IR proximity sensor, as suggested by many. However, I don't seem to
succeed, no matter what I try. I wonder if anyone on the list has
experienced problems before getting it to work.
I use NQC on a Mac, BTW.
I have tried several slightly different pieces of code before finally
settling on the "Ping" driver provided by Mark Overmars, which goes
as follows (this is NQC 1.0, of course):
/*
* Ping
* ====
* Adapted from a program by Dave Chen and Simen Svale Skogsrud
*
* This program assumes that the light sensor is on IN_2 and
* that it points in the same direction as the infrared connection
* on the robot. It beeps when the robot gets close to an obstacle.
* This is done by repeatedly sending IR messages. These cause a
* large fluctuation in light intensity.
*
* This is a nice mechanism to find a close by wall without bumping
* in to it.
*/
#define THRESHOLD 200 // Making this larger decreases the distance
int lastlevel;
task Ping
// Constantly test whether there is a high fluctuation
{
Sensor(IN_2,IN_CFG(STYPE_LIGHT, SMODE_RAW));
lastlevel = 0;
while(true)
{
SendMessage(0);
if(lastlevel > IN_2)
{
// Close to something
PlaySound(1);
Sleep(30);
}
lastlevel = IN_2;
lastlevel -= THRESHOLD;
}
}
task main
{
start Ping;
}
So the idea is that when the robot is facing open space the
IR beam gets lost and doesn't influence the light sensor, whereas
when facing a wall the light sensor reads ambient light + IR
reflected light,
Unfortunately, I never detect a fluctuation in my readings.
I ran the program with datalogs on "lastlevel" and the light sensor
and I always get about the same values, no matter whether I am close
to a wall or not. The light sensor always gives a reading of about
700 (in raw mode, of course), when placed in a moderately illuminated
room. I am starting to think that the light sensor may be defective
or that the IR beam may not be strong enough. Any idea on how to find
out what's wrong?
Thanks to all,
Stefano
_________________________________________________________
Stefano Franchi
Department of Philosophy Phone: Off: (650) 723-0855
Stanford University Home: (650) 497-2812
Stanford, CA 94305 Fax: (650) 723-0985
USA
e-mail: franchi@csli.stanford.edu
http://spiel.stanford.edu
|
|
Message has 1 Reply:
Message is in Reply To:
8 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|