Segmentation fault when connecting to Dobot Magician using python on Ubuntu 18.04


#1

I’m trying to use Python to connect to the dobot Magician on my Ubuntu 18.04 system. I got the libDobotDll.so file from the website. I am able to detect the Dobot on ttyUSB0 using the SearchDobot function, but using ConnectDobot results in a Segmentation fault. Any help would be greatly appreciated. I have also tried recompiling the shared library with qt, using the source code provided in the the Dobot Demo v2.1, but I still have the seg fault.


#2

Got the same problem when using the library v2.1 with python on ubuntu 18.04 and my raspberry pi.


#3

I went through tons of version of the shared library, some precompiled and some that I compiled myself. I kept having the same problem. But I think I have the issue narrowed down, as well as a fix that I do not guarantee the reliability of.

The big problem is DobotDllType.py. I referred to the function signatures in the DobotDll.h file, and modified the corresponding functions in DobotDllType.py

The first change you need to make is in connectDobot. You need to pass a versionBuf to the api.ConnectDobot() function. Aside from that, just get rid of the master_id and slave_id being passed to basically every api function call, and it should start working normally. This worked for me, and I could get a demo as well as some of my own code running on the Dobot.

Note that making these changes on Windows might cause your program to crash. My guess is that the Windows dll file and the Linux .so files were compiled form different sources and DobotDllType was written for the windows shared library. Hope this helps.


[SOLVED] Segmentation fault in libDobotDll.so.1.0.0 under linux
Python-Based Dobot Magician Control on Linux
#4

Thanks @rbhirang, your solution worked for me. One extra thing I had to do was to alter DevType.Magician enum value to match one in ConnectInfo filled by ConnectDobot function.

If that would be helpful for someone…
Solved by compiling fresh libDobotDll.so from sources provided in Dobot Demo V2.3-en.rar under magiciandll-master sub archive. It can be downloaded from Dobot Download Center, look for Magician Development protocol. And altered DobotDllType.py according to instructions above.


#5

thanks for the awesome information.


#6

Hello,

i have a quite similar problem with my Dobot. I’m using Ubuntu20.04 and tried ROS. It worked kind of, but wasn’t easy to use and I didn’t get any feedback from the robot, like alarms and so on. Then I tried the cri_dobot library. The dobot connects fine, but i get a segfault on every command i want to run. As I’m not a programmer, I don’t know what exactly I have to change in the DobotTypeDll.py file. Could someone upload the correct file or a detailed manual what to change? Or are there any other ideas, what could help me?

api = dType.load()
dType.ConnectDobot(api, “”, 115200)
dType.GetPose(api) #Here comes the segfault error


#7

Hello,

I had the same problem as Sven, but I solved it.
If anyone encounters the same situation, please refer to it.
Edit “DobotDllType.py” file, and just delete parameter.

def GetPose(api):
    pose = Pose()
    while(True):
        #result = api.GetPose(c_int(masterId), c_int(slaveId), byref(pose))
        result = api.GetPose(byref(pose))
        if result != DobotCommunicate.DobotCommunicate_NoError:
            dSleep(5)
            continue
        break
    return [pose.x, pose.y, pose.z,pose.rHead, pose.joint1Angle, pose.joint2Angle, pose.joint3Angle, pose.joint4Angle]

#8

thanks my issue has been fixed.


#9

@rbhirang Could you please share how you modify the DobotDllType.py file? After having communication with the Robot, I can control it with HEX commands through the serial port directly, not using DobotControl.py. I have spent a lot of time figuring out what is going on with drivers in Ubuntu 22.04.3 and it seems a nightmare. Technical support of Dobot did not answer. I can see Segmentation Fault error if I run DobotControl.py with sudo, without sudo I can see that Dobot is occupied. I have been aware that the port is available. Could you please share specifically which changes (with a code example) we made in DobotDllType?

Appreciate your help on that.


#10

@rbhirang Could you please share how you modify the DobotDllType.py file? After having communication with the Robot, I can control it with HEX commands through the serial port directly, not using DobotControl.py. I have spent a lot of time figuring out what is going on with drivers in Ubuntu 22.04.3 and it seems a nightmare. Technical support of Dobot did not answer. I can see Segmentation Fault error if I run DobotControl.py with sudo, without sudo I can see that Dobot is occupied. I have been aware that the port is available. Could you please share specifically which changes (with a code example) we made in DobotDllType?

Appreciate your help on that.