3D Obstacle Avoiding Robot

Robo_Maker

New Member
This robot can avoid obstacles in 3d space, including but not limited to: gaps, tall objects, etc. The robot is build in such a way that the two servos can rotate the PING ultrasonic range finder 180 degrees horizontally and vertically. Therefore, the robot can be programed to avoid obstacles smarter than usual 2d robots, where the range finder rotates left and right only.


IMG_1058 - Copy.png


The 3D Version program is shown at 3:00 minuites
 

erco

Senior Member
Bravo Robo_Maker! Kudos for a great looking bot and a great video. Love that table edge-sensing!
 

techElder

Well-known member
Looks like your ultrasonics is trying to measure too much in the "near field" of the transducers.

Amazing robot, though. Pat yourself on the back for me! :D
 

Robo_Maker

New Member
Looks like your ultrasonics is trying to measure too much in the "near field" of the transducers.

Amazing robot, though. Pat yourself on the back for me! :D
The 3d program is mean to scan under the tracks for and gaps or obstacles. If there is an obstacle, it is meant to stop and scan further.
Thanks for the feedback :)
 

stan74

Senior Member
Nice robot. It keeps bumping into things though :) Are you using a tamiya motor gear box? I built one and it goes too fast. Yours must be 210:1 which is what I wanted,they're so fiddly to build 1st time.
I ignore raw range below 50 with the US on my robot..spurious readings..zeros,fours etc.
I spent ages tweaking my robots code. Have fun!
I'm building a tracked and stepper motor robot,plenty of time to react.Here's mine which is not bad for it's speed. https://youtu.be/SQABIPBx5Ug
 
Last edited:

stan74

Senior Member
Looking at your video I can guess what the robot is doing when it detects/searches objects. It seems to reverse until the object disappears. As it reverses try moving the servo so it detects the object again then reverse more.
If an object detected left then keep servo--turn right until object gone
move servo left to see object and repeat above
move servo more left to detect object again then do above again
now front should be clear, it may not
so move servo right and test for object and move left until it's gone
do same for object detected left
if the object is ahead..if servo>130 and servo<170 then it's forward....saferange=480;-change saferange
else it's left or right....saferange=500;-------------------------------------------------------ahead less saferange
If object is not left or right then it must be ahead so
random w0; toss a coin,left or right...keeps it interesting.
if b0<127 then check left-if clear go left else go right
else if right clear then go right else go left
if left decided then the servo is still pointing at the object it detected so
turn left until object gone
then turn servo right to point at object again and go left until object gone
if turn right is chosen then turn servo left to point at object again and go right until object gone
this algorithm made my robot run pretty well.
Do you want my code?
Tweaking is the way to go,new ideas will occur. Loads o' fun.Let us know improvements.
 
Last edited:

stan74

Senior Member
I check the sonar and move the servo every main program loop but this wouldn't work for your robot.
Just a thought..you could use a servo scanning left right on a servo that makes it scan up down..bit late now but would be faster.
At 62, I'm still impetuous, build 1st then code :(
Code:
[color=Black]rotateradar:[/color]
[color=Blue]gosub [/color][color=Black]ping[/color]
[color=Blue]if [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]+ [/color][color=Navy]5
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]200 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]endif
else  let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]- [/color][color=Navy]5
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]100 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1
      [/color][color=Blue]endif
endif
servopos [/color][color=Black]servopin,radarpos[/color]
[color=Blue]return[/color]
[color=Black]ping:[/color]
[color=Blue]high [/color][color=Black]pingecho [/color][color=Green];---- check ahead blocked[/color]
[color=Blue]pulsin [/color][color=Black]pingecho,[/color][color=Navy]1[/color][color=Black],range[/color]
[color=Blue]pause [/color][color=Navy]9[/color]
[color=Blue]if [/color][color=Black]range [/color][color=DarkCyan]<[/color][color=Navy]2 [/color][color=Blue]then goto [/color][color=Black]ping [/color][color=Green];----out of range[/color]
[color=Blue]return[/color]
 

stan74

Senior Member
In your video the robot can't see things ahead because they are at an angle and the sound is bouncing away so check the sides more, to get some response/reaction. Cloth absorbs ultra sound as well.
 

Robo_Maker

