
ignoblegnome

This is my first time using ARC and EZ-Script. I'm having trouble with what I think should be a very straight forward script.
I have Revolution Six outfitted with an HC-SR04 ultrasonic sensors on a head-mounted servo. The Ping Distance control shows that the sensor is working fine.
My issue is that when I hit 'Start' on the Script control, the robot doesn't move. Actually, the servo d20 (which controls the Ping sensor position) moves, but Six doesn't walk. I can see in the Auto Position control that the Forward Action is repeating (see attached screenshot), but the robot doesn't move...
Until I hit 'Stop' in the Script control. Then Six moves forward as expected, but he doesn't follow the rest of his program. He never responds to his Ping sensor and reverses. I also noticed that the Auto Position control stops updating with Six's movements after I hit 'Stop' in the Script control.
Here's my code:Code:
servo(d20, 90)
:loop
$dist = getping(d21,d22)
if ($dist < 20)
ControlCommand("Auto Position", AutoPositionAction, "Reverse")
else
ControlCommand("Auto Position", AutoPositionAction, "Forward")
endif
goto(loop)
What am I doing wrong?
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Early Access edition. You'll have everything that's needed to unleash your robot's potential!
Sleep(0500)
This example is a 1/2 second. You can adjust the time to anything that works for you. 1000 would be one full second. Your script may be running too fast for anything to respond. You need to give your devices time to either move to the position you want them to move to or return the info you are seeking.
Thanks for the assist.
Code posted below for reference. This is a Six robot with ultrasonic sensor on a head-mounted servo.
Code: