-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
489 lines (446 loc) · 19.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
const ArgumentType = require('../../extension-support/argument-type');
const BlockType = require('../../extension-support/block-type');
const formatMessage = require('format-message');
const AdapterBaseClient = require('./codelab_adapter_base.js');
// const blockIconURI = require("./icon.svg");
const blockIconURI =
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyNC4wLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0i5Zu+5bGCXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNDAgNDAiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQwIDQwOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDojRDFEMUQxO30NCgkuc3Qxe2ZpbGw6I0JBQkFCQTt9DQoJLnN0MntmaWxsOiNGM0YzRjM7fQ0KCS5zdDN7ZmlsbDojRkZGRkZGO30NCgkuc3Q0e2ZpbGw6IzNBM0EzQTt9DQo8L3N0eWxlPg0KPHRpdGxlPuaJqeWxleaPkuS7tumFjeWbvuiuvuiuoTwvdGl0bGU+DQo8Zz4NCgk8Zz4NCgkJPGVsbGlwc2UgdHJhbnNmb3JtPSJtYXRyaXgoMC4wODgzIC0wLjk5NjEgMC45OTYxIDAuMDg4MyA3LjEwMiA1Ny4yNjY1KSIgY2xhc3M9InN0MCIgY3g9IjM0LjgzIiBjeT0iMjQuNzUiIHJ4PSI2LjAzIiByeT0iMi4x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sMC43OSw0Ljk4LDIuMDFDMjYuMzgsOS40NCwyNS4wNywxMS43OSwyNC4yOCwxNC4wN3oiLz4NCgkJPC9nPg0KCQk8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMzAuMzksMTYuNDJjLTIuNjIsMi40NS03LjE2LDIuODgtOC4xMiwxLjQ5Yy0wLjUyLTAuODcsMS4zMS0xLjgzLDIuMS01LjI0YzAuNjEtMi42Mi0wLjA5LTMuNjcsMC42MS00LjE5DQoJCQljMS41Ny0xLjE0LDcuMTYsMi4wMSw2Ljk5LDUuMjRDMzEuOTcsMTUuMDMsMzEuMDEsMTUuOSwzMC4zOSwxNi40MnoiLz4NCgkJPHBhdGggY2xhc3M9InN0MCIgZD0iTTkuMDgsMTYuNDJjMi42MiwyLjQ1LDcuMTYsMi44OCw4LjEyLDEuNDljMC41Mi0wLjg3LTEuMzEtMS44My0yLjEtNS4yNEMxNC41LDEwLjA1LDE1LjE5LDksMTQuNSw4LjQ4DQoJCQljLTEuNTctMS4xNC03LjE2LDIuMDEtNi45OSw1LjI0QzcuNTEsMTUuMDMsOC40NywxNS45LDkuMDgsMTYuNDJ6Ii8+DQoJPC9nPg0KCTxwYXRoIGNsYXNzPSJzdDQiIGQ9Ik0xOS43NCwxOC4zNUwxOS43NCwxOC4zNWMtMC43OSwwLTEuNjYtMC40NC0xLjgzLTEuMTRsLTAuNDQtMS4xNGMtMC41Mi0xLjQsMC40NC0zLjE0LDIuMjctMy4xNGwwLDANCgkJYzEuODMsMCwyLjgsMS43NSwyLjI3LDMuMTRsLTAuNDQsMS4xNEMyMS40LDE3LjkxLDIwLjUyLDE4LjM1LDE5Ljc0LDE4LjM1eiIvPg0KPC9nPg0KPC9zdmc+DQo=';
const menuIconURI = blockIconURI;
/**
* Enum for button parameter values.
* @readonly
* @enum {string}
*/
const NODE_ID = 'eim/node_alphamini';
const HELP_URL = 'https://adapter.codelab.club/extension_guide/alphamini/';
// 翻译
const FormHelp = {
'en': 'help',
'zh-cn': '帮助'
};
const FormSetEmitTimeout = {
'en': 'set wait timeout [emit_timeout]s',
'zh-cn': '设置等待超时时间[emit_timeout]秒'
};
const FormConnect = {
'en': 'connect alphamini robot [id] type [robot_type]',
'zh-cn': '连接悟空机器人[id]类型[robot_type]'
};
const FormDisConnect = {
'en': 'disconnect',
'zh-cn': '断开连接'
};
const Form_control_node = {
'en': '[turn] [node_name]',
'zh-cn': '[turn] [node_name]'
};
const FormMove = {
'en': '[step]step(s) [direction]',
'zh-cn': '向 [direction] 前进 [step]步'
};
const FormSay = {
'en': 'say [x]',
'zh-cn': '说[x]'
};
const FormPlayBehavior = {
'en': 'play behavior [name]',
'zh-cn': '表演舞蹈 [name]'
};
const FormPlayAction = {
'en': 'play action [name]',
'zh-cn': '展示动作 [name]'
};
const FormPlayExpression = {
'en': 'play expression [name]',
'zh-cn': '展示表情 [name]'
};
const Form_sendTopicMessageAndWait = {
'en': 'broadcast [content] and wait',
'zh-cn': '广播[content]并等待'
};
const Form_sendTopicMessageAndWait_REPORTER = {
'en': 'broadcast [content] and wait',
'zh-cn': '广播[content]并等待'
};
const FormGetInfraredDistance = {
'en': 'get infrared distance',
'zh-cn': '前方障碍物距离'
};
// face_detect
const FormFaceDetectCount = {
'en': 'face count',
'zh-cn': '识别到人脸数量'
};
const FormFaceAnalysis = {
'en': 'face info',
'zh-cn': '人脸信息'
};
const FormFaceRecognise = {
'en': 'face id',
'zh-cn': '人脸id'
};
class AdapterClient {
onAdapterPluginMessage (msg) {
this.node_id = msg.message.payload.node_id;
if (this.node_id === this.NODE_ID) {
// json 数据, class
this.adapter_node_content_hat = msg.message.payload.content;
this.adapter_node_content_reporter = msg.message.payload.content;
console.log('content ->', msg.message.payload.content);
}
}
constructor (node_id, help_url) {
this.NODE_ID = node_id;
this.HELP_URL = help_url;
this.emit_timeout = 10000; // ms
this.adapter_base_client = new AdapterBaseClient(
null, // onConnect,
null, // onDisconnect,
null, // onMessage,
this.onAdapterPluginMessage.bind(this), // onAdapterPluginMessage,
null, // update_nodes_status,
null, // node_statu_change_callback,
null, // notify_callback,
null, // error_message_callback,
null // update_adapter_status
);
}
emit_with_messageid (NODE_ID, content) {
return this.adapter_base_client.emit_with_messageid(
NODE_ID,
content,
this.emit_timeout
);
}
}
class Scratch3AlphaminiBlocks {
constructor (runtime) {
this.client = new AdapterClient(NODE_ID, HELP_URL, runtime, this);
}
/**
* The key to load & store a target's test-related state.
* @type {string}
*/
static get STATE_KEY () {
return 'Scratch.alphamini';
}
_setLocale () {
let now_locale = '';
switch (formatMessage.setup().locale) {
case 'en':
now_locale = 'en';
break;
case 'zh-cn':
now_locale = 'zh-cn';
break;
default:
now_locale = 'zh-cn';
break;
}
return now_locale;
}
/**
* @returns {object} metadata for this extension and its blocks.
*/
getInfo () {
const the_locale = this._setLocale();
return {
id: 'alphamini',
name: '悟空机器人',
colour: '#ff641d',
colourSecondary: '#c94f18',
colourTertiary: '#c94f18',
menuIconURI: menuIconURI,
blockIconURI: blockIconURI,
blocks: [
{
opcode: 'open_help_url',
blockType: BlockType.COMMAND,
text: FormHelp[the_locale],
arguments: {}
},
{
opcode: 'set_emit_timeout',
blockType: BlockType.COMMAND,
text: FormSetEmitTimeout[the_locale],
arguments: {
emit_timeout: {
type: ArgumentType.NUMBER,
defaultValue: 10.0
}
}
},
{
opcode: 'control_node',
blockType: BlockType.COMMAND,
text: Form_control_node[the_locale],
arguments: {
turn: {
type: ArgumentType.STRING,
defaultValue: 'start',
menu: 'turn'
},
node_name: {
type: ArgumentType.STRING,
defaultValue: 'node_alphamini'
}
}
},
{
opcode: 'connect',
blockType: BlockType.COMMAND,
text: FormConnect[the_locale],
arguments: {
id: {
type: ArgumentType.STRING,
defaultValue: '00447'
},
robot_type: {
type: ArgumentType.STRING,
defaultValue: 'DEDU',
menu: 'robot_type'
}
}
},
/*
{
opcode: "disconnect",
blockType: BlockType.COMMAND,
text: FormDisConnect[the_locale]
},*/
// FormDisConnect
{
opcode: 'move',
blockType: BlockType.COMMAND,
text: FormMove[the_locale],
arguments: {
step: {
type: ArgumentType.NUMBER,
defaultValue: 1
},
direction: {
type: ArgumentType.STRING,
defaultValue: 'FORWARD',
menu: 'direction'
}
}
},
{
opcode: 'say',
blockType: BlockType.COMMAND,
text: FormSay[the_locale],
arguments: {
x: {
type: ArgumentType.STRING,
defaultValue: '你好'
}
}
},
{
opcode: 'get_infrared_distance',
blockType: BlockType.REPORTER,
text: FormGetInfraredDistance[the_locale],
arguments: {}
},
//
{
opcode: 'get_face_count',
blockType: BlockType.REPORTER,
text: FormFaceDetectCount[the_locale],
arguments: {}
},
// face_analysis
{
opcode: 'face_analysis',
blockType: BlockType.REPORTER,
text: FormFaceAnalysis[the_locale],
arguments: {}
},
{
opcode: 'face_recognise',
blockType: BlockType.REPORTER,
text: FormFaceRecognise[the_locale],
arguments: {}
},
//
{
opcode: 'play_behavior',
blockType: BlockType.COMMAND,
text: FormPlayBehavior[the_locale],
arguments: {
name: {
type: ArgumentType.STRING,
defaultValue: 'custom_0035' // 生日快乐
}
}
},
{
opcode: 'play_action',
blockType: BlockType.COMMAND,
text: FormPlayAction[the_locale],
arguments: {
name: {
type: ArgumentType.NUMBER,
defaultValue: '010' // 打招呼
}
}
},
{
opcode: 'play_expression',
blockType: BlockType.COMMAND,
text: FormPlayExpression[the_locale],
arguments: {
name: {
type: ArgumentType.STRING,
defaultValue: 'codemao13' // 疑问
}
}
},
//
{
opcode: 'broadcastTopicMessageAndWait',
blockType: BlockType.COMMAND,
text: Form_sendTopicMessageAndWait[the_locale],
arguments: {
content: {
type: ArgumentType.STRING,
defaultValue:
"robot.play_action(action_name='010')"
}
}
},
{
opcode: 'broadcastTopicMessageAndWait_REPORTER',
blockType: BlockType.REPORTER,
text: Form_sendTopicMessageAndWait_REPORTER[the_locale],
arguments: {
content: {
type: ArgumentType.STRING,
defaultValue: 'robot.GetActionList()'
}
}
}
/*
{
opcode: "getbattery",
blockType: BlockType.REPORTER,
text: formatMessage({
default: formatMessage({
id: "cxtello.actionMenu.getbattery",
default: "get battery",
description: "getbattery",
}),
description: "getbattery",
}),
},*/
],
menus: {
turn: {
acceptReporters: true,
items: ['start', 'stop']
},
robot_type: {
acceptReporters: true,
items: ['DEDU', 'MINI']
},
direction: {
acceptReporters: true,
items: ['FORWARD', 'BACKWARD', 'LEFTWARD', 'RIGHTWARD']
}
}
};
}
connect (args) {
const id = args.id;
const content = `robot.connect("${id}", "${args.robot_type}")`; // todo 兼容旧的
return this.client.emit_with_messageid(NODE_ID, content); // timeout
}
say (args) {
const x = args.x;
const content = `robot.say(text="${x}")`;
return this.client.emit_with_messageid(NODE_ID, content);
}
// 前方障碍物距离 get_infrared_distance
get_infrared_distance (args) {
const content = `robot.get_infrared_distance()`;
return this.client.emit_with_messageid(NODE_ID, content);
}
get_face_count (args) {
const content = `robot.face_detect()`;
return this.client.emit_with_messageid(NODE_ID, content);
}
//
face_analysis (args) {
const content = `robot.face_analysis()`;
return this.client.emit_with_messageid(NODE_ID, content);
}
face_recognise (args) {
const content = `robot.face_recognise()`;
return this.client.emit_with_messageid(NODE_ID, content);
}
move (args) {
// step=1, direction="FORWARD"
const step = args.step;
const direction = args.direction;
const content = `robot.move(${step}, "${direction}")`;
return this.client.emit_with_messageid(NODE_ID, content);
}
play_behavior (args) {
const name = args.name;
const content = `robot.play_behavior(name='${name}')`;
return this.client.emit_with_messageid(NODE_ID, content);
}
play_action (args) {
const name = args.name;
const content = `robot.play_action(action_name='${name}')`;
return this.client.emit_with_messageid(NODE_ID, content);
}
play_expression (args) {
const name = args.name;
const content = `robot.play_expression(express_name='${name}')`;
return this.client.emit_with_messageid(NODE_ID, content);
}
// broadcast
broadcastTopicMessageAndWait (args) {
const node_id = args.node_id;
const content = args.content;
return this.client.emit_with_messageid(node_id, content);
}
getbattery () {
return this.client.emit_with_messageid(NODE_ID, 'tello.get_battery()');
}
open_help_url (args) {
window.open(HELP_URL);
}
control_node (args) {
const content = args.turn;
const node_name = args.node_name;
return this.client.adapter_base_client.emit_with_messageid_for_control(
NODE_ID,
content,
node_name,
'node'
);
}
set_emit_timeout (args) {
const timeout = parseFloat(args.emit_timeout) * 1000;
this.client.emit_timeout = timeout;
}
broadcastTopicMessageAndWait (args) {
// topic服务于消息功能, node_id承载业务逻辑(extension)
const content = args.content;
return this.client.adapter_base_client.emit_with_messageid(
NODE_ID,
content
);
}
broadcastTopicMessageAndWait_REPORTER (args) {
// topic服务于消息功能, node_id承载业务逻辑(extension)
const content = args.content;
return this.client.adapter_base_client.emit_with_messageid(
NODE_ID,
content
);
}
}
module.exports = Scratch3AlphaminiBlocks;