New Member
Nice robot. It keeps bumping into things though Are you using a tamiya motor gear box? I built one and it goes too fast. Yours must be 210:1 which is what I wanted,they're so fiddly to build 1st time.
I ignore raw range below 50 with the US on my robot..spurious readings..zeros,fours etc.
I spent ages tweaking my robots code. Have fun!
I'm building a tracked and stepper motor robot,plenty of time to react.Here's m
Hi, Thanks. you have a very nice robot too.
I am using Tamiya gearbox on 58 and Instant Motor Shield, so I can control the speed of motors. The 210 ratio couldn't make the robot turn on the carpet from the steady position, so I had to start with both motors and then turn :). Also, with 58 ratio it can go over the small obstacles very well :). You are right - it still bumping on some conditions. I have progrmmed the feature called "autocorrection" so it does half tern left and half turn right in order to find the "best" (longest distance) way to go, while advancing forward. It works really nice in open space, since the robot turns without stopping. It is very complex to make the "universal" algorithm for all existing conditions, so instead I am doing task related algorithms like detecting the hight of the object and making the decision to go over it or to make a turn.
 

Robo_Maker

New Member
I check the sonar and move the servo every main program loop but this wouldn't work for your robot.
Just a thought..you could use a servo scanning left right on a servo that makes it scan up down..bit late now but would be faster.
At 62, I'm still impetuous, build 1st then code :(
Code:
[color=Black]rotateradar:[/color]
[color=Blue]gosub [/color][color=Black]ping[/color]
[color=Blue]if [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]+ [/color][color=Navy]5
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]200 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]endif
else  let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]- [/color][color=Navy]5
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]100 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1
      [/color][color=Blue]endif
endif
servopos [/color][color=Black]servopin,radarpos[/color]
[color=Blue]return[/color]
[color=Black]ping:[/color]
[color=Blue]high [/color][color=Black]pingecho [/color][color=Green];---- check ahead blocked[/color]
[color=Blue]pulsin [/color][color=Black]pingecho,[/color][color=Navy]1[/color][color=Black],range[/color]
[color=Blue]pause [/color][color=Navy]9[/color]
[color=Blue]if [/color][color=Black]range [/color][color=DarkCyan]<[/color][color=Navy]2 [/color][color=Blue]then goto [/color][color=Black]ping [/color][color=Green];----out of range[/color]
[color=Blue]return[/color]
I have some similar function, but I have 2 servos instead for horisontal and vertical move. The range is from -90 to +90 degrees on horisontal and from -90 to ~+45 on vertical range. The ultrasonic is attached at 45 degrees angle to the "arm" in order to let him look 90 degrees down, since if you mesure the disance down at the angle > -45 the waves are getting reflected from the surface and not comming back :)
 

Robo_Maker

New Member
In your video the robot can't see things ahead because they are at an angle and the sound is bouncing away so check the sides more, to get some response/reaction. Cloth absorbs ultra sound as well.
Yes, you are right, the cloth pillows are very difficult obstacles to avoid as they absorbs ultra sound and reflect it badly due to the pillow's material and shape.
 

Robo_Maker

New Member
Looking at your video I can guess what the robot is doing when it detects/searches objects. It seems to reverse until the object disappears. As it reverses try moving the servo so it detects the object again then reverse more.
If an object detected left then keep servo--turn right until object gone
move servo left to see object and repeat above
move servo more left to detect object again then do above again
now front should be clear, it may not
so move servo right and test for object and move left until it's gone
do same for object detected left
if the object is ahead..if servo>130 and servo<170 then it's forward....saferange=480;-change saferange
else it's left or right....saferange=500;-------------------------------------------------------ahead less saferange
If object is not left or right then it must be ahead so
random w0; toss a coin,left or right...keeps it interesting.
if b0<127 then check left-if clear go left else go right
else if right clear then go right else go left
if left decided then the servo is still pointing at the object it detected so
turn left until object gone
then turn servo right to point at object again and go left until object gone
if turn right is chosen then turn servo left to point at object again and go right until object gone
this algorithm made my robot run pretty well.
Do you want my code?
Tweaking is the way to go,new ideas will occur. Loads o' fun.Let us know improvements.
Yes, this is close to what have been done in 1st 2d algorithm, except that "autocorrection" feature which I mentioned in another post. (The vehicle can correct its way toward more open space)

