unitreerobotics / unitree_legged_sdk

SDK tools for control robots.
BSD 3-Clause "New" or "Revised" License
283 stars 156 forks source link

for Python 3.8 lib #46

Closed devemin closed 2 years ago

devemin commented 2 years ago

Dear Unitree

I tried the python commit, It works! (Python 3.7)

And I hope Could you add the ARM64 lib (.so) for Python 3.8 ? I need to use it with another host (Python3.8 / Ubuntu 20.04 / 64bit/ Raspi 4).

https://github.com/unitreerobotics/unitree_legged_sdk/tree/master/lib/python/arm64

Thanks :-)

TrivasZhang commented 2 years ago

Did this lib unsatisfy your need? Because this lib could work under raspbian buster, 64bit.

devemin commented 2 years ago

@TrivasZhang Thanks for you reply.

Maybe Is the lib file for python 3.7 ?

I think it can't use with python 3.8, right ? I try it with raspi4 (ubuntu20.04/64bit/python 3.8 ), but It appeared the import error.

cd ./build cmake .. make -j4 //change the source, "sys.path.append('../lib/python/arm64')"

export LD_LIBRARY_PATH=/path-to-unitree_legged_sdk/lib/cpp/arm64:$LD_LIBRARY_PATH python3 ../example_py/example_walk.py

ModuleNotFoundError: No module named 'robot_interface'

I need to use with python 3.8.

or, Should I install python 3.7 ?

devemin commented 2 years ago

fix

export LD_LIBRARY_PATH=/path-to-unitree_legged_sdk/lib/cpp/arm64:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH=../lib/cpp/arm64:$LD_LIBRARY_PATH

image

TrivasZhang commented 2 years ago

So could this 3.7 version lib works with python3.8? I know the 3.8 is more versatile, but the known issue is that many delivered robots are python 3.7.

devemin commented 2 years ago

No, It fix only the path string. I tried, but It didn't work with python 3.8 yet. (It showed as screenshot.)

If unitree can provide the lib for python 3.8, It is convenient. But If can't, I will try to add python 3.7.

Thank you, @TrivasZhang

TrivasZhang commented 2 years ago

I'll add 3.8.

TrivasZhang commented 2 years ago

fix

export LD_LIBRARY_PATH=/path-to-unitree_legged_sdk/lib/cpp/arm64:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH=../lib/cpp/arm64:$LD_LIBRARY_PATH

image

Did absolute path not work?

devemin commented 2 years ago

I did again with absolute path, but same result.

( Off course Go1's raspi can work with this.)

image

TrivasZhang commented 2 years ago

cd to example_py folder then python3 example_walk.py

devemin commented 2 years ago

Thanks @TrivasZhang image

same

I think because of module version.

TrivasZhang commented 2 years ago

Use sys.path.append('../lib/python/arm64') By the way, where did you find this raspi4 (ubuntu20.04/64bit/python 3.8 ) system image?

devemin commented 2 years ago

Use sys.path.append('../lib/python/arm64')

same result.

image

and I tried another way.


cd ../example_py
cp ../lib/python/arm64/robot_interface.cpython-37m-aarch64-linux-gnu.so ./
//change the source
import robot_interface as sdk

->

from . import robot_interface as sdk

then error message has changed.

ubuntu@rpi4ubuntu2004:~/unitreeSDKs/leggedSDK3.8/unitree_legged_sdk/example_py$ python3 ./example_walk.py 
Traceback (most recent call last):
  File "./example_walk.py", line 8, in <module>
    from . import robot_interface as sdk
ImportError: attempted relative import with no known parent package

I don't know about this meaning.

And about Ubuntu 20.04 system image:

I installed the raspi4 (Ubuntu20.04 /64bit/python3.8) with Ubuntu server image (It is CUI), and installed the GUI easy setting script. (the name is desktopify.)

git clone https://github.com/wimpysworld/desktopify.git cd desktopify sudo ./desktopify --de ubuntu

ref: (japanese, sorry) https://gihyo.jp/admin/serial/01/ubuntu-recipe/0624?page=2

devemin commented 2 years ago

Next, I try to rename the lib.

mv ./robot_interface.cpython-37m-aarch64-linux-gnu.so robot_interface.so

Then version mismatch log appeared.

import robot_interface Traceback (most recent call last): File "", line 1, in ImportError: Python version mismatch: module was compiled for Python 3.7, but the interpreter version is incompatible: 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0].

image

Thanks.

TrivasZhang commented 2 years ago

Please wait for the 3.8 version lib.

devemin commented 2 years ago

Dear TrivasZhang,

Thanks for helping me. I really appreciate it. I will wait for it.

devemin

TrivasZhang commented 2 years ago

I update the lib, could you try again?

devemin commented 2 years ago

Dear @TrivasZhang

Thanks for your quick action.

And It works great !!! I can move my dog with python 3.8 ! and No errors happened.

I appreciate your correspondence.

devemin

image

TrivasZhang commented 2 years ago

Good to hear that! If everything stable, I'll make a release.

devemin commented 2 years ago

I will use and test this for a week :-)

Dorianproject commented 1 year ago

Is there a python 3.10.6 solution for the: " No module named 'robot_interface' " problem ?

xyq1223 commented 1 year ago

Hello,we have provided the python_wrapper,please check and any version of Python (>3.0) can be used to control the robot dog (https://github.com/unitreerobotics/unitree_legged_sdk/tree/go1/python_wrapper)

ketulpanchal commented 8 months ago

Hello,we have provided the python_wrapper,please check and any version of Python (>3.0) can be used to control the robot dog (https://github.com/unitreerobotics/unitree_legged_sdk/tree/go1/python_wrapper)

Hi, I am using python3.10.12 and I am getting the same error saying "no module named robot_interface" Can I please know how to use python_wrapper to solve this error? Or do I need to use different version of Python