Blockly support in SDK

While browsing through the latest versions of the SDK, I noticed there is significant new support for Blockly in the xarm/tools directory. This is of interest to us because we would like to extend Blockly features to better serve our needs, if possible.

  1. What is the purpose of the code in that directory? What can we do with it? The example seems to read a blockly xml file and convert to it python, but since this can be done through XArm studio directly, I’m wondering why it is in the SDK. Is it there so we can add our own blocks by hacking the code somehow?

  2. Do you have an example where a custom block can be created, installed, and used to generate custom code? Using xarm studio of course.

This is important to us because Blockly is easy for our robot operators but we would need to create some custom code to send TCP/IP messages to other equipment. From a custom block.

If we can’t create a custom block, we’d have to abandon Blockly completely which then means we’d have to train operators in python which we would much rather avoid.

Thanks for your help! BTW, We have 2 xarms (so far), a 6 and a 7 and have been using them weekly for years with great results. I’m impressed with the quality and the rate at which the SDK has been adding fearures! Excellent work!

André Sant’Anna
Director, R&D
Applied Anodize, Inc.

Hi André,

1, You are right, it will read Blockly file and convert it to python automatically, users can do secondary python development based on the generated code to adapt to more scenarios.

2, Sorry, it doesn’t support adding a custom block. There are so many usage scenarios so that it is difficult to implement only in Blockly without any development. And it may be difficult for us to manage xArmStudio if we open this function.
Blockly allows you to define a function/method using the existing Blockly block.

Anyway, I think it might be more appropriate for us to add blocks for you. You can detail your needs, and then we can make an evaluation if we can add something.

Best regards,
Minna

Hi Minna,

Thanks for the quick reply!

I think that a block that would extremely useful to us (and also to many of your customers) is a simple variation of the function block you already have.

The new block might be called “Python Function” and it might work like this:

  1. When you create the function in studio, you can pick “Create Python Function” for example.
  2. What happens next is you get a block very similar to the normal function block. I.e. it asks you the name and creates a block. ​Like the normal function block, you have fields for function name and the flyout for function parameters - no change so far.
  3. The difference is that this new block does not accept docking with blockly commands - instead it has a single blockly “multi-line field” in which the user can type python code. Something like this:

image

  1. When blockly generates the code for this block, the block’s python code would get inserted “as-is” into a function in a way very like what it does with normal functions now. In other words, the code generated might be something like this:

    #Define Mydef class
    class MyDef(object):
         def __init__(self, *args, **kwargs):
             pass
    
         @classmethod
         def function_1(cls, r):
             # NOTE: code below was provided by the user through
             # a Python function block
             
             # calculate area of circle
             area = math.pi * r * r
             return area
    
             # End of user code
    

That’s it! Or something similar.

What’s great about this for us is that we can create a “library” of small Blockly functions in Python to do things that XArm Studio does not currently support and our operators can just use those Blockly functions without having to learn Python.

You should probably stress that this block is for advanced users only – code is inserted into the Python file “as is”. It is up to the user to make sure they don’t “break” anything.

Thank you for considering my request! I think this block can benefit many users!

Andre Sant’Anna
Director, R&D
Applied Anodize, Inc.

PS If you go ahead and do something like this, it occurred to me that XArm studio does not appear to be able to create “string” values so they can be passed to functions. This should be very easy to implement and would be necessary to make this “Python Function” block fully useful.

1 Like

Hi Andre,
Thanks very much for the explanation, it’s very clear. It’s a good idea and we think it will expand the use of the Blockly, we did add that to our requirement list and will evaluate in the next version of requirements review meeting.
Thanks Andre

Thanks for taking this under consideration!

André

Hi Daniel,

Any news on the Python function feature? Was it accepted as a requirement?
Any idea on release date if so?

Thanks,

  • Andre

Hi Andre,
Sorry for the late reply, we did discuss it and we add it to our to do list. We are thinking about create a beta version for you after we release the V1.9.0, it should be done by Feb or Mar of 2022.
I will let you know by Email, could you please copy this link and Email to me daniel.wang@ufactory.cc
Thanks

Hi dear Daniel and UFactory team,

Is this new block still planned to be added to the next release?
I am in the same situation as Andre, where the persons in charge of teaching the robot are pretty much not Pything savvy at all, hence keeping it all in Blockly with pre-programmed blocks for a few “advanced” actions would be perfect.

Hi Antoine,

Is this new block still planned to be added to the next release?
Yes.
We are still on the developing of the xArm Studio V1.9.0, we will start the development of that feature after we realese the V1.9.0 in around 2 weeks.
Please send me an Email so I can share you the beta version then, daniel.wang@ufactory.cc

Thanks

Hi Antoine,
Is this new block still planned to be added to the next release?
Yes.
We are still on the developing of the xArm Studio V1.9.0, we will start the development of that feature after we realese the V1.9.0 in around 2 weeks.
Please send me an Email so I can share you the beta version then, daniel.wang@ufactory.cc

Thanks

Hi Daniel,

Any news on the development of the Python function block?

Thanks

Hi,
After evaluation, we found the development of that function is more complicate than we thought, so we have to put forward it, we hope it would come out after we release the V 1.10.0 this month.
Thanks

Thank you for the update.

Hi Daniel,

Any news on the Blockly support described above? We’ve been waiting since October 2021 !
Is this still in your timeline? If so, when can we expect it?

We have added new hardware to our project counting on this feature to communicate
with it, now our development is halted … :frowning:

Please help,

Andre Sant’Anna
Director, R&D
Applied Anodize, Inc.

Hi Andre,
Sorry for the late reply.
May I know more details of your project, what’s the communication method and protocol of the “new hardware”.
I’m thinking about another way like adding a Block like “send modbus data[xxxx xxxx xxxx xxxx]”

Are you still going to provide the Python Block?
That would be ideal because we have a lot of devices
we may need to communicate with.

We were going to write non-blocking functions for
both serial and TCP/IP at least. We really can’t
predict what we will ultimately need which was why
a generic Python block is so attractive.

Could you give me an idea of why this feature is
more complicated than you thought originally
(see May 5 message above) ?

Thank you for your attention,

Andre Sant’Anna
Applied Anodize, Inc

Hi Andre,
If the devices you mentioned should be connected to the robot end flange and controlled by commands through the robot end tool connector, the devices should support standard Modbus RUT commands.
If the devices you mentioned are controlled by your PC directly through TCP/IP or serial, that’s another thing.

May I know where are you based? Maybe we can have a 30mins video call to discuss it?

Thanks

That would be great. We have a variety of devices
we need to communicate with - we can go into all
the details in the call.

I’m located in San Jose, California. Please let me know
what hours work for you.

Thanks,

Will you still be providing the Python Block?

I did not receive a response to this question
and this response is important to us.

Thanks

Hi Andre,
We are on the assessment of the Studio V2.0.0, we should figure out what you need before we build it.

  1. Assume your device need to be connected to the robot end flange and controlled by commands through the robot end tool connector.
    1.1 If your devices support standard Modbus RTU, then we provide a new Blockly like “send modbus data[xxxx]” can solve that problem.
    1.2 If your devices does not support Modbus RTU, then it will be complicate. Actually, on this condition, provide Pyhon Blockly does not make sense, we should develop the transparent transmission protocol for the robot, and it’s a big project since we need modify not only the xarm studio but also the robot firmwar and drivers, it’s much more complicate than support Modbus RTU device.
  2. Assume your devices are connected to your PC by Ethernet or USB, and your divices are control by your PC directly, on this condition, if you could do that by Python and provide us one or more Python example, that will be quite helpful for us to understand your situation.

Hope you could reply by Email, my work email is daniel.wang@ufactory.cc

Thanks