# distance sensing navigation algorithms anyone?

Hey guys. Now that I have my robot base working (3D printed base & caterpillar tracks and turns on a carpet!! wohoo) I am attempting to add some intelligence.

First step is some pointless and continuous wandering around without bumping into things using a sharp IR distance sensor on a small servo.

Can anyone point me to some algorithms for said navigation using a distance sensor. Even high level pseudo code (probably preferred) would be good to compare with my currently non-functioning navigation approach.

cheers

AgeingHippy:
Hey guys. Now that I have my robot base working (3D printed base & caterpillar tracks and turns on a carpet!! wohoo) I am attempting to add some intelligence.

First step is some pointless and continuous wandering around without bumping into things using a sharp IR distance sensor on a small servo.

Can anyone point me to some algorithms for said navigation using a distance sensor. Even high level pseudo code (probably preferred) would be good to compare with my currently non-functioning navigation approach.

cheers

Completely untested pseudocode:

``````Loop:

While (Read Distance From Sensor) < MinimumDistance

MoveBackwardBySmallAmount

TurnByRandomAmountRandomlyLeftOrRight

End If

MoveForward
``````

Hi All

I would still like some pointers to navigation algorithms that are proven to work.

My current process is roughly as follows

``````main loop {
if first time in main loop { navigate() }
else { scanWhileDriving() }
}

navigate() {
scanForPath()
turnTowardsPath()
}
goForeward
}

scanWhileDriving() {
Scan 30 degrees each side of straight ahead (60 deg  to 120 deg)
if anything closer than collisionThreshold detected {
stop
navigate()
}
}

Scan at [60, 75, 90, 105, 120] degrees (90 being straight ahead)
if anything closer than clearPathThreshold { return false }
else { return true }
}

scanForPath() {
Scan 80 degrees each side of straight ahead ( 10 deg to 170 deg)
Return furthest distance >= clearPathThreshold and angle distance found at
}

turnTowardsPath() {
turn leftOrRightBasedOnAngle until furthestDistance found
}
``````

I would appreciate any comments or pointers or even some grown-up navigation algorithms...

I placed the while not clearAhead in the navigate loop because when it turns towards the clear distance it stops turning when the wheels will still have collision danger...

I'm working on the same thing. I building a robotic lawnmower. Have a look at SLAM. I'm using a sonic sensor because I think it can give me better range and more accurate. I will use IR to sense close objects perhaps from behind. I have the sensor mounted so I can pan and tilt. There are a few other techniques if you google but I thought SLAM was the best choice for me.

Have you considered taking a braitenberg vehicle approach, this works pretty well for obstacle avoidance.

http://en.wikipedia.org/wiki/Braitenberg_vehicle

Or perhaps Potential Fields would be more suitable - have a read of "AI Robotics" by Robin Murphy, this is a good reference book as a starter and it pretty readable.