Getting x, y, z, r coordinates at a given timepoint on MG400 using python


Hi experts.
Im developing a python script for the Dobot MG 400. I would like to do some sort of calibration, and in order to do so, i need the coordinates of the robot at a given timepoint.
I dont need to have them updated live, just what they are when i request it from the robot.

Can you help me out in how that can be achieved?

Best, Anders


Hey Anders,

Add this to your api:

def GetPose(self):
    Get position of the robot in XYZR
    string = "GetPose()"
    return self.wait_reply()

This will give you the pose (with a big delay) when you call it.

Otherwise this example gives you instantaneous update:

def get_feed(feed: DobotApi):
    global current_actual
    hasRead = 0
    while True:
        data = bytes()
        while hasRead < 1440:
            temp = feed.socket_dobot.recv(1440 - hasRead)
            if len(temp) > 0:
                hasRead += len(temp)
                data += temp
        hasRead = 0

        a = np.frombuffer(data, dtype=MyType)
        if hex((a['test_value'][0])) == '0x123456789abcdef':

            # Refresh Properties
            current_actual = a["tool_vector_actual"][0]
            #print("tool_vector_actual:", current_actual)



After the latest update I have just checked and “GetPose()” is instantaneous/live.


Let me join this conversation with a problem regarding the GetPos() answer. I’m using the ModBUS communication (from Siemens S7-1214). While the comm works, I’m getting confusing answers from robot after GetPos command. The pic shows the position request from PLC (the rPosX_REQ - rRotation_REQ) and what the robot sends me as feedback to the GetPos command (rPosX_ACK - rRotation_ACK). I’m sending the values from Dobot as F32 type registers (4-byte long variable each). The ACK values are almost always distorted as visible in the pic.
What am I doing wrong? Is it a matter of data formatting before I set the registers in the Dobot?


I’m adding something new to the topics. The picture shows the robot position feedback from Dobot Studio (right) and Siemens S7-12xx datablock where the robot saves the information about itsactual position. As you can see, the data differs, in some cases quite a lot.
In the robot Lua script I’m using the command Sync() after all movements are finished and then I fill the modbus register in PLC with data. Do I do something wrong? How can I get the same data result like the Dobot Studio shows?


We have been having a heck of a time with calibration on the MG-400. We have a process that involves the Dobot slotting a part into a few multi-position rack. It has been impossible for us to move through all of the positions without tripping a collision (I don’t want to damage the fixtures that we have built, otherwise we would turn off detection). It seems like any collision throws the alignment off such that when we send it to “Home” the joints are no longer square. I don’t think we have ever squared it well enough to get to within a few millimeters of the pre-collision alignment.

This became such an issue that I build a homing block with three orthogonal switches to try to capture a reference position. I squared the joints, zeroed the axes in DobotStudio, and used the switches to capture the joint angles one at a time. After a collision I tried to measure the angles of the reference switches again and use the difference to reset the zero point, but it only made the misalignment worse.