Asked — Edited

It'S Not Perfect, But Here Is A Navigation Script. Comments Welcome.

#NavExplore Script $exit = 0 Roomba(init) Roomba(EnableSensors) stop() say("OK, Explore mode!") goto(headcenter) sleep(1500)

:Start

:testleftping goto(headleft)

#Vertical $lv = GetPing(d9, d8)

If the ping sensor value is less

than 20, found object

if ($lv < 20) goto(objectfound)

#Horizontal set(D19,5) $lh = GetPing(d18, d17)

If the ping sensor value is less

than 20, object found

if ($lh < 20) goto(objectfound) RETURN()

:testcenterPing goto(headcenter)

#CenterVertical $cv = GetPing(d9, d8)

If the ping sensor value is less

than 20, object found

if ($cv < 20) goto(objectfound)

#CenterHorizontal set(D19,43) $ch = GetPing(d18, d17)

If the ping sensor value is less

than 20,object found

if ($ch < 20) goto(objectfound) RETURN()

:testrightping goto(headright)

#VerticalRight $rv = GetPing(d9, d8)

If the ping sensor value is less

than 20,object found

if ($rv < 20) goto(objectfound)

#HorizontalRight set(D19,90) $rh = GetPing(d18, d17)

If the ping sensor value is less

than 20, object found

if ($rh < 20) goto(objectfound) RETURN()

:RotateLeft goto(headcenter) left(255,750) Return()

:RotateRight goto(headcenter) right(255,750) Return()

:Reverse goto(headcenter) reverse(255,1000) RETURN()

If the exit value is 1, exit the script

if ($exit = 1) goto(Exit)

begin moving forward

Forward() goto(start)

:headleft set(D1,5) RETURN()

:headcenter set(D1,43) RETURN()

:headright set(d1,90) RETURN()

:objectfound stop() say("Object Found!") if ($lv < 20) goto(RotateRight) if ($lh < 20) goto(RotateRight) if ($rv < 20) goto(RotateLeft) if ($rh < 20) goto(RotateLeft) if ($ch < 20) goto(Reverse) if ($ch < 20) goto(Reverse) goto(Start) RETURN()

:Exit Stop() Say("Received Command Stop") Halt()


ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.

#1  

I do realize that I am testing everything twice. I haven't tried it yet.

#2  

the following is better:

#NavExplore Script Roomba(init) say("OK, Explore mode!") :Start stop() goto(readleftping) goto(readcenterping) goto(readrightping) goto(Start)

:readleftping goto(headcenter) goto(headleft) sleep(1000)

#Vertical $lv = GetPing(d9, d8) goto(test)

#Horizontal $lh = GetPing(d18, d17) goto(test) RETURN()

:readcenterPing goto(headcenter) sleep(1000)

#CenterVertical $cv = GetPing(d9, d8) goto(test)

#CenterHorizontal $ch = GetPing(d18, d17) goto(test) RETURN()

:readrightping goto(headcenter) goto(headright) sleep(1000)

#VerticalRight $rv = GetPing(d9, d8) goto(test)

#HorizontalRight $rh = GetPing(d18, d17) goto(test) RETURN()

goto(start)

#Robot movement

:RotateLeft goto(headcenter) Left(255,750) Return()

:RotateRight goto(headcenter) Right(255,750) Return()

:Reverse goto(headcenter) reverse(255,1500) RETURN()

:Forward goto(headcenter)

begin moving forward

Forward(255) RETURN()

:headleft SERVO(D19,54) servo(D1,43) Sleep(1500) RETURN()

:headcenter SERVO(D19,30) servo(d1,60) Sleep(1500) RETURN()

:headright SERVO(d1,75) servo(d19,3) SLEEP(1500) RETURN()

:test goto(headcenter) if ($lv < 45) goto(RotateRight) if ($lh < 45) goto(RotateRight) if ($rv < 45) goto(RotateLeft) if ($rh < 45) goto(RotateLeft) if ($ch < 45) goto(Reverse) if ($ch < 45) goto(Reverse) goto(Forward) RETURN()

But, I run into a problem when i test for less than 45. I need to ignore a value of zero because before it is tested it is either 255 or Zero.

What do you think?

#3  

Here is another version. Still haven't got it to do what I want. Simply avoid objects. I am sure that it is my rusty programming skills.

#NavExplore Script Roomba(init) say("OK, Explore mode!") goto(headcenter) stop() sleep(1200) :Start goto(readleftping) goto(readcenterping) goto(readrightping) goto(test) goto(Start)

:readleftping say("reading Left Ping.") SERVO(D19,60) sleep(1200)

#Vertical $lv = GetPing(d9, d8) #Horizontal $lh = GetPing(d18, d17) sleep(1200)
RETURN()

:readcenterPing say("Reading Center Ping.") sleep(1200) SERVO(D19,30) #CenterVertical $cv = GetPing(d9, d8) #CenterHorizontal $ch = GetPing(d18, d17) sleep(1200) RETURN()

:readrightping say("Reading Right Ping.")
servo(d19,3) sleep(1200)
#VerticalRight $rv = GetPing(d9, d8) #HorizontalRight $rh = GetPing(d18, d17) sleep(1200) RETURN()

goto(start)

#Robot movement

:RotateLeft Left(255,750) Return()

:RotateRight Right(255,750) Return()

:Reverse reverse(255,1500) RETURN()

:Forward

begin moving forward

Forward(255) sleep(1000) RETURN()

:headleft servo(D1,3) RETURN()

:headcenter servo(D1,60) RETURN()

:headright SERVO(d1,90) RETURN()

:test goto(testleft) goto(testcenter) goto(testright) goto(Forward) RETURN()

:testLeft if ($lv < 45) if ($lh < 45) goto(RotateRight) RETURN()

:testcenter if ($ch < 45) if ($cv < 45) goto(Reverse) RETURN()

:testright if ($rv < 45) if ($rh < 45) goto(RotateLeft) RETURN()

comments welcome

Australia
#4  

OMG - MovieMaker, pardon my ignorance but what are you trying to do with all this script, navigate around Mars ? lol eyeroll I'm just trying to get from the lounge to the kitchen and back..:D

United Kingdom
#5  

@Hazbot great comment lol:)

I was looking at this and I could load it into my Omnibot but wanted a few more details. I presume the head is the ultrasonic sensor and which way it is pointing? Are there any other sensors involved

Might help if it was loaded to the cloud project with notepad comments

I am re-building a house at present and the other day the builders laid the new concrete floor (we call it screed here). Then I realised too late I should of had a cable buried in the new floor that the robot could follow doh. That would have neatly solved the lounge to the kitchen and back problem although another way to do it would be to maintain a set distance from the wall with a ping sensor and follow that until reaching the desired location using the floor map (needs work and thinking about)

#6  

Hey Winston!

My script is not finished yet. I have completely written it about six times. I started off with two sharp IR sensors and two Ping units. The IR sensors worked very flakely, so I just went with the two Ultrasonic Ping units. When I was young, this would've only taken me an afternoon. But, I have spent about two weeks and I am still not there. The idea here, is that I have a stationary vertical PING unit to catch tabletops and such. And I have a horizontal scanning Unit. Here was my plan:

Start scan the horizontal Left ping (lh) then Horz center (ch) then right (rh) then vertical left ping (lv) then center (cv) then right (rv)

store these to the values: lh,ch,rh,lv,cv,rv.

then test them all to see if the Ping was less than 45. (It could be as low as 20) But, I ran into a problem because when I am testing the Pings and the pings have not PINGED, the value is ZERO. So, I had to figure a way to make sure the value was not Zero AND the value was less than 45.

I have not succeeded yet.

I just wanted to share my script in case it would get some creative juices going with some of the members like you.

Usually, when I write a program, I just get something working. After it is working, I try to trim it down. But in this case, it is not working yet.

Thanks for the reply.

Mel

Australia
#7  

Thanks winstn60, I was thinking along the same lines using ping with script but havn't tried it yet. DJ suggested a beacon but he didn;t elaborate on it, he gave the impression it could work. Another idea I had was to install a line following sensore and use a thin strip of tape but free range navigation is what I'm really after.:)