Kaito_Robo
Ensure Variable State Saver Loads First
Running a JD Humanoid over WiFi to an EZB, and I’m trying to persist a few calibration/tuning variables between ARC sessions using the Variable State Saver skill. I’ve added these globals in the skill’s config with sensible defaults: $headPanOffset, $headTiltOffset, $leftArmOffset, $rightArmOffset, $gaitSpeed. My JavaScript control applies them on startup before I trigger some Auto Position actions:
var pan = 90 + parseInt(GetVar("$headPanOffset") || 0);
var tilt = 90 + parseInt(GetVar("$headTiltOffset") || 0);
Servo(D0, pan);
Servo(D1, tilt);
SetSpeed(D2, GetVar("$gaitSpeed") || 2);
Expected: when I open the project and connect to the JD, it should use the last saved values. Actual: on project load, the values are still at the defaults for a second or two while my scripts and Auto Position frames kick off, then if I manually press Load on Variable State Saver (or call ControlCommand("Variable State Saver", "Load")), everything updates-but by then JD already moved with the wrong offsets/speed.
What I’ve tried:
- Put ControlCommand("Variable State Saver", "Load") in a dedicated Init script set to run on project start.
- Moved the same command to the EZB Connection skill’s On Connection script (JD connects reliably).
- Added small delays (Sleep 500-2000 ms) before reading the variables, which helps sometimes but feels hacky.
Is there a recommended way to guarantee Variable State Saver loads its saved values before any other scripts/skills run, or an autoload option/initialization event I should be using so JD never starts with the defaults?
Related Hardware (view all EZB hardware)
Related Robot Skills (view all robot skills)

Yes - the key is to load the Variable State Saver before anything else reads those globals.
Recommended approach
For JD, the most reliable pattern is:
Connection Establishedscript on the same connection index JD uses.ControlCommand("Variable State Saver", "Load")firstThat way, the saved values are restored as soon as the EZ-B connects, before your initialization logic runs.
Example startup script
In the EZB Connection skill:
0if that’s where JD is connectedUse something like:
Important notes
1)
Loadin a project-start script may run too earlyIf the project starts before the EZ-B connection is ready, some skills may still initialize with defaults. That’s why Connection Established is better than a project-load script for hardware calibration values.
2)
ControlCommand("Variable State Saver", "Load")is the right commandThat’s the correct way to restore the saved state from script.
3) Your script has one ARC JavaScript detail
You used:
In ARC JavaScript, use the servo command form instead:
Also,
getVar()is preferred overGetVar().Best practice for JD
If those offsets are used by multiple skills, you can also:
That avoids timing issues and keeps startup deterministic.
If you still see a race condition
If another skill is acting before the connection script finishes, the next step is to:
For more on the skill itself:
One question
Are your Auto Position actions being triggered by:
If you tell me which skill starts them, I can suggest the cleanest ordering so JD never moves on defaults.