Question

I have a toy car that has an arduino and 4 Ultrasonic Range Finder sensors in front, rear and both sides, they give me the distance to a wall if any exist within the range that the sensor covers, the sensors give me this data in short intervals, the car has to move around a room and plot the outline, the rooms can have columns and be kind of irregular, I don't know the algorithms involved in this plotting, any insight would be appreciated.

Was it helpful?

Solution

heh once did a robot that was almost the same :)
bud it could turn around at one place (no turning radius)
so it was easy to drive and map environment
in your case hard to say because we do not see the car kinematics

anyway some hints:

1.while doing ultrasonic listening you should have your motors quiet

  • I used stepper motors so their pulses could be heard in receiver
  • if you use DC motor then this could be very tricky (may be you will need to do full stop)
  • or determine which echo is echo and which commutator noise
  • with brushless (BLDC) and sinusoidal driving is all OK
  • but PWM or any other impulse driving will create the same problems
  • so you need to synchronize listening times and pulse noisse times
  • without proper measure equipment will this be extremly hard (Oscilloscope is ideal for this)

2.ultrasound emitters

  • to avoid many confusions
  • either use only one at a time
    • this is easy but slow
  • or all at once and wait for first receive only
    • in this way you do not get the data from far echoes
  • it is possible to receive from all sides but it need a fairly complex filtering
  • try to optimize the receiving loop as much as you can
  • I did it in few T of the MCU which give me about 4 mm resolution
  • but it was a long time ago and the ATMEL used was old 51 clone running on 20 MHz only
  • dont know about arduino (preffer UC3) but todays MCUs are more than 10 times faster with much better timings.

3.movement

  • you will need to code movement manoeuvres
  • forwad/backward by constant step
  • turn left/right by 90 degrees
  • their must be as accurate as you can code
  • in suitable environment you can use ultrasound to be more accurate (need perpendicular sides only and no problematic material inside)
  • with these you can start mapping your 2D maze

4.mapping the room

  • create 2D map of the environment
  • you can do it by cell or vector approach
  • I strongly recommend the cell access (it is less accurate but easier for starters)
  • map can be 2D array
  • with values unknown,space,wall

    1.init

    • place the car perpendicular to some wall
    • clear map with unknown
    • set position in the middle of map (x,y)

    2.echo-locate all sides

    • if wall is found mark it in the map on (x,y)+(distance * side vector)
    • and mark all space between x,y and the wall mark as space
    • if no wall found then mark as space all cells in the map from x,y to (x,y)+(safe range*side vector)
    • side vectors can be: front(0,+1), back(0,-1), left(-1,0), right(+1,0)
    • safe range is distance from your car where wall is always detected in [cells]
    • distance is measured distance of wall in [cells]
    • do not forget to add the emitter/receiver offsets from the car position into account
    • also mark current position (x,y) as space

    3.find any or closest or fastest to move cell marked as unknown but neighbouring space cell

    • if none such found then the mapping is finished (blink by LED or do some crazy move to signal it)
    • if found then plan path and move car to it
    • set position x,y to it

    4.goto 2

now just mine the data from MCU to PC and view it

[notes]

  • there is much what can be added to improve this ...
  • beware fabric/cloth like materials
  • they are very hard to detect by ultrasound
  • for emitters use their required frequency to maximize their performance
  • for impulse echolocation the best power/accuracy/range ratio for emitting is 7 pulses
  • no one knows why but it is the best (at least for all applications and equipment I know of)

Have fun :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top