Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Get the position of the real robot using the API

#1
Hi everyone,

I'm trying to write a Python script in RoboDK to replicate the Get Position button, which updates the robot's position from the real robot (Yaskawa Motoman AR1440).

The button in the GUI works perfectly — it retrieves and updates the real robot's joint values. However, none of the Python commands I’ve tried (such as robot.Update(), or robot.Joints() ) seem to get the actual robot position — they just return the simulated one.

The robot is connected (status shows "Ready"), but I can't find the exact command that triggers the same action as the button.

Any idea how to achieve this in Python?

Thanks in advance!


Attached Files
.png   Capture d’écran 2025-06-26 171628.png (Size: 18.32 KB / Downloads: 11)
#2
You can achieve the same effect as using the Get Position of the robot panel by calling robot.Joints(). However, you should make sure you are properly connected to the real robot in your script so that the commands are run on the real robot.

You can use a script like this one:
Code:
success = robot.ConnectSafe() # Try to connect multiple times, or use Connect() instead
status, status_msg = robot.ConnectedState()
if status != ROBOTCOM_READY:
    raise Exception("Failed to connect: " + status_msg)

# Use the driver for robot commands: this is done automatically if you called Connect or ConnectSafe already
# RDK.setRunMode(RUNMODE_RUN_ROBOT)

# Retrieve robot joints from the real robot and update it in RoboDK:
joints = robot.Joints()
#3
I’m experiencing a similar issue. Indeed, after connecting to the robot, I can retrieve each joint’s data using robot.Joints(), and the values match between RoboDK and the actual robot.
However, when I use robot.Pose() to get the current TCP (Tool Center Point) position, the values are slightly different between RoboDK and the real robot.
Is there a way to retrieve the actual TCP position from the real robot?
Note: The tool coordinates and user coordinates are entered identically in both RoboDK and the actual robot.
#4
Good question. The answer is that Joints will force pulling the latest position from the real robot. However, calling Pose() will take the pose from the simulated robot.

To take the pose of the current robot you can call Joints first and Pose right after. Example:
Code:
# Take the real joints from the real robot and update the simulated robot:
real_joints = robot.Joints()

# Take the simulated robot pose (updated from the real robot if you called Joints first)
real_pose = robot.Pose()
There is also another function that can be of help: if you are connected to a robot and you need the joints from the simulated robot (not the real robot), you can call SimulatorJoints().
#5
Thank you for your reply. I tried the method you suggested, but the values did not change. I’ve attached the results of the implementation. Is there another method we could try? The robot I’m using is the CRX-10iA.


Attached Files
.pdf   Robodk-Realrobot.pdf (Size: 692.45 KB / Downloads: 8)
#6
The robot TCP is not pulled from the controller, however, you can set it by calling setPoseTool. This will update the Tool pose form your robot in RoboDK to the real robot controller when you are connected with the driver.
#7
Dear Albert

Thank you for your message.

I understand that robot's TCP can not be automatically retrieved from the controller.
I appreciate you letting me of know.

Best regards,
Tyler
  




Users browsing this thread:
1 Guest(s)