Asked — Edited

Script Help Needed

I am having a little bit of trouble with this script. Everything works until I get to the "if" statement at the left and right sensor. So what it is supposed to do is not allow movement if tracks are disabled which upon startup they are. Once track motors are enabled and the command robot turn left is given the head is to turn left and down, again which it does. But then it never gets to the send serial commands. There is something missing, endif, elseif, end repeat? BTW I troubleshot by commenting out lines of code until figuring out where the problem began. I appreciate the help. Also how do I use code tags on this website?


if($movement = "false")
print("movement prohibited")
SayEzb("my track motors are disabled")
Else 
print("moving")

ControlCommand("Script Manager ", ScriptStart, "Head_Left")
ControlCommand("Script Manager ", ScriptStart, "Head Down")
sleep(500)

if ($leftsensor <60)And ($rightsensor <60)
sleep(500)
SendSerial(D0,38400,1)
SendSerial(D0,38400,255)
Sleep(5000)
SendSerial(D0,38400,0)
ElseIf 
SendSerial(D0,38400,0) 
SayEZB("i have detected something in my path") 
EndIf


ARC Pro

Upgrade to ARC Pro

ARC Pro is more than a tool; it's a creative playground for robot enthusiasts, where you can turn your wildest ideas into reality.

#17  

This script still does not work completely. If I block the sensors it does not move which is correct, but it never says " I have detected something in my path".


IF ($movement = "false")

  print("movement prohibited")

  SayEzb("my track motors are disabled")

ELSE

  print("moving")

  ControlCommand("Script Manager ", ScriptStart, "Head_Left")
  ControlCommand("Script Manager ", ScriptStart, "Head Down")

  sleep(500)

  $leftsensor = getadc(adc5)
  $topsensor = getadc(adc7)
  $rightsensor = getadc(adc6)


  IF ($leftsensor <60)And ($rightsensor <60)

    sleep(1500)
    SendSerial(D0,38400,1)
    SendSerial(D0,38400,255)
    Sleep(3000)
    SendSerial(D0,38400,0)

  ELSEIF

    SendSerial(D0,38400,0)
    SayEZB("i have detected something in my path")

  ENDIF

ENDIF



ControlCommand("Script Manager ", ScriptStart, "Head_Center") 

#18  

Richard thanks for the lesson on the tags that was a big help. Other forums I visit don't require that. Thanks again.

#19  

In your following statement something looks odd to me.

 
  IF ($leftsensor <60)And ($rightsensor <60)

    sleep(1500)
    SendSerial(D0,38400,1)
    SendSerial(D0,38400,255)
    Sleep(3000)
    SendSerial(D0,38400,0)

I could be wrong but It may be moving too fast and skipping a needed command. Try placing a Sleep() command between:


 SendSerial(D0,38400,1)
 SendSerial(D0,38400,255)

#20  

Thinking about this more I'm sure my above post may be part of your problem. You need to give things time to complete operation before moving on to the next command. This is even more important when you're sending serial commands to other devices. Too fast and you're going to flood the channel or send a command faster then the device you're trying to control can accept and read it. I find this to be true when sending serial commands to the Kangaroo X2 I control through ARC and EZB.

To troubleshoot timing issues I sometime give Sleep() commands a stupid amount of time. This really slows down the script and lets things complete. Then I trim down the sleep() times till everything runs fast and smooth. :)

#21  

Try changing that ELSEIF to ELSE

#22  

Dave the reason those two serial commands are like that are to start the 2 tracks in opposite directions. I cant start 1 and then start the other after a sleep period. Thanks for the response though, I appreciate it and may try a sleep at other points to troubleshoot.

Faengelm I will try that later tonight when I return home this evening. Hopefully that works.

          Chris
#23  

Yes... get rid of the elseif and use else.... You only use elseif if you are checking on an additional condition that may exist....

#24  

Thanks guys will try tomorrow, some life changes prevented me from trying tonight. It was my night with the kids! thanks again

 Chris