Canada
Asked — Edited

Some Code Help Please

Hello, I need some code help. I realize this is super simple but can't get my head around it.
In the following code once "Master" or "Milady" has been identified and the ControlCommand has been executed, I would like the CameraObjectName subject to be ignored for say, 1/2 hour.

To try and be clear, once it sees you it won't execute the ControlCammand repeatedly .

Thanks in advance. Tony

SayEZB(("I see " + $CameraObjectName))

if ($CameraObjectName = "Master")

  sleep(2000)

  ControlCommand("Script Manager", ScriptStart, "Fist Bump")


elseif ($CameraObjectName = "Milady")

  sleep(2000)

  ControlCommand("Script Manager", ScriptStart, "Royal Wave")


else


endif

ARC Pro

Upgrade to ARC Pro

Harnessing the power of ARC Pro, your robot can be more than just a simple automated machine.

#9  

Really not a good idea to run a loop in the camera control script... In essence it is already basically a loop in itself....

#10  

I am probably making this more complex than it needs to be, and I haven't completely formed the thought so I am not sure how I would do all of this, but...

In your camera control script, I would check for the contents of a variable and only execute the command if the variable was 'true' or whatever you set it to. after running the command, set the variable to 'false'.

Then you need another script that watches for that variable to change, and sets a timer when it does, and changes it back when the timer expires. That one can run in a loop.

Alan

Canada
#11  

@Richard R. Ok, I'll give up trying.

#12  

Quote:

Ok, I'll give up trying.
You shouldn't give up, just run the loop outside the camera control, like I describe above. In a few weeks I expect to finally have time to spend on robots again (3 year project at work coming to an end) and if you haven't solved it by then, I will write examples.

Alan

#13  

Don’t give up trying. This is actually a good exercise that could benefit others. Hopefully DJ will return to this post.

Canada
#14  

Thanks Alan. it is a challenge for me.

PRO
Synthiam
#15  

Okay - that's an easy bit of code to write. This doesn't need a loop. I'll write something for you to get you started. Stay tuned

PRO
USA
#16  

Initialization script:


$master_alert_expire_on=""
$milady_alert_expire_on=""

Camera script :


SayEZB("I see " + $CameraObjectName)

if ($CameraObjectName="Master")

  #logic: both conditions 1 and 2
  #       1) expiration date is set, i.e. string not empty
  #       2) current time i.e. Now() is less than the current expiration date time
  #       => Ignore!         
  if ($master_alert_expire_on!="" AND now()<$master_alert_expire_on)
    print("ignoring master")
  ELSE
    # set the master variable expiration date to 30 minutes
    $master_alert_expire_on=AddMinutes(now(),30)
    ControlCommand("Script Manager", ScriptStart, "Fist Bump")
  endif

ELSEif ($CameraObjectName="Milady")

  if ($milady_alert_expire_on!="" AND now()<$milady_alert_expire_on)
    print("ignoring milady")
  ELSE
    # set the milady variable expiration date to 30 minutes
    $milady_alert_expire_on=AddMinutes(now(),30)
    ControlCommand("Script Manager", ScriptStart, "Royal Wave")
  endif

endif