Asked — Edited

Programming Cy 2.0

Evening all ! Now that CY is basically complete on the hardware side (more to add on later) I an now working thru the programming (ugh!). For some time now, I've played around with little scripts here and there to test different parts of what the hardware "should do" and am now trying to mash it all together. What I am really trying to focus on first is getting its navigation down. More so when I want it to be able to roam around all on its own.

That I have showing here is suppose to be a main navigation program that gets executed when I tell it to do so (and to stop when told to do so). Here is where I'm having an issue, and some inside as what I am missing here would be so helpful to me.


# This variable will be used to determine if we exit.
# If it is a 0, we continue running
# If it is a 1, we exit this script
$exit = 0

# begin moving forward
Forward()
ControlCommand("BumperTest", ScriptStart)
:Start

  # Get the ping sensor value
$ping1 = GetPing(d14, d15)  
$ping2 = GetPing(d16, d16)
$ping3 = GetPing(d17, d17)
$Ping4 = GetPing(d18, d19)

  # If the ping sensor value is less 
  # than 20, alarm!
if ($ping1 < 20)
  goto(Alarm1)
endif
if ($ping2 < 15)
  goto(Alarm2)
endif
if ($ping3 < 10)
  goto(Alarm3)
endif
if ($ping4 < 10)
  goto(Alarm4)
endif
  # If the exit value is 1, exit the script
if ($exit = 1)
  goto(Exit)
endif


Goto(Start)

:Alarm1
Stop()
SayEZB("Object Left Detected")
pause(500)
ControlCommand("Sharp IR Radar", PauseOff)
Reverse(150,2000)
if (ADC_Wait(ADC4,lower,10,50)) 
right(255, )
Sleep(500)
Forward()
endif
Return()

:Alarm2
Stop()
SayEZB("Object Front Detected")
sleep(500)
ControlCommand("Sharp IR Radar", PauseOff)
reverse(255,3000)
if (ADC_Wait(ADC4,lower,10,50))
sleep(500)
left(255, )
Sleep(500)
Forward()
endif
Return()

:Alarm3
Stop()
SayEZB("Object Rear Detected")
sleep(750)
stop() 
Sleep(750)
right(255, )
Forward()
Return()

:Alarm4
Stop()
SayEZB("Object Right Detected")
sleep(500)
ControlCommand("Sharp IR Radar", PauseOff)
if (ADC_Wait(ADC4,lower,10,50)) 
Reverse(150,2000)
left(255, )
Sleep(500)
Forward()
endif
Return()

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

Key thing to note here is that CY is using 4 Ultrasonic sensors and 1 IR sensor. The first four sensors are 2 Parallax ones for front and rear, 2 EZrobot ones for left and right, and 1 IR sensor which is on a servo to sweep. The idea here is that when moving forward, if robot gets to close to a wall or corner, its suppose to stop, then the IR sensor is to sweep the area ahead,then stop sweep, and the area with the greatest distance is suppose to make the robot reverse,turn,and continue in that direction, and continue until it detects another obstruction. Also have 2 lever bumper switches for added protection that are in case one of forward sensors miss.

I have other functions Im trying to clear up, but this is a big one for me. Any ideas,suggestions, pointers? confused Even included my project file.Alot of there there. Is it also possible to be having too many things running at the same time which could slow some processing down a little? always wondered that.

Cy2_0_NewTest2.EZB


ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming