Skip to content

Commit

Permalink
스마트팜 전용블록 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
irarykim committed Sep 4, 2024
1 parent 9a10380 commit fabdd1d
Showing 1 changed file with 242 additions and 0 deletions.
242 changes: 242 additions & 0 deletions src/playground/blocks/hardware/block_robotisRBPracticalAssembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,19 @@ Entry.Robotis_rb_P_Assembly.blockMenuBlocks = [
'robotis_Practice_stop_at_cross',
'robotis_Practice_turn_at_line',
'robotis_Practice_drive_stop',

'robotis_Practice_securitybot_init',
'robotis_Practice_securitybot_hi',
'robotis_Practice_securitybot_alert',

'robotis_Practice_petbot_happy',
'robotis_Practice_petbot_sad',

'robotis_Practice_farmbot_init',
'robotis_Practice_farmbot_seek',
'robotis_Practice_farmbot_plant_type',
'robotis_Practice_farmbot_harvest_or_not_and_go',

// 값 블록
'robotis_Practice_cm_ir_value',
'robotis_Practice_detectFrontObj',
Expand Down Expand Up @@ -173,12 +180,19 @@ Entry.Robotis_rb_P_Assembly.setLanguage = function () {
robotis_Practice_stop_at_cross: "교차로 %1 에서 멈추기 %2",
robotis_Practice_turn_at_line: "교차로에서 %1 하고 멈추기 %2",
robotis_Practice_drive_stop: "정지하기 %1",

robotis_Practice_securitybot_init: "보안로봇 초기화 %1",
robotis_Practice_securitybot_hi: "보안로봇 위아래로 흔들기 %1",
robotis_Practice_securitybot_alert: "보안로봇 좌우로 흔들기 %1",

robotis_Practice_petbot_happy: "반려로봇 웃음 %1",
robotis_Practice_petbot_sad: "반려로봇 화남 %1",

robotis_Practice_farmbot_init: "스마트팜 로봇 초기화 %1",
robotis_Practice_farmbot_seek: "농작물 찾기 %1",
robotis_Practice_farmbot_plant_type: "%1 농작물이면",
robotis_Practice_farmbot_harvest_or_not_and_go: "농작물 %1 돌아가기 %2",


// 값 블록
robotis_Practice_cm_ir_value: "%1 적외선센서 값",
Expand Down Expand Up @@ -739,6 +753,11 @@ Entry.Robotis_rb_P_Assembly.setLanguage = function () {
robotis_huskylens_center_arrow_origin_y: "시작점 Y좌표",
robotis_huskylens_center_arrow_target_x: "끝점 X좌표",
robotis_huskylens_center_arrow_target_y: "끝점 Y좌표",

robotis_plant_ripe: "빨간색으로 잘 익은",
robotis_plant_unripe: "초록색으로 덜 익은",
robotis_harvest: "수확하고",
robotis_not_harvest: "수확하지 않고",
},
},
en: {
Expand All @@ -754,6 +773,18 @@ Entry.Robotis_rb_P_Assembly.setLanguage = function () {
robotis_Practice_stop_at_cross: "Stop at cross %1 %2",
robotis_Practice_turn_at_line: "%1 at cross and stop %2",
robotis_Practice_drive_stop: "Stop %1",

robotis_Practice_securitybot_init: "Security robot init %1",
robotis_Practice_securitybot_hi: "Security robot shake up and down %1",
robotis_Practice_securitybot_alert: "Security robot shake left and right %1",

robotis_Practice_petbot_happy: "Petbot laugh %1",
robotis_Practice_petbot_sad: "Petbot angry %1",

robotis_Practice_farmbot_init: "SmartFarm Robot init %1",
robotis_Practice_farmbot_seek: "Look for plant %1",
robotis_Practice_farmbot_plant_type: "If it is %1 plant",
robotis_Practice_farmbot_harvest_or_not_and_go: "%1 the plant and go back %2",



Expand Down Expand Up @@ -1110,6 +1141,11 @@ Entry.Robotis_rb_P_Assembly.setLanguage = function () {
robotis_huskylens_center_arrow_origin_y: "Origin Y",
robotis_huskylens_center_arrow_target_x: "Target X",
robotis_huskylens_center_arrow_target_y: "Target Y",

robotis_plant_ripe: "ripe in red",
robotis_plant_unripe: "green and unripe",
robotis_harvest: "Harvest",
robotis_not_harvest: "Skip harvesting",
},
}
}
Expand Down Expand Up @@ -2200,6 +2236,212 @@ Entry.Robotis_rb_P_Assembly.getBlocks = function () {
},


robotis_Practice_farmbot_init: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic',
statements: [],
params: [
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
size: 12,
},
],
events: {},
def: {
params: [
null,
],
type: 'robotis_Practice_farmbot_init',
},
paramsKeyMap: {
},
class: 'robotis_rb100_practice_special',
isNotFor: ['Robotis_rb_P_Assembly'],
func: function (sprite, script) {
// instruction / address / length / value / default length

var data_sendqueue = [
[
Entry.Robotis_rb.INSTRUCTION.WRITE, 2130, 1, 1
]
];
return Entry.Robotis_carCont.postCallReturn(
script,
data_sendqueue,
3000
);
},
syntax: {
js: [],
py: ['Robotis.farmbot_init()'],
},
},
robotis_Practice_farmbot_seek: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic',
statements: [],
params: [
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
size: 12,
},
],
events: {},
def: {
params: [
null,
],
type: 'robotis_Practice_farmbot_seek',
},
paramsKeyMap: {
},
class: 'robotis_rb100_practice_special',
isNotFor: ['Robotis_rb_P_Assembly'],
func: function (sprite, script) {
// instruction / address / length / value / default length

var data_sendqueue = [
[
Entry.Robotis_rb.INSTRUCTION.WRITE, 2131, 1, 1
]
];
return Entry.Robotis_carCont.postCallReturn(
script,
data_sendqueue,
200
);
},
syntax: {
js: [],
py: ['Robotis.farmbot_seek()'],
},
},
robotis_Practice_farmbot_plant_type: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
fontColor: '#fff',
skeleton: 'basic_boolean_field',
statements: [],
params: [
{
type: 'Dropdown',
options: [
[Lang.Blocks.robotis_plant_ripe, '1'],
[Lang.Blocks.robotis_plant_unripe, '2'],
],
value: '1',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
],
events: {},
def: {
params: [
null,
],
type: 'robotis_Practice_farmbot_plant_type',
},
paramsKeyMap: {
TYPE: 0,
},
class: 'robotis_rb100_practice_special',
isNotFor: ['Robotis_rb_P_Assembly'],
func: function (sprite, script) {
var scope = script.executor.scope;
var compareValue = script.getNumberValue('TYPE');

var result = Entry.hw.portData[2134];

if(result == undefined) {
return false;
}

return (result == compareValue);
},
syntax: {
js: [],
py: ['Robotis.farmbot_is_type(%1)'],
},
},
robotis_Practice_farmbot_harvest_or_not_and_go: {
color: EntryStatic.colorSet.block.default.HARDWARE,
outerLine: EntryStatic.colorSet.block.darken.HARDWARE,
skeleton: 'basic',
statements: [],
params: [
{
type: 'Dropdown',
options: [
[Lang.Blocks.robotis_harvest, '1'],
[Lang.Blocks.robotis_not_harvest, '2'],
],
value: '1',
fontSize: 11,
bgColor: EntryStatic.colorSet.block.darken.HARDWARE,
arrowColor: EntryStatic.colorSet.arrow.default.HARDWARE,
},
{
type: 'Indicator',
img: 'block_icon/hardware_icon.svg',
size: 12,
},
],
events: {},
def: {
params: [
null,
null,
],
type: 'robotis_Practice_farmbot_harvest_or_not_and_go',
},
paramsKeyMap: {
ACTION: 0,
},
class: 'robotis_rb100_practice_special',
isNotFor: ['Robotis_rb_P_Assembly'],
func: function (sprite, script) {
// instruction / address / length / value / default length

let action = script.getNumberValue('ACTION', script);
let address = 2132;
let wait_time = 6000;

switch (action)
{
case 1:
address = 2132;
wait_time = 6000;
break;

case 2:
address = 2133;
wait_time = 1600;
break;
}

var data_sendqueue = [
[
Entry.Robotis_rb.INSTRUCTION.WRITE, address, 1, 1
]
];
return Entry.Robotis_carCont.postCallReturn(
script,
data_sendqueue,
wait_time
);
},
syntax: {
js: [],
py: ['Robotis.farmbot_harvest_or_not_and_go(%1)'],
},
},




robotis_Practice_cm_ir_value: {
Expand Down

0 comments on commit fabdd1d

Please sign in to comment.