
kamaroman68
What I want the robot to do is move forward 3 seconds as long as nothing is detected in its path using adc5 or adc6, ir sensors. Sensors work fine. Have tried several iterations of scripting. No matter what I try the sensors do see above 60 but the robot never stops. Posting my scripts.
Check distance script with forward movement
:MonitorDistances
$leftsensor = getadc(adc5)
$topsensor = getadc(adc7)
$rightsensor = getadc(adc6)
if ($leftsensor 60)or ($rightsensor >60)
ControlCommand("Script Manager ", ScriptStart, "Emergency_Stop")
EndIf
goto(MonitorDistances)
In this particular instance I called my emergency stop script which follows...
ControlCommand("Script Manager ", ScriptStopAll)
SendSerial(D0,38400,64)
SendSerial(D0,38400,192)
Again robot continues to go forward without stopping. Thanks guys!
Chris
:MonitorDistances
$leftsensor = getadc(adc5)
$topsensor = getadc(adc7)
$rightsensor = getadc(adc6)
if ($leftsensor <60)And ($rightsensor <60)
ControlCommand("Script Manager ", ScriptStart, "forward_3_Seconds")
ElseIf ($leftsensor >60)or ($rightsensor >60)
ControlCommand("Script Manager ", ScriptStart, "Emergency_Stop")
EndIf
goto(MonitorDistances)
Alan
Alan
You need a sleep statement in your loop. Can be as little as 50ms, but you can't just continuously loop on ADC sensor readings 10's of thousands of times per second, which is what your script is doing now. Probably not working because the ARC is on the verge of locking up.
I think your logic is otherwise correct, but again, I don't really have time to look in detail until tomorrow.
Alan
:MonitorDistances
$leftsensor = getadc(adc5)
$topsensor = getadc(adc7)
$rightsensor = getadc(adc6)
ControlCommand("Script Manager ", ScriptStart, "Head Down")
sleep(1200)
ControlCommand("Script Manager ", ScriptStart, "Head Sweep")
Sleep(2200)
if ($leftsensor <60)And ($rightsensor <60)
ControlCommand("Script Manager ", ScriptStart, "forward_3_Seconds")
ElseIf ($leftsensor >60)or ($rightsensor >60)
ControlCommand("Script Manager ", ScriptStart, "Stop")
EndIf
Sleep(100) )
goto(MonitorDistances)
Alan