First off, this post is not a question but a documentation to overcome various undocumented and unfixed issues. I run into the following two issues which are related:
Issue 1
Issue 2
Objective: Writing a python application to control the Dobot Magician robot on Linux 64bit
Issues: Dobot DLL causes seg faults for all Set*() function calls
### Prerequisites ###
Ubuntu 22.04 LTS
Dobot Magician
Python3 and Python2 tested
### Compiling Dobot DLL from Source ###
Obtain the source files from the Dobot Download Centre. Once logged in, please download the Dobot Demo v2.3 file. Untar it and copy the magiciandll-master.zip to your Linux machine under /usr/local/src/.
Next, install various packages you will require to compile from source:
apt install -y build-essential \
libxcomposite-dev \
libxcb-glx0-dev \
libx11-xcb-dev \
libxrender-dev \
libxkbcommon-x11-dev \
libfontconfig-dev \
libwayland-cursor0 \
libgl-dev \
unzip
Next, install QT. Note, the QT installer will pop up a window where you go through a couple of steps. Either connect a display to your Linux machine or use x-forwarding when SSHing into the machine (ssh -x):
cd /usr/local/src/
wget https://download.qt.io/archive/qt/5.12/5.12.11/qt-opensource-linux-x64-5.12.11.run
chmod +x qt-opensource-linux-x64-5.12.11.run
./qt-opensource-linux-x64-5.12.11.run
Once QT is installed, compile and install the DLL
/usr/local/src/# unzip magiciandll-master.zip
/usr/local/src/magiciandll-master# /opt/Qt5.12.11/5.12.11/gcc_64/bin/qmake
/usr/local/src/magiciandll-master# make
/usr/local/src/magiciandll-master# make install
Now update your system to include the newly compiled libraries. I chose to add the following to my ~/.bashrc
export DOBOT_LIB_PATH=/usr/DobotDllOutput
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DOBOT_LIB_PATH
### Patch Python DLL Wrapper ###
The Dobot Demo 2.3 RAR file includes an example for Python. Unzip the demo-magician-python-64-master.zip and find the DobotDllType.py file which is imported in your python code via
import DobotDllType as dType
The DobotDllType.py requires a patch which I uploaded to pastebin.com. Download the patch, save it as dobot.patch in the same folder as the DobotDllType.py and apply it via:
patch -u DobotDllType.py -i dobot.patch
Enjoy controlling your Dobot Magician on Linux!
PS: If the Dobot support team reads this post, please update your documentation on how to compile it from source on Linux and please patch your python ctypes wrapper. Note, under python2, the Chinese characters in the .py cannot be parsed by the python compiler, as it expects ASCI-compliant characters. Thus, I had to remove them.