Optical Distance Sensor

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

Optical Distance Sensor

Postby airglide » Fri Nov 09, 2012 5:09 pm

hello everyone,

We're programming a robot that follows a wall. If the measurements of the sensor on the top are (<40 centimeters) the robot should turn. So the robot checks while driving if there is a wall in front of him. The program works to a specific point, where the robot finds measurements ( < 40 centimeters) and turns, but theres nothing in front of him.

We've tried to do more than one measurement but we have to do over 8 measurements to get a good result.

My question is now, is it the sensor which have noise (or something like that) or does our program fail.

thank you for your help

Code: Select all
while(true)
{
                                Color tmpCol = cs.getColor();
                                if(...) //tmpCol == green/red
                                {
                                        break;
                                }
                               double test = ops1.getDistance()/10.0;
                               Delay.msDelay(50);
                                if(test < distToWallTarget)
                                {
                                      //turn
                                }
}
airglide
New User
 
Posts: 19
Joined: Sun Mar 04, 2012 2:09 pm

Re: Optical Distance Sensor

Postby Aswin » Fri Nov 09, 2012 9:50 pm

Hi,

What kind of sensor are you using? Could this be a Sharp IR basedMindsensors? Did you calibrate it yourself?

How do you process these eight samples to get a good result?

How often do these misreadings occur? Do you get a specific value then?

Maybe the sensor reads the distance to the floor sometimes.

Anyways, it surely helps to log the samples, I like to use the NXTChartingLogger that is included in lejos.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Optical Distance Sensor

Postby gloomyandy » Sat Nov 10, 2012 1:00 pm

If it is the mindsensor one then it can be very sensitive to battery voltage. What other sensors are you using? I found that using this sensor at the same time as an NXTCam resulted in very poor readings. As Aswin said it is best to log the actual readings and try and work out what is going one. You may also want to try writing some simple test programs and testing each sensor in turn, both with and without other sensors attached, and perhaps with and without the motors running...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Optical Distance Sensor

Postby airglide » Sat Nov 10, 2012 2:37 pm

thank you for your great answers, it seems that the sensor somehow measures the floor even if the distance isn't really correct and goes up and down (from 35cm to 90cm) even if the sensor isn't moving.
We're using a middelrange mindsensor and we didn't calibrate it (could that help?). There's no specific value that occurs. We're using alot of sensors, three midrange mindsensor and a colorsensor. But we've tried it out with a simple program (and only one sensor). We've managed to reduce the occuring of errors by stabilazing the sensor. But we can't really explain why the value jumps up and down...

airglide
airglide
New User
 
Posts: 19
Joined: Sun Mar 04, 2012 2:09 pm

Re: Optical Distance Sensor

Postby Aswin » Sun Nov 11, 2012 12:31 am

Hi,

It's worth taking a look at the graphs in the datasheet. These tell that the sensor is less accurate at longer (>40cm) ranges. You might be using the sensor outside its effective range.

You can calibrate the sensor but I don't think it helps with your problem. You'll risk new problems, so better not.
My NXT blog: http://nxttime.wordpress.com/
Aswin
Active User
 
Posts: 122
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff