@@ -1041,11 +1041,11 @@ Blockly.Blocks['niryo_one_tool_select'] = {
1041
1041
init : function ( ) {
1042
1042
this . appendDummyInput ( ) . appendField (
1043
1043
new Blockly . FieldDropdown ( [
1044
- [ 'Standard gripper' , 'GRIPPER_1_ID ' ] ,
1045
- [ 'Large gripper' , 'GRIPPER_2_ID ' ] ,
1046
- [ 'Adaptive gripper ' , 'GRIPPER_3_ID ' ] ,
1047
- [ 'Electromagnet 1' , 'ELECTROMAGNET_1_ID ' ] ,
1048
- [ 'Vacuum pump 1' , 'VACUUM_PUMP_1_ID ' ]
1044
+ [ 'Standard gripper' , 'GRIPPER_1 ' ] ,
1045
+ [ 'Large gripper' , 'GRIPPER_2 ' ] ,
1046
+ [ 'Adaptive gripper ' , 'GRIPPER_3 ' ] ,
1047
+ [ 'Electromagnet 1' , 'ELECTROMAGNET_1 ' ] ,
1048
+ [ 'Vacuum pump 1' , 'VACUUM_PUMP_1 ' ]
1049
1049
] ) ,
1050
1050
'TOOL_SELECT'
1051
1051
) ;
@@ -1056,6 +1056,16 @@ Blockly.Blocks['niryo_one_tool_select'] = {
1056
1056
}
1057
1057
} ;
1058
1058
1059
+ Blockly . Blocks [ 'niryo_one_get_current_tool_id' ] = {
1060
+ init : function ( ) {
1061
+ this . appendDummyInput ( ) . appendField ( 'Get current tool id' ) ;
1062
+ this . setOutput ( true , 'niryo_one_tool_select' ) ;
1063
+ this . setColour ( tool_color ) ;
1064
+ this . setTooltip ( '' ) ;
1065
+ this . setHelpUrl ( '' ) ;
1066
+ }
1067
+ } ;
1068
+
1059
1069
Blockly . Blocks [ 'niryo_one_update_tool' ] = {
1060
1070
init : function ( ) {
1061
1071
this . appendDummyInput ( ) . appendField ( 'Update tool' ) ;
@@ -1067,16 +1077,31 @@ Blockly.Blocks['niryo_one_update_tool'] = {
1067
1077
}
1068
1078
} ;
1069
1079
1070
- // Blockly.Blocks['niryo_one_detach_tool'] = {
1071
- // init: function () {
1072
- // this.appendDummyInput().appendField('Detach current tool');
1073
- // this.setPreviousStatement(true, null);
1074
- // this.setNextStatement(true, null);
1075
- // this.setColour(tool_color);
1076
- // this.setTooltip('');
1077
- // this.setHelpUrl('');
1078
- // }
1079
- // };
1080
+ Blockly . Blocks [ 'niryo_one_grasp_with_tool' ] = {
1081
+ init : function ( ) {
1082
+ this . appendDummyInput ( ) . appendField ( 'Grasp with tool' ) ;
1083
+ this . setPreviousStatement ( true , null ) ;
1084
+ this . setNextStatement ( true , null ) ;
1085
+ this . setColour ( tool_color ) ;
1086
+ this . setTooltip (
1087
+ 'Grasp with tool | This action correspond to | - Close gripper for Grippers | - Pull Air for Vacuum pump | - Activate for Electromagnet'
1088
+ ) ;
1089
+ this . setHelpUrl ( '' ) ;
1090
+ }
1091
+ } ;
1092
+
1093
+ Blockly . Blocks [ 'niryo_one_release_with_tool' ] = {
1094
+ init : function ( ) {
1095
+ this . appendDummyInput ( ) . appendField ( 'Release with tool' ) ;
1096
+ this . setPreviousStatement ( true , null ) ;
1097
+ this . setNextStatement ( true , null ) ;
1098
+ this . setColour ( tool_color ) ;
1099
+ this . setTooltip (
1100
+ 'Release with tool | This action correspond to | - Open gripper for Grippers | - Push Air for Vacuum pump | - Deactivate for Electromagnet'
1101
+ ) ;
1102
+ this . setHelpUrl ( '' ) ;
1103
+ }
1104
+ } ;
1080
1105
1081
1106
Blockly . Blocks [ 'niryo_one_open_gripper' ] = {
1082
1107
init : function ( ) {
@@ -1195,6 +1220,68 @@ Blockly.Blocks['niryo_one_deactivate_electromagnet'] = {
1195
1220
}
1196
1221
} ;
1197
1222
1223
+ Blockly . Blocks [ 'niryo_one_enable_tcp' ] = {
1224
+ init : function ( ) {
1225
+ this . appendDummyInput ( )
1226
+ . appendField ( 'Enable TCP' )
1227
+ . appendField (
1228
+ new Blockly . FieldDropdown ( [
1229
+ [ 'True' , '1' ] ,
1230
+ [ 'False' , '0' ]
1231
+ ] ) ,
1232
+ 'ENABLE_TCP'
1233
+ ) ;
1234
+ this . setInputsInline ( true ) ;
1235
+ this . setPreviousStatement ( true , null ) ;
1236
+ this . setNextStatement ( true , null ) ;
1237
+ this . setColour ( tool_color ) ;
1238
+ this . setTooltip (
1239
+ 'Enables or disables the TCP function (Tool Center Point). If activation is requested, the last recorded TCP value will be applied. The default value depends on the gripper equipped. If deactivation is requested, the TCP will be coincident with the tool_link.'
1240
+ ) ;
1241
+ this . setHelpUrl ( '' ) ;
1242
+ }
1243
+ } ;
1244
+
1245
+ Blockly . Blocks [ 'niryo_one_set_tcp' ] = {
1246
+ init : function ( ) {
1247
+ this . appendValueInput ( 'POSE' )
1248
+ . setCheck ( 'niryo_one_pose' )
1249
+ . appendField ( 'Set tcp with pose' ) ;
1250
+ this . setTooltip (
1251
+ 'Activates the TCP function (Tool Center Point) and defines the transformation between the tool_link frame and the TCP frame.'
1252
+ ) ;
1253
+ this . setPreviousStatement ( true , null ) ;
1254
+ this . setNextStatement ( true , null ) ;
1255
+ this . setColour ( tool_color ) ;
1256
+ this . setHelpUrl ( '' ) ;
1257
+ }
1258
+ } ;
1259
+
1260
+ Blockly . Blocks [ 'niryo_one_reset_tcp' ] = {
1261
+ init : function ( ) {
1262
+ this . appendDummyInput ( ) . appendField ( 'Reset TCP' ) ;
1263
+ this . setPreviousStatement ( true , null ) ;
1264
+ this . setNextStatement ( true , null ) ;
1265
+ this . setColour ( tool_color ) ;
1266
+ this . setTooltip (
1267
+ 'Reset the TCP (Tool Center Point) transformation. The TCP will be reset according to the tool equipped.'
1268
+ ) ;
1269
+ this . setHelpUrl ( '' ) ;
1270
+ }
1271
+ } ;
1272
+
1273
+ Blockly . Blocks [ 'niryo_one_tool_reboot' ] = {
1274
+ init : function ( ) {
1275
+ this . appendDummyInput ( ) . appendField ( 'Reboot tool' ) ;
1276
+ this . setPreviousStatement ( true , null ) ;
1277
+ this . setNextStatement ( true , null ) ;
1278
+ this . setColour ( tool_color ) ;
1279
+ this . setTooltip (
1280
+ 'Reboot the motor of the tool equparam_list = [workspace_name]'
1281
+ ) ;
1282
+ this . setHelpUrl ( '' ) ;
1283
+ }
1284
+ } ;
1198
1285
// Utility
1199
1286
1200
1287
Blockly . Blocks [ 'niryo_one_wait' ] = {
@@ -1496,10 +1583,6 @@ Blockly.Blocks['niryo_one_play_sound'] = {
1496
1583
. setCheck ( 'String' )
1497
1584
. appendField ( 'Play sound named' ) ;
1498
1585
1499
- // this.appendValueInput('WAIT_END')
1500
- // .setcheck('Boolean')
1501
- // .appendField('wait until the end');
1502
-
1503
1586
this . appendDummyInput ( ) . appendField ( 'wait until the end' ) ;
1504
1587
this . appendDummyInput ( ) . appendField (
1505
1588
new Blockly . FieldDropdown ( [
@@ -2186,8 +2269,24 @@ BlocklyPy['niryo_one_set_12v_switch'] = function (block) {
2186
2269
// Tool
2187
2270
2188
2271
BlocklyPy [ 'niryo_one_tool_select' ] = function ( block ) {
2189
- var dropdown_tool_select = block . getFieldValue ( 'TOOL_SELECT' ) ;
2190
- var code = dropdown_tool_select ;
2272
+ const tool_id_map = {
2273
+ NONE : 0 ,
2274
+ GRIPPER_1 : 11 ,
2275
+ GRIPPER_2 : 12 ,
2276
+ GRIPPER_3 : 13 ,
2277
+ ELECTROMAGNET_1 : 30 ,
2278
+ VACUUM_PUMP_1 : 31
2279
+ } ;
2280
+ var tool_model_id = block . getFieldValue ( 'TOOL_SELECT' ) ;
2281
+ var code = tool_id_map [ tool_model_id ] ;
2282
+
2283
+ // var dropdown_tool_select = block.getFieldValue('TOOL_SELECT');
2284
+ // var code = dropdown_tool_select;
2285
+ return [ code , BlocklyPy . ORDER_NONE ] ;
2286
+ } ;
2287
+
2288
+ BlocklyPy [ 'niryo_one_get_current_tool_id' ] = function ( block ) {
2289
+ var code = 'n.get_current_tool_id()\n' ;
2191
2290
return [ code , BlocklyPy . ORDER_NONE ] ;
2192
2291
} ;
2193
2292
@@ -2196,11 +2295,15 @@ BlocklyPy['niryo_one_update_tool'] = function (block) {
2196
2295
return code ;
2197
2296
} ;
2198
2297
2199
- // new function corresponds to release_with_tool (made in pair with grasp_with_tool)
2200
- // BlocklyPy['niryo_one_detach_tool'] = function (block) {
2201
- // var code = 'n.change_tool(0)\n';
2202
- // return code;
2203
- // };
2298
+ BlocklyPy [ 'niryo_one_grasp_with_tool' ] = function ( block ) {
2299
+ var code = 'n.grasp_with_tool()\n' ;
2300
+ return [ code , BlocklyPy . ORDER_NONE ] ;
2301
+ } ;
2302
+
2303
+ BlocklyPy [ 'niryo_one_release_with_tool' ] = function ( block ) {
2304
+ var code = 'n.release_with_tool()\n' ;
2305
+ return [ code , BlocklyPy . ORDER_NONE ] ;
2306
+ } ;
2204
2307
2205
2308
BlocklyPy [ 'niryo_one_open_gripper' ] = function ( block ) {
2206
2309
var number_open_speed = block . getFieldValue ( 'OPEN_SPEED' ) ;
@@ -2266,6 +2369,30 @@ BlocklyPy['niryo_one_deactivate_electromagnet'] = function (block) {
2266
2369
return code ;
2267
2370
} ;
2268
2371
2372
+ BlocklyPy [ 'niryo_one_enable_tcp' ] = function ( block ) {
2373
+ var dropdown_enable_tcp = block . getFieldValue ( 'ENABLE_TCP' ) ;
2374
+ var code = 'n.enable_tcp(' + dropdown_enable_tcp + ')\n' ;
2375
+ return [ code , BlocklyPy . ORDER_NONE ] ;
2376
+ } ;
2377
+
2378
+ BlocklyPy [ 'niryo_one_set_tcp' ] = function ( block ) {
2379
+ var value_pose = BlocklyPy . valueToCode ( block , 'POSE' , BlocklyPy . ORDER_ATOMIC ) ;
2380
+ value_pose = value_pose . replace ( '(' , '' ) . replace ( ')' , '' ) ;
2381
+
2382
+ var code = 'n.set_tcp(' + value_pose + ')\n' ;
2383
+ return code ;
2384
+ } ;
2385
+
2386
+ BlocklyPy [ 'niryo_one_reset_tcp' ] = function ( block ) {
2387
+ var code = 'n.reset_tcp()\n' ;
2388
+ return code ;
2389
+ } ;
2390
+
2391
+ BlocklyPy [ 'niryo_one_tool_reboot' ] = function ( block ) {
2392
+ var code = 'n.tool_reboot()\n' ;
2393
+ return code ;
2394
+ } ;
2395
+
2269
2396
// Utility
2270
2397
2271
2398
BlocklyPy [ 'niryo_one_wait' ] = function ( block ) {
@@ -3067,14 +3194,22 @@ const TOOLBOX = {
3067
3194
kind : 'BLOCK' ,
3068
3195
type : 'niryo_one_tool_select'
3069
3196
} ,
3197
+ {
3198
+ kind : 'BLOCK' ,
3199
+ type : 'niryo_one_get_current_tool_id'
3200
+ } ,
3070
3201
{
3071
3202
kind : 'BLOCK' ,
3072
3203
type : 'niryo_one_update_tool'
3073
3204
} ,
3074
- // {
3075
- // kind: 'BLOCK',
3076
- // type: 'niryo_one_detach_tool'
3077
- // },
3205
+ {
3206
+ kind : 'BLOCK' ,
3207
+ type : 'niryo_one_grasp_with_tool'
3208
+ } ,
3209
+ {
3210
+ kind : 'BLOCK' ,
3211
+ type : 'niryo_one_release_with_tool'
3212
+ } ,
3078
3213
{
3079
3214
kind : 'BLOCK' ,
3080
3215
type : 'niryo_one_open_gripper'
@@ -3103,6 +3238,18 @@ const TOOLBOX = {
3103
3238
kind : 'BLOCK' ,
3104
3239
type : 'niryo_one_deactivate_electromagnet'
3105
3240
} ,
3241
+ {
3242
+ kind : 'BLOCK' ,
3243
+ type : 'niryo_one_set_tcp'
3244
+ } ,
3245
+ {
3246
+ kind : 'BLOCK' ,
3247
+ type : 'niryo_one_reset_tcp'
3248
+ } ,
3249
+ {
3250
+ kind : 'BLOCK' ,
3251
+ type : 'niryo_one_tool_reboot'
3252
+ } ,
3106
3253
{
3107
3254
kind : 'BLOCK' ,
3108
3255
type : 'niryo_one_wait'
0 commit comments