AUTOCORRECTION
===========
dist_forward = CHECK_DIST
IF dist_forward > DIST_CLEAR THEN
SrfHalfTurnLeft ''' moves SRF Only, but keep going forward
dist_left = CHECK_DIST
SrfHalfTurnRight
dist_Right = CHECK_DIST

IF dist_left > dist_right THEN
if dist_left > dist_forward THEN
HalfTurnLEFT '' turn the vehicle half left
END IF
ELSE
if dist_right > dist_forward THEN
HalfTurnRIGHT '' turn the vehicle half right
END IF
END IF


END IF

So basically I am checking 5 positions LEft, HalfLeft, Center, HalfRight and Right at 2d algorithm. In the 3-D algorithm it is also looking under the left and right tracks while advancing forward to avoid sleeping from the table's edge.


P.S. And YES , please share your code :)
 
Last edited:

stan74

Senior Member
Hi. Robots I build never work as planned and I spend time rewriting it. I inc/dec the servo 8mS every main loop so get 222-78 that's 18 sonar checks from left to right which is a compromise to scan as much as possible. By trial and error I found a wide scan and changing the saferange for different positions helped. I also used the robots and motors momentum a bit meaning it behaves better on a vinyl floor than on carpet.
I think I'll add a vertical servo to a horizontal servo to scan left move down,scan right,move down,scan left etc. I had to point the sonar slightly up because it saw the carpet.
Code:
[color=Green];ultrasonic on servo robot
;pins c.1 and c.2 were pwm.Now turns motors on/off.
;pins b.6 and b.7 1=forward 0=reverse[/color]
[color=Black]init:[/color]
[color=Navy]#picaxe [/color][color=Black]28x2[/color]
[color=Blue]symbol [/color][color=Black]servopin [/color][color=DarkCyan]= [/color][color=Blue]B.5 [/color][color=Green];servo pin[/color]
[color=Blue]symbol [/color][color=Black]pingecho [/color][color=DarkCyan]= [/color][color=Blue]C.5
symbol [/color][color=Black]lmotordir [/color][color=DarkCyan]= [/color][color=Blue]B.6
symbol [/color][color=Black]rmotordir [/color][color=DarkCyan]= [/color][color=Blue]B.7
symbol [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Purple]b2 [/color]
[color=Blue]symbol [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Purple]b3[/color]
[color=Blue]symbol [/color][color=Black]range [/color][color=DarkCyan]= [/color][color=Purple]w3[/color]
[color=Blue]symbol [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Purple]w4[/color]

[color=Blue]let [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Navy]420[/color]
[color=Blue]let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]150 [/color][color=Green]; mid 75 left 225 right[/color]
[color=Blue]let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1[/color]
[color=Blue]servo [/color][color=Black]servopin,[/color][color=Navy]150 [/color][color=Green];---- point radar ahead[/color]
[color=Blue]pause [/color][color=Navy]5000[/color]
[color=Blue]for [/color][color=Purple]b0 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]to [/color][color=Navy]60
      [/color][color=Blue]gosub [/color][color=Black]rotateradar[/color]
[color=Blue]next [/color][color=Purple]b0[/color]

[color=Blue]let [/color][color=Purple]w5 [/color][color=DarkCyan]= [/color][color=Purple]timer [/color][color=Green]; random[/color]
[color=Black]main: [/color][color=Green];----------------------- START ------------------[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2[/color][color=Black]:[/color][color=Blue]high [/color][color=Black]rmotordir:[/color][color=Blue]high [/color][color=Black]lmotordir [/color][color=Green]; motors forward[/color]
[color=Blue]gosub [/color][color=Black]rotateradar
 [/color]
[color=Green];---- set saferange for different directions[/color]
[color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]>= [/color][color=Navy]130 [/color][color=Blue]then
      if [/color][color=Black]radarpos [/color][color=DarkCyan]<= [/color][color=Navy]170 [/color][color=Blue]then
            let [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Navy]430 [/color][color=Green]; front
      [/color][color=Blue]endif
else  let [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Navy]470 [/color][color=Green]; left and right[/color]
[color=Blue]endif[/color]

[color=Green];--- test for obstacles [/color]
[color=Blue]if [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Blue]then [/color][color=Green];---- ahead is clear
      [/color][color=Blue]goto [/color][color=Black]main[/color]
[color=Blue]endif[/color]

[color=Green];ahead blocked[/color]
[color=Blue]gosub [/color][color=Black]brake[/color]

[color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]> [/color][color=Navy]170 [/color][color=Blue]then [/color][color=Green];--- blocked left
      [/color][color=Blue]goto [/color][color=Black]turnright    [/color]
[color=Blue]elseif [/color][color=Black]radarpos [/color][color=DarkCyan]< [/color][color=Navy]130 [/color][color=Blue]then [/color][color=Green];--- blocked right
      [/color][color=Blue]goto [/color][color=Black]turnleft[/color]
[color=Blue]endif 
      [/color]
[color=Green];---- ahead blocked so random test turn left or right[/color]
[color=Blue]low [/color][color=Black]lmotordir,rmotordir[/color]
[color=Blue]pause [/color][color=Navy]15[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.2

random [/color][color=Purple]w5[/color]
[color=Blue]if [/color][color=Purple]b10 [/color][color=DarkCyan]< [/color][color=Navy]128 [/color][color=Blue]then
      servopos [/color][color=Black]servopin,[/color][color=Navy]100 [/color][color=Green];point radar far right
      [/color][color=Blue]gosub [/color][color=Black]ping
      [/color][color=Blue]if [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Blue]then [/color][color=Green];---- right is clear
            [/color][color=Blue]goto [/color][color=Black]turnright
      [/color][color=Blue]else
            goto [/color][color=Black]turnleft
      [/color][color=Blue]endif
else servopos [/color][color=Black]servopin,[/color][color=Navy]200 [/color][color=Green];---- point radar far left
      [/color][color=Blue]gosub [/color][color=Black]ping
      [/color][color=Blue]if [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Blue]then [/color][color=Green];---- left is clear
            [/color][color=Blue]goto [/color][color=Black]turnleft
      [/color][color=Blue]else
            goto [/color][color=Black]turnright
      [/color][color=Blue]endif
endif [/color]
[color=Green];......................................................[/color]
[color=Black]turnright:[/color]
[color=Blue]high [/color][color=Black]lmotordir:[/color][color=Blue]low [/color][color=Black]rmotordir:[/color][color=Blue]let [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Navy]470[/color][color=Black]:[/color][color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]170 [/color][color=Green];---- point radar left[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateright:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange:[/color][color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]170 [/color][color=Green];---- point radar more left[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateright:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange:[/color][color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]215 [/color][color=Green];---- point radar full left[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateright:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Green];---- spin clockwise until no object to full left[/color]

[color=Blue]let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]126[/color][color=Black]:[/color][color=Blue]let [/color][color=Black]radardir[/color][color=DarkCyan]=[/color][color=Navy]1[/color][color=Black]:[/color][color=Blue]servopos [/color][color=Black]servopin,radarpos [/color][color=Green];---- point radar right[/color]

[color=Blue]goto [/color][color=Black]main[/color]
[color=Green];......................................................[/color]
[color=Black]turnleft:[/color]
[color=Blue]low [/color][color=Black]lmotordir:[/color][color=Blue]high [/color][color=Black]rmotordir:[/color][color=Blue]let [/color][color=Black]saferange [/color][color=DarkCyan]= [/color][color=Navy]470[/color][color=Black]:[/color][color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]150 [/color][color=Green];----point radar ahead[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateleft:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Green]; ---- spin anti-clockwise until no object ahead[/color]

[color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]110 [/color][color=Green];---- point radar right[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateleft:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Green]; ---- spin anti-clockwise until no object to more right[/color]

[color=Blue]servopos [/color][color=Black]servopin,[/color][color=Navy]85 [/color][color=Green];---- point radar full right[/color]

[color=Blue]do[/color][color=Black]:[/color][color=Blue]gosub [/color][color=Black]scanrotateleft:[/color][color=Blue]loop until [/color][color=Black]range [/color][color=DarkCyan]> [/color][color=Black]saferange [/color][color=Green]; ---- spin anti-clockwise until no object to full right[/color]

[color=Blue]let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]174[/color][color=Black]:[/color][color=Blue]let [/color][color=Black]radardir[/color][color=DarkCyan]=[/color][color=Navy]0[/color][color=Black]:[/color][color=Blue]servopos [/color][color=Black]servopin,radarpos [/color][color=Green];---- point radar left[/color]

[color=Blue]goto [/color][color=Black]main[/color]
 

stan74

Senior Member
Code:
[color=Black]ping:[/color]
[color=Blue]high [/color][color=Black]pingecho:[/color][color=Blue]pulsin [/color][color=Black]pingecho,[/color][color=Navy]1[/color][color=Black],range[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2
pause [/color][color=Navy]7[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
[color=Black]scanrotateleft:[/color]
[color=Blue]gosub [/color][color=Black]ping[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2
pause [/color][color=Navy]7[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
[color=Black]scanrotateright:[/color]
[color=Blue]gosub [/color][color=Black]ping[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2
pause [/color][color=Navy]7[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
[color=Black]rotateradar: [/color][color=Green];move servo and measure distance[/color]
[color=Blue]gosub [/color][color=Black]ping[/color]
[color=Blue]if [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]+[/color][color=Navy]8 
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]222 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]0
      [/color][color=Blue]endif
else  let [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Black]radarpos [/color][color=DarkCyan]- [/color][color=Navy]8
      [/color][color=Blue]if [/color][color=Black]radarpos [/color][color=DarkCyan]= [/color][color=Navy]78 [/color][color=Blue]then let [/color][color=Black]radardir [/color][color=DarkCyan]= [/color][color=Navy]1
      [/color][color=Blue]endif
endif
servopos [/color][color=Black]servopin,radarpos[/color]
[color=Blue]return[/color]
[color=Black]brake:[/color]
[color=Blue]low [/color][color=Black]rmotordir:[/color][color=Blue]low [/color][color=Black]lmotordir [/color][color=Green]; short reverse[/color]
[color=Blue]pause [/color][color=Navy]7[/color]
[color=Blue]low c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
[color=Black]motors_fullspeed:[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
[color=Black]rotate_clockwise:[/color]
[color=Blue]high [/color][color=Black]lmotordir [/color][color=Green]; left motor forward[/color]
[color=Blue]low [/color][color=Black]rmotordir [/color][color=Green]; right motor reverse[/color]
[color=Blue]return[/color]
[color=Black]rotate_anticlockwise:[/color]
[color=Blue]high [/color][color=Black]rmotordir:[/color][color=Blue]low [/color][color=Black]lmotordir [/color][color=Green]; left motor reverse right motor forward[/color]
[color=Blue]return[/color]
[color=Black]motors_forward:[/color]
[color=Blue]high [/color][color=Black]rmotordir:[/color][color=Blue]high [/color][color=Black]lmotordir [/color][color=Green]; left motor forward right motor forward[/color]
[color=Blue]high c.1[/color][color=Black],[/color][color=Blue]c.2
return[/color]
 

erco

Senior Member
In your video the robot can't see things ahead because they are at an angle and the sound is bouncing away so check the sides more, to get some response/reaction. Cloth absorbs ultra sound as well.
It's getting more common to scan with both ultrasonic and Sharp sensors as they have complementary strengths & weaknesses.
 

stan74

Senior Member
IR can't see dark coloured objects and both have trouble with surfaces not at 90 deg which shows in the video. There's always a flat spot on a balloon. Footballs are seen easy to. My tracked robot runs fast even at 3V and it's geared 220:1 with the smaller cogs driving the tracks. We're lucky to be able to get sensors so cheap. I built a light seeking robot that could avoid obstacles once and think I'll repeat it making the robot seek a tv remote while avoiding..tricky.
 

erco

Senior Member
Actually the Sharp IR sensors see black nearly as well as white, over 90%. Their position sensitive detector measures using parallax effects, not just detecting reflected 38 kHz signals.

Data sheet at https://www.pololu.com/product/136

Try one, you'll like it. :)
 

stan74

Senior Member
I modded a £1 ir sensor to use picaxe pwm. Small pot adjusts sensitivity. The output from these units is analogue really. I can see the indicator led glow as I move an object closer.
 
Top