Lynxmotion Smart Servos icon Lynxmotion Smart Servos — Compact Lynxmotion Smart Servos with position feedback, safety features and UART TX/RX for Arduino/EZ-B v4; scriptable temp, load, load-dir and ping. Try it →
Asked
1 Participant
Personality Generator canceling long scripts

Personality Generator Canceling Long Scripts

Running ARC on a DF Robot LattePanda (Windows), using the onboard Arduino Leonardo over USB with the EZ-Genuino firmware and DTR Enabled in the Connection config, I’m trying to give my bot some ambient behavior via the Personality Generator skill but I’m hitting a cancellation issue with longer routines. Two micro servos are on Leonardo pins D5 (head tilt) and D6 (pan), powered from a separate 5V regulator, grounds tied. Personality Generator Low=8s, High=25s. I added three personality actions: head_nod, look_around, and speak_greeting. Right now I have them coded inline in Personality Generator (EZ-Script), for example look_around sweeps the head for ~20-30 seconds while occasionally speaking via Speech Synthesis. The expected result is it finishes the sweep before the next random action, but the actual behavior is that when the next interval fires, the current script stops mid-motion or mid-sentence and the new one starts, which matches the note that the skill cancels the currently running script.

I tried: widening the interval to Low=20/High=60, adding a $busy flag around the long sequences, and even moving the routines into Script Manager and having Personality Generator just call them via ControlCommand("Script Manager", ScriptStart, "look_around") so I could gate with a $busy check. But the moment the next Personality Generator interval hits, it seems to interrupt anyway. Here’s a simplified snippet of the inline version that gets cut off:

$busy = 1
FOR($i=1; $i<=40; $i++)
  Servo(D5, Random(40,120))
  Servo(D6, Random(30,150))
  Sleep(500)
NEXT
Say("Scanning complete")
$busy = 0

Is there a recommended pattern (queueing, pausing the Personality Generator, or a ControlCommand to defer new triggers) so a Personality Generator action on a LattePanda/Leonardo can complete without being cancelled by the next randomized interval?



Related Hardware (view all EZB hardware)
Lattepanda by DF Robot
LattePanda with Synthiam ARCx runs headless, loads EZB firmware on the built-in Arduino, and controls robots from any browser
Wi-Fi / USB
Servos 12
Camera
Audio
UART 1
I2C
ADC 5
Digital 12

Related Robot Skills (view all robot skills)
Manage and execute multiple scripts in a single Script Manager using ControlCommand(), with Control Details showing available commands.
Background randomizer that executes timed scripts to add lifelike actions (movement, servos, camera/control) and unique personality to your robot

ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

Author Avatar
PRO
Canada
Twitter YouTube GitHub
#1  

Yes - what you’re seeing is expected behavior for Personality Generator. It runs one personality script at a time, and when the next randomized interval hits, it cancels the currently running script and starts the new one. So a long routine like your 20-30 second sweep will get interrupted unless you design around that behavior.

Option 1: Keep Personality scripts short and non-blocking

This is the simplest and most reliable approach.

Instead of one long script that "does" the whole sweep, make the Personality Generator trigger small actions only:

  • move head a little
  • speak a short phrase
  • blink LEDs
  • change pose briefly

Then let the next trigger handle the next small step.

This works well because Personality Generator is meant for spontaneous, short behaviors, not long routines.


Option 2: Use a state machine with short scripts

If you want the bot to appear to do a long routine, break it into phases and store the phase in a global variable.

For example:

  • head_state = 0 start scan
  • head_state = 1 continue scan
  • head_state = 2 finish scan

Each Personality Generator trigger runs only one phase, then exits quickly.

That avoids cancellation issues because each script is short.


Option 3: Have Personality Generator call a Script Collection script that only starts if idle

If you want to keep using Script Collection, the key is:

  • Personality Generator should trigger a script that checks whether another action is already active
  • If active, it should immediately exit
  • If not active, it should start a short action and set a state flag

But note: if the Personality Generator itself fires again, it can still cancel the current running script if that same script is still executing. So this only helps if the triggered script is very short.


What won’t solve it by itself

These approaches usually won’t prevent cancellation:

  • just adding $busy = 1
  • putting the routine in Script Collection and calling ScriptStart
  • widening the interval a lot

Why? Because the Personality Generator doesn’t wait on your $busy flag - it simply starts a new script when its timer fires, and the currently running personality script gets cancelled.


Best practical workaround

If you want long ambient behavior, use Personality Generator only as the "starter", not the executor.

Example pattern:

  1. Personality Generator runs a tiny script:

    • if not busy, set a mode variable like $lookState = 1
    • start a separate worker script using ControlCommand("Script Collection", "ScriptStart", "LookAroundWorker")
  2. The worker script should be designed to:

    • run in short chunks
    • save its state
    • exit quickly, or use repeated short calls rather than one long blocking loop

If you need a long-running routine, it’s better to trigger it from a different control than Personality Generator, or convert it into a repeatable state machine.


Example pattern

Personality Generator action

if (getVar("$busy") == 0) {
  setVar("$busy", 1);
  setVar("$lookState", 1);
  controlCommand("Script Collection", "ScriptStart", "LookAroundWorker");
}

Worker script

if (getVar("$lookState") != 1) return;

Servo.setPosition(d5, 70);
Servo.setPosition(d6, 90);
sleep(500);

Servo.setPosition(d5, 50);
sleep(500);

Servo.setPosition(d6, 120);
sleep(500);

Audio.say("Scanning complete");

setVar("$lookState", 0);
setVar("$busy", 0);

This is still not a perfect "queue," but it keeps the Personality Generator from being responsible for the entire long routine.


Important note about speech

If you’re using speech in the same long script, that also increases the chance you’ll see interruption. A better pattern is:

  • keep speech phrases short
  • trigger speech as its own short action
  • avoid long scripts that mix movement loops + speech + delays

Relevant docs


My recommendation for your LattePanda/Leonardo setup

Since you’re already on ARC with Windows and the onboard Leonardo, I’d recommend:

  • keep Personality Generator actions under 1-3 seconds
  • use a state variable for multi-step head scanning
  • let the scan continue across multiple triggers rather than one blocking loop

If you want, I can help you rewrite your current look_around routine into a non-blocking state machine in JavaScript or Python for ARC, which is usually the cleanest way to do this.

I am a customer support AI and still learning. Please verify important answers in our support documentation. For advanced AI features, use the AI Script Agent built into ARC.