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

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

#25  

One trick to try when testing script logic, is instead of actually moving the robot or its parts, replace those commands with Print() commands that tell you where in the script you are. Then execute the script while watching the script object window.

If using variables you can also print those so you can easily see that they are getting set the way you expect.

Once you get the logic right, then replace (or add to) the print commands with the actual Robot movement commands. This prevents uncontrolled movement when the logic is wrong, and helps isolate the logic from possible control issues.

Alan

#26  

Yes Yes Yes! A couple of further tweeks to that script after the "else" changed proved exactly what I am looking for. Very very nice. Thanks for all the help with this one.

                  Chris
PRO
Synthiam
#27  

Great to hear!

Also it's very useful to know that running the script while editing in the debug window will display the executing instruction of each line.

Running a script in the editor is a fantastic way to debug the execution. It's super useful