Blockly support in SDK

Thank you Daniel,

So many messages were sent back and forth that I think
we are drifting away from the main point. :slight_smile:

If you could refer to the Oct 21 message to Minna that started
this current topic, you will see that:

  1. We can do everything we need with the Python SDK. In fact,
    we have done most of it already. The SDK is great, we are
    happy with it. We have 3 xArm robots and are satisfied with
    their performance.

  2. We would like to allow our operators to use Blockly instead
    of Python because many do not have Python programming knowledge.

  3. Our suggestion was making a simple Blockly that allowed arbitrary
    Python code to be called as a great solution. We would
    then create a “library” of these Blocklys as necessary and our
    operators would use these without having to learn Python.

As to your Modbus RTU Blockly, it might be useful to some of your
customers but not to us since the devices we use currently are
TCP/IP, serial and digital control line devices.

For example, we have a compressed air fluid dispenser that has a TCP/IP
interface where we can set pressure, etc by sending commands to
a certain port. Our robot places a syringe at a certain place, turns on
the displenser with a TCP/IP command, moves the syringe to apply a
type of adhesive resin to a part and then sends a command to turn it off.

We can do the whole thing in Python. No problem. We are trying to
do this in App Studio.

We envisioned creating a Blockly called “Set Pressure” and another
called “Enable Dispenser”, etc. Since you do not open source
App Studio, we suggested a generic Python Blockly so we do this ourselves.
Does this make more sense?

Thank you,

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

Hi Andre,
Thanks for your clarification, that’s clear.

Hi Daniel, has xArm Studio V1.9.0 Beta or any form been released yet? I found that Antonie and I although completely different companies are looking to do similar things whereby we would like to train the team using blockly but would like to be able to use some custom blocks. I’d also like to have the feature of sending the modbus data [xxxx xxxx xxxx xxxx] as all the other options i couldnt not achieve what i require.

Hi Edwin,
I’m sorry that we spend all the time on the Lite 6’s software development recently, I hope that we could get the Python function feature before December.

Hi Edwin,
We are developing it now, and estimate to get the beta version next week, I can share you the beta version if you want give a try.
Thanks

Hi Daniel

I recently got an xArm6 with me. I’m wondering if the blocky function with Python inside was finally implemented. I’m very new and I appreciate any help to get started with the xArm, any guides or courses or material with examples of each blocky function I can study.

Hi Fabian,
We are glad to help.
the Python Blockly feature is ready, please check the Firmware/Software version, make sure they are 2.4.0 or later, if not, please upgrade the firmware/software on the “Check Update” page


You can find the Python block here

Here is an example to create Python block

# python code
import time            
from xarm.wrapper import XArmAPI
arm=XArmAPI('192.168.1.58') #your controller ip
time.sleep(1)
ret=arm.get_position()
print("tcp_pos={}".format(ret[1]))
                                              

Please copy the code and paste on the Python block and run, like this

And if you could tell us more abour your project, it will be better for us to understand the situation.
Thanks

Hi Daniel,

Thanks for this clarification, I find it very useful. I am a teacher and I want to learn how to use this robot, but I also want to teach others how to use it. However, I see that the only way to work with the UFACTORY Studio GUI is by connecting to the physical robot. Is there another way I can share with my students to give them the option to study UFACTORY Studio and then be able to implement their programs on the real xArm when they access the physical robot?

Hi Fabian,
Thanks for your reply.
Yes, there is a way to get access to xarm 6 robot simulation without a real robotic arm, it requires a software named docker, it’s not easy to do that but I believe you will make it. Please follow the steps

  1. Download and install docker, docker website: Docker: Accelerated Container Application Development
  2. Download and install UFACTORY Studio docker image, here is the link and you will find the installation guidance inside: Docker - Google ドライブ
  3. If you follow the guidance, you will start the Lite 6 robot by default. if you want use the the xArm 6 simulation, the command to start the ufactory studio server is
/xarm_scripts/xarm_start.sh 6 9

If every thing goes well, you will find the serve IP address here when you click the search server button on this page.

Let me know if you have any questions during the installation.

Hi Daniel,

Thanks for your instructions.

I followed all the steps and at the end I get the following message when I enter the command /xarm_scripts/xarm_start.sh 6 9:

root@5acc8c51e24d:~# /xarm_scripts/xarm_start.sh 6 9
No Sockets found in /run/screen/S-root.
There is one screen on:
4774.xarm_controller_screen (08/01/24 10:30:10) (Detached)
1 Socket in /run/screen/S-root.

And here I don’t know what to do, because I try to connect to the UFACTORY Studio search server option but I don’t get any IP address:

I verify the IP address in the Inspect tab of the Docker Desktop

But when I try to connect:

Update1: I am not sure but I think the problem is related to Ports no exposed when I try to Run a new container with Ubuntu image
image

When I see the Inspect tab of Docker Desktop:

Then I created a new Container but maping several ports: 18335, 502, 503, 30001, 30002, 30003, 30004, 30009, 30010, 29999:

However, the result was the same, it does not appears to connect

Update2: I created a new Container maping an additonal port: 18333

This time I use the next address directly in the web browser:
http://localhost:18333/
or
http://127.0.0.1:18333/

and then, voila! It works

However, it is an old version.

Update3: Inside Docker - Google ドライブ there is a file to update to the last version: docker_sim_update_V2.4.0.zip

I followed all steps successfully, but when I enter the last line of code /home/uf/.UFACTORY/xarm/software/python/bin/python3 setup.py install

Then appears the next error:

Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = ‘/home/uf/.UFACTORY/xarm/software/python/bin/python3’
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = ‘/home/uf/.UFACTORY/xarm/software/python/bin/python3’
sys.base_prefix = ‘/usr’
sys.base_exec_prefix = ‘/usr’
sys.platlibdir = ‘lib’
sys.executable = ‘/home/uf/.UFACTORY/xarm/software/python/bin/python3’
sys.prefix = ‘/usr’
sys.exec_prefix = ‘/usr’
sys.path = [
‘/usr/lib/python310.zip’,
‘/usr/lib/python3.10’,
‘/usr/lib/lib-dynload’,
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named ‘encodings’
Current thread 0x00007f19db896080 (most recent call first):
no Python frame

Despite this, I restarted the application using again the code /xarm_scripts/xarm_start.sh 6 9:


But it does not work properly, continuously appears an error of collision with any movement.

Hi Fabian,
Seems it needs a file folder for the robot firmware to copy the collision models, please execute this command and then restart the application
sudo mkdir -p /usr/local/lib64
Please give a try and let us know the result.
Thanks

Hi Daniel,

Now the robot works fine, it can moves without the self collision error. Thanks!
However, when I try to enter to the Blocky option, it does not load:

I assume that it is due to the last part of the update process, after the next code:
/home/uf/.UFACTORY/xarm/software/python/bin/python3 setup.py install

it showed:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/home/uf/.UFACTORY/xarm/software/python/bin/python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/home/uf/.UFACTORY/xarm/software/python/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.platlibdir = 'lib'
  sys.executable = '/home/uf/.UFACTORY/xarm/software/python/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python310.zip',
    '/usr/lib/python3.10',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f4722f35080 (most recent call first):
  <no Python frame>

The following is what appears inside my '/usr/lib/'

Hi Fabian,
We are sorry for that, it’s a bug and we fix it, a file named xarmcore should be replaced to solve this issue, here is the steps:

  1. Download the xarmcore from the google driver: Docker - Google ドライブ
  2. Find and delete the xarmcore in the file folder of docker image:~/.UFACTORY/xarm/software/xarmcore
  3. Upload the xarmcore you just download to that file folder docker image.
  4. Restart the docker image.
  5. Start the software, the commands are the same as before:
    /xarm_scripts/xarm_start.sh 6 9

Hi Daniel,

I replaced the xarmcore file as you said but the Blocky programing option still doesn’t work. I used the same Docker container from the last attempt, maybe I need to create a new one? Do I need to repeat everything again from scratch but without using the code
/home/uf/.UFACTORY/xarm/software/python/bin/python3 setup.py install?

Sorry but I’m not sure what to do and in what order.

Thanks

Update: I made a mistake by removing and replacing the xarmcore file. It works fine now!

Thanks!

Just to resume:

The next are the steps I used to update from simulator version 1.12.4 to version 2.4.0

  1. attach the files of version 2.4.0 to docker container (in my case to /root), and run command in docker container
       tar -xf xarmcontroller-x86_64-*.tar.gz
       tar -xf xarmstudio-x86_64-*.tar.gz --wildcards linux/xarm.tar.gz && tar -xf linux/xarm.tar.gz -C ./ && rm -rf linux
       sudo cp -rf xarmcontroller/* /home/uf/xArm/
       sudo cp -rf xarm/* /home/uf/.UFACTORY/xarm/
       sudo mkdir -p /usr/local/lib64
  1. restart docker container

  2. find and delete the xarmcore in the file folder of docker container: /home/uf/.UFACTORY/xarm/software/xarmcore

       sudo rm -rf /home/uf/.UFACTORY/xarm/software/xarmcore/xarmcore
    
  3. copy the new xarmcore to that file folder docker container

       sudo cp -rf /root/xarmcore /home/uf/.UFACTORY/xarm/software/xarmcore/
    
  4. restart the docker container

  5. start the software, the commands are the same as before:

       /xarm_scripts/xarm_start.sh 6 6
    


In case of simulating another robot I found the following sequence of numbers to the code:
/xarm_scripts/xarm_start.sh 6 9

  • 5 5 → xarm5
    6 6 → xarm6
    6 9 → LITE6
    6 12 → 850?
    7 7 → xarm7

Hi Farbian,
I’m very glad that you make it work. The type&model - product you listed is correct.

5 5, xArm 5
6 6, xArm 6
7 7, xArm 7
6 9, Lite 6
6 12, 850

And thanks very much for you detailed feedback, what we are going to do is to make the installation of the simulation easier by building new image, or put the image to the docker hub.

Thanks

@Fabian_Leon
Hi Fabian,
We create a new docker image and push to the docker hub, it will be much easier to install, please check.

UFACTORY Studio simulation - General Discussion - UFACTORY Forum

1 Like