diff --git a/src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js b/src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js index 561ff6a015..4128d7b09c 100644 --- a/src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js +++ b/src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js @@ -45,6 +45,7 @@ Entry.Robotis_rb_P_Assembly = { Entry.Robotis_carCont.setRobotisData([ [Entry.Robotis_rb.INSTRUCTION.WRITE, 2100, 1, 1], // PracticeBot Finish ]); + camera_id_for_use = 0; Entry.Robotis_carCont.update(); }, id: ['7.A', '7.B'], @@ -1155,6 +1156,7 @@ let dxl_last_valid_value = []; let rb100_last_valid_value = []; let bg_color = 0; let beat_per_minute = 75; +let camera_id_for_use = 0; const _doevent = ms => new Promise(res => setTimeout(res, ms)); async function wait(nTime) { await _doevent(nTime); } @@ -2415,12 +2417,12 @@ Entry.Robotis_rb_P_Assembly.getBlocks = function () { { case 1: address = 2132; - wait_time = 6000; + wait_time = 6500; break; case 2: address = 2133; - wait_time = 1600; + wait_time = 2100; break; } @@ -7056,20 +7058,23 @@ Entry.Robotis_rb_P_Assembly.getBlocks = function () { var data_length = 2; var data_value = script.getNumberValue('ID'); - var data_sendqueue = [ - [ - data_instruction, - data_address, - data_length, - data_value, - ], - ]; - - Entry.Robotis_carCont.postCallReturn( - script, - data_sendqueue, - Entry.Robotis_openCM70.delay - ); + if (camera_id_for_use != data_value) { + var data_sendqueue = [ + [ + data_instruction, + data_address, + data_length, + data_value, + ], + ]; + + Entry.Robotis_carCont.postCallReturn( + script, + data_sendqueue, + Entry.Robotis_openCM70.delay + ); + camera_id_for_use = data_value; + } data_address = 4036; // BLOCK_RESULT_BY_ID_X_CENTER @@ -7149,20 +7154,23 @@ Entry.Robotis_rb_P_Assembly.getBlocks = function () { var data_length = 2; var data_value = script.getNumberValue('ID'); - var data_sendqueue = [ - [ - data_instruction, - data_address, - data_length, - data_value, - ], - ]; - - Entry.Robotis_carCont.postCallReturn( - script, - data_sendqueue, - Entry.Robotis_openCM70.delay - ); + if (camera_id_for_use != data_value) { + var data_sendqueue = [ + [ + data_instruction, + data_address, + data_length, + data_value, + ], + ]; + + Entry.Robotis_carCont.postCallReturn( + script, + data_sendqueue, + Entry.Robotis_openCM70.delay + ); + camera_id_for_use = data_value; + } data_address = 4044; // ARROW_RESULT_BY_ID_X_ORIGIN diff --git a/src/playground/blocks/hardwareLite/block_robotis_robotai_lite.js b/src/playground/blocks/hardwareLite/block_robotis_robotai_lite.js index a283bfe877..420a9d2edc 100644 --- a/src/playground/blocks/hardwareLite/block_robotis_robotai_lite.js +++ b/src/playground/blocks/hardwareLite/block_robotis_robotai_lite.js @@ -156,6 +156,7 @@ const crcTable = [ const rb100_last_valid_value = []; let bg_color = 0; let beat_per_minute = 75; +let camera_id_for_use = 0; (function () { Entry.RobotisRobotaiLite = new (class RobotisRobotaiLite { @@ -296,6 +297,7 @@ let beat_per_minute = 75; this.__removeAllTimeouts(); this.robotisBuffer = []; this.robotisBuffer.push([INST_WRITE, 2100, 1, 1]); + camera_id_for_use = 0; if (Entry.hwLite && Entry.hwLite.serial) { Entry.hwLite.serial.update(); } @@ -2925,12 +2927,12 @@ let beat_per_minute = 75; switch (action) { case 1: address = 2132; - wait_time = 6000; + wait_time = 6500; break; case 2: address = 2133; - wait_time = 1600; + wait_time = 2100; break; } @@ -6995,15 +6997,18 @@ let beat_per_minute = 75; let data_length = 2; let data_value = script.getNumberValue('ID'); - let data_sendqueue = [ - [data_instruction, data_address, data_length, data_value], - ]; + if (data_value != camera_id_for_use) { + let data_sendqueue = [ + [data_instruction, data_address, data_length, data_value], + ]; - Entry.RobotisRobotaiLite.postCallReturn( - script, - data_sendqueue, - DEFAULT_DELAY - ); + Entry.RobotisRobotaiLite.postCallReturn( + script, + data_sendqueue, + DEFAULT_DELAY + ); + camera_id_for_use = data_value; + } data_address = 4036; // BLOCK_RESULT_BY_ID_X_CENTER @@ -7080,15 +7085,18 @@ let beat_per_minute = 75; let data_length = 2; let data_value = script.getNumberValue('ID'); - let data_sendqueue = [ - [data_instruction, data_address, data_length, data_value], - ]; + if (data_value != camera_id_for_use) { + let data_sendqueue = [ + [data_instruction, data_address, data_length, data_value], + ]; - Entry.RobotisRobotaiLite.postCallReturn( - script, - data_sendqueue, - DEFAULT_DELAY - ); + Entry.RobotisRobotaiLite.postCallReturn( + script, + data_sendqueue, + DEFAULT_DELAY + ); + camera_id_for_use = data_value; + } data_address = 4044; // ARROW_RESULT_BY_ID_X_ORIGIN