Author Topic: 2D mapping with 4 IR sensors  (Read 2222 times)

0 Members and 1 Guest are viewing this topic.

Offline gfscustomsTopic starter

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 0
2D mapping with 4 IR sensors
« on: August 07, 2009, 11:59:22 AM »
I am working on coding my IR sensors for distance readings and eventually mapping.

I have one servo with 4 IR sensors aiming Front,Back,Left,right mounted on it.

I plan on sweeping the servo from 0deg, to 90deg, and taking a measurement from each IR every 5 deg. This shoud cover a 360deg area with the IR's.

I've read the tutorial on this and search the forum, but does anyone have a code example of how this is accomplished?

on my microcontroller it streams the IR data from the time I enable them, so I don't need to send any commands to turn them on and off to take an individual reading.

I suppose I just need to query my servo position, so when it is @ a 0 angle, record the sensor stream data, when it's at a 5deg angle, record sensor stream data... etc..

and then just put these values into arrays for each sensor...

A code example would be great though, just so I could see how someone else does this.


Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,702
  • Helpful? 173
    • Society of Robots
Re: 2D mapping with 4 IR sensors
« Reply #1 on: August 07, 2009, 02:45:35 PM »
My Hypersquirrel used two Sharp IRs, and my Fuzzy used three. The code for Fuzzy is on SoR.

Since its on a rotating servo, save the data in a 2D matrix representing polar coordinates.

Its exactly like doing it with one sharp IR, but you read two sensors instead of one, and save the data into two locations in the matrix at a time instead of one.

Processing the data is exactly the same.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: 2D mapping with 4 IR sensors
« Reply #2 on: August 14, 2009, 03:46:30 PM »
I actually had a quite good exp in mapping ,
my advice to you is do not use hobby servo motor if  you are looking for precise mapping.why? simply because the angle - pulse width function of them are not really linear. this means that the servo motor is not really a linear system.
Use steppers, steppers make precise steps so you dont have to wprry about angles.
at eah angle read adc signals then move to the next angle. step by step you save your sensor data in an array
uhm uhm,, actually make 2 arrays,
one for ranges and the other you save in it the angles

ranges=[23 44 45 45 43 43 32 2 3 2 2 2 2];
angles=[0 5 10 15 20 .....................  355];

now we have polar data
simply calculate cartesian data (X,Y) to plot area in 2D mapping

good ol' BeNNy


Get Your Ad Here