Singapore
Asked — Edited
Resolved Resolved by Dunning-Kruger!

How To Run An Object Detection Script In A Midst Of Auto-Position Actions?

Hi guys,

I am trying to run an object detection script:

$CameraObjectName = ("Unknown")

ControlCommand("Camera", CameraObjectTracking) SayEZBWait("Let me look for an object") Sleep(1000)

If($CameraHorizontalQuadrant = "Unknown") SayEZBWait("No, I do not see an object") ControlCommand("Auto Position", AutoPositionAction, "Left") ControlCommand("Auto Position", AutoPositionAction, "Left") EndIf

If($CameraHorizontalQuadrant != "Unknown") SayEZB("Yes, yes I do see a " + $CameraObjectName) SayEZBWait("The object is in" +$CameraVerticalQuadrant+ "row" + $CameraHorizontalCamera+ "column") ControlCommand("Auto Position", AutoPositionAction, "Forward") ControlCommand("Auto Position", AutoPositionAction, "Forward") ControlCommand("Auto Position", AutoPositionAction, "Forward") ControlCommand("Auto Position", AutoPositionAction, "Forward") ControlCommand("Auto Position", AutoPositionAction, "Forward") ControlCommand("Auto Position", AutoPositionAction, "Forward")

EndIf


in the midst of some Auto Position actions in a script. The script doesn't run after doing those actions. Is there anything I could add to make it work smoothly?

Thanks in advance!


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

#1  

You're auto ControlCommands will virtually all run at the same time...you should set the action to repeat instead... Or set it to run once and use another goto loop or a repeatuntil loop with a sleep/wait command after each Forward action... You'll also need to check the location of the object again after each forward/left/right movements as no doubt the object will have changed postion (as the camera sees it) relative to the robot....

Singapore
#2  

Hi @Richard R,

thanks for the quick reply. However, my problem is that other dance auto-position actions are running together with the object detection script. How do I make it such that the object detection only runs after the actions are done. Below is the full script:

ControlCommand("Auto Position", AutoPositionAction, "Forward" )

ControlCommand("Auto Position", AutoPositionAction, "Hands Dance" )

ControlCommand("Auto Position", AutoPositionAction, "Thinking" )

ControlCommand("Auto Position", AutoPositionAction, "YMCA Dance" )

ControlCommand("Auto Position", AutoPositionAction, "Forward" )

$CameraObjectName = ("Unknown" )

ControlCommand("Camera", CameraObjectTracking ) SayEZBWait("Let me look for an object" ) Sleep(1000)

If($CameraHorizontalQuadrant = "Unknown" ) SayEZBWait("No, I do not see an object" ) ControlCommand("Auto Position", AutoPositionAction, "Left" ) ControlCommand("Auto Position", AutoPositionAction, "Left" ) EndIf Goto(loop ) If($CameraHorizontalQuadrant != "Unknown" ) SayEZB("Yes, yes I do see a " + $CameraObjectName ) SayEZBWait("The object is in" +$CameraVerticalQuadrant+ "row" + $CameraHorizontalCamera+ "column" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) ControlCommand("Auto Position", AutoPositionAction, "Forward" ) EndIf

Thanks.

#3  

Hmmm good question.... There is no ControlCommand("Auto Position", AutoPositionActionWait command.... There has to be a way (I am sure there is) to pause the script until all the actions are completed before continuing to the camera tracking.... For now a long sleep command may be a stop gap...

Singapore
#4  

I will try to continue figuring it out...thanks for helping anyway!

#5  

You do realize that all of your control commands are going to run all at the same time. Is this what you wanted to do or did you want one to finish before starting the next?


#All these actions will run simultaneously....
ControlCommand("Auto Position", AutoPositionAction, "Forward" )

ControlCommand("Auto Position", AutoPositionAction, "Hands Dance" )

ControlCommand("Auto Position", AutoPositionAction, "Thinking" )

ControlCommand("Auto Position", AutoPositionAction, "YMCA Dance" )

ControlCommand("Auto Position", AutoPositionAction, "Forward" )

#6  

Check this out in auto positioner.... This will allow you to run a script when the auto-position commands are completed... In your case put your camera tracking in the last action before the camera tracking starts... Put your camera tracking code in the "position end script" as below...

User-inserted image

#7  

Better yet, you can also use this variable to check and see whether auto positioner is still running or not..


if($AutoPositionStatus=1)
#auto positioner is still running so wait
else
#auto positioner is NOT running
#run your camera tracking code
endif