Skip to content

Commit b58795c

Browse files
Add default action gap and discourage auto rest command
Co-authored-by: Rongzhong Li <rzlib2l@gmail.com>
1 parent d93405f commit b58795c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

blocks/generators.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,6 +1821,18 @@ await (async function() {
18211821
await waitForSerialTokenLine(token, timeout, __from);
18221822
}
18231823
if (typeof window !== 'undefined') window.__lastTokenReceivedAt = Date.now();
1824+
// Default anti-sticking gap between consecutive motion commands: 0.01s
1825+
const __postGapMs = (typeof window !== 'undefined' && typeof window.__actionCommandGapMs === 'number')
1826+
? Math.max(0, window.__actionCommandGapMs)
1827+
: 10;
1828+
if (__postGapMs > 0) {
1829+
const __endAt = Date.now() + __postGapMs;
1830+
while (Date.now() < __endAt) {
1831+
checkStopExecution();
1832+
const __wait = Math.min(10, __endAt - Date.now());
1833+
if (__wait > 0) await new Promise(r => setTimeout(r, __wait));
1834+
}
1835+
}
18241836
}
18251837
// delayAfterToken: delay starting from when robot completed
18261838
async function __delayAfterToken(ms) {

main.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,8 @@ <h3 style="color: #4CAF50;">${title}</h3>
43214321
Gesture: encodeCommand("XGr",[])=enable,"XGp"=poll,"Xg"=exit
43224322
43234323
PATTERN: await sendAndWait("khi",10000,'k'); await delayAfterToken(500); await sendAndWait("khsk",10000,'k');
4324-
RULE: ALWAYS use built-in k* skill for named actions. NEVER compose joint movements for actions that have a skill command.`;
4324+
RULE: ALWAYS use built-in k* skill for named actions. NEVER compose joint movements for actions that have a skill command.
4325+
RULE: DO NOT insert rest command "d" between actions unless user explicitly asks for rest/sleep/lying down/final relax.`;
43254326

43264327
const seed = Math.floor(Math.random() * 1000000);
43274328
const userPrompt = `Generate JavaScript code for: "${description}"`;

0 commit comments

Comments
 (0)