Australia
Asked — Edited
Resolved Resolved by ptp!

Synchronising Commands In A Custom Behavior Control Plugin In C#

I’ve made a custom robot skill plugin and use the EZ_Builder.Scripting.Executor.StartScriptBlocking method to run commands. However, I can’t get it to properly run the Test Script in Script Manager:

Code in Script Manager - "Test":

ControlCommand("Auto Position", AutoPositionAction, "Disco Dance")
ControlCommand("RGB Animator", AutoPositionAction, "Spin")
SayWait("This test will make me dance and light up my eyes then stop.")
ControlCommand("Auto Position", AutoPositionFrame, "STAND", 25, 3, -1)
ControlCommand("RGB Animator", AutoPositionAction, "Idle")

When the above code is played via the Script Manager control, the robot dances and lights its eyes up while speaking through the PC.

Code in robot skill plugin:

EZ_Builder.Scripting.Executor executor = new EZ_Builder.Scripting.Executor();
executor.StartScriptBlocking(EZ_Builder.Scripting.Compiler.Compile("ControlCommand(\"Script Manager\", ScriptStartWait, \"Test\")"));

However, the code in the robot skill plugin only speaks and doesn’t move or change its eye LEDs at all.

Does anyone know how to fix this?

NB: "Disco Dance" and "Spin" both repeat so I can’t wait for their status variables to be cleared.



Related Hardware (view all EZB hardware)
JD Humanoid by EZ-Robot
JD humanoid robot kit - WiFi-enabled, 16 DOF with metal-gear servos; easy, fun, educational, available from the EZ-Robot online store.
Wi-Fi / USB
Servos 24
Camera
Audio
UART 3
I2C
ADC 8
Digital 24

Related Robot Skills (view all robot skills)
ARC utilities: DataQuery for SQL/ODBC/OLEDB/Excel with parameterized queries returning array variables; Ticks/Millis timing functions.
Manage and execute multiple scripts in a single Script Manager using ControlCommand(), with Control Details showing available commands.
Create servo frames/actions to animate humanoid, hexapod or custom gaits with smooth transitions, SW ramping and directional control
RGB Animator by Synthiam
Create custom animations for JD Humanoid's 18 RGB Eyes LEDs via I2C - per-LED color frames, transitions, pauses, scripting and real-time preview.

ARC Pro

Upgrade to ARC Pro

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

Author Avatar
Australia
#2  

Hi,

Yes, but I'd also like to know how to solve this post's problem too. I have a feeling it's got to do with the executor overwriting the previous commands but I'm still not sure why it behaves differently when calling it from the ARC GUI.

Author Avatar
PRO
USA
#3  

and if you use executor.StartAsync  ?

Author Avatar
PRO
Synthiam
#4   — Edited

None of the commands in your script manager code are blocking commands. Please read how the ControlCommand() works by clicking on the highlighted word in this sentence.

That script will execute all commands one after another super fast. There's nothing waiting for anything to complete.

for example...


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

ControlCommand("RGB Animator", AutoPositionAction, "Spin")

Waitfor($AutoPositionStatus = 0)

SayWait("This test will make me dance and light up my eyes then stop.")

ControlCommand("Auto Position", AutoPositionFrame, "STAND", 25, 3, -1)

Waitfor($AutoPositionStatus = 0)

ControlCommand("RGB Animator", AutoPositionAction, "Idle")

Waitfor($AutoPositionStatus = 0)

Author Avatar
Australia
#5  

Thanks @ptp, using Executor.StartScriptASync works. I don't know why I didn't try the ASync earlier although I did try the ExecuteScriptSingleLine.

@DJ, the code got stuck at the WaitFor($AutoPositionStatus = 0) line because the Disco Dance action repeats.