Can codes converted from blockly be used in VS code?

Hi there,

I am learning to use Blockly on [UFACTORY Studio simulation], finding that the codes written in Blockly (as shown in the picture) could be converted to Python in the IDE. What a nice feature!

Currently, I don’t have access to a real Xarm and I have a couple of questions:

  1. Can Python code generated in the IDE from Blockly be run directly in VS code?
  2. if the answer to 1 is yes, to run the codes generated in the Studio Simulation on a physical robot, would it be enough to change the IP written in the scripts (as shown in the picture) to match the
    one on the control box?

Thanks in advance!

Kind regards,
Lee

Hi Lee,

You can run the python code directly in VS code, and you have to install xarm-python-sdk in your environment first. The command is ‘pip install xarm-python-sdk’.

The IP generated in Studio is already the current controller’s IP.

Best regards,
Minna

Dear Minna,

Thanks for your quick reply. In my case, the same scripts can be run within the IDE integrated in Ufactory Simulation but it couldn’t be run in an external IDE, such as VS code. At the end of the script, it says,

raise Exception('connect socket failed')
Exception: connect socket failed

But I checked in Command, it shows that I have installed the according SDK,

and it’s been used in the scripts as well.

RobotMain.pprint('xArm-Python-SDK Version:{}'.format(version.__version__))
arm = XArmAPI('172.17.0.2', baud_checkset=False)
robot_main = RobotMain(arm)
robot_main.run()

Can you advise me on how to proceed with this matter?

Kind regards,
Lee

Hi Lee,

Can you ping the controller’s IP? Do you run it on the real arm?

  1. Download the friction file.
    dynconfig_XI130503D42AFF.yaml (868 Bytes)

  2. Upload the friction file to your docker container.

docker cp C:\pathtothefile\dynconfig_XI130503D42AFF.yaml  your_container_id:/home/uf/xArm

  1. Make sure you run the container with command
docker run -it --name uf_software -p 18333:18333 -p 502:502 -p 503:503 -p 504:504 -p 30000:30000 -p 30001:30001 -p 30002:30002 -p 30003:30003 danielwang123321/uf-ubuntu-docker
  1. Change the IP in the script to ‘127.0.0.1’ on your VScode

Dear Minna,

Thanks for your quick reply! Yes, I did run it on a real ram, and I could ping the controller’s IP back then, as I could run the same scripts on the arm with the IDE integrated in Ufactory.

Kind regards,
Lee

Dear Daniel,

Thanks for your instruction! If I understood correctly, I think this answer was explaining how to run codes on VS code to command the arm in the simulator?

However, I was trying to test if the codes converted from Blockly could be run on VS code too, even though it could run on the Python IDE of UFacotry, but not yet on VS code. Could I refer to this article (【Official】How to use xArm Python SDK---For Python beginners)? Even though it’s meant for PyCharm.

Regards,
Lee

Hi Lee,

Did you upload the friction file to your docker container?

Best regards,
Minna