Skip to content

Commit

Permalink
Merge pull request #2827 from irarykim/develop-hw
Browse files Browse the repository at this point in the history
로봇아이 블록 수정
  • Loading branch information
Tnks2U authored Sep 24, 2024
2 parents a7883e5 + 95bd9c9 commit cdb83f0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 48 deletions.
68 changes: 38 additions & 30 deletions src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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); }
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
44 changes: 26 additions & 18 deletions src/playground/blocks/hardwareLite/block_robotis_robotai_lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cdb83f0

Please sign in to comment.