Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RDK calculate a TCP speed on a running robot
How would it be possible, ie is there anything in robodk already that can calculate the TCP speed of a running robot.

From the live robot I can feed into RDK an updated joint position every 4ms (i can possibly even get it down to 1ms but that's an expensive Kuka tech pack and probably overkill), what I would like to do is have rdk tell me what the robots TCP speed is so I can modulate a speed for an extruder independent of the acceleration and deceleration of robot joints or override speed setting on the robot etc


Hi Collin,

That's a good question.

First, I think that even 4 ms is a bit overkill, I don't see how the extruder could modify the flow fast enough to get even close to that refresh rate, but that's not the point.

What I think I would try is to have RoboDK calculate the actual position of the TCP from the set of joint and TCP measurements using the SolveFK (robolink module) function of the API.
You can then use the Distance (robodk module) function to calculate the distance between the previous point and the actual point.
If the data is coming in at a steady rate you can extrapolate the actual speed of the TCP.

Where I'm unsure is if Python is fast enough to deal with that kind of process.
@Albert any thoughts?

Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our Youtube Channel

Hi Colin,

A Python script like the one attached should allow you to monitor the robot every 4 ms if you don't need to do any calculations.

On the other hand, the default RoboDK driver monitors the robot every 20 ms or so (based on the KUKAVARPROXY).


Attached Files
.py (Size: 1.42 KB / Downloads: 14)
.py (Size: 1.48 KB / Downloads: 12)

this is what im working with to get the data in from the robot, again it doesn't overly matter if the reading of the file isnt as fast as that, as jeremy rightly said, an extruder wont react that fast, or indeed even be that accurate in terms of flow rates anyway

the RSi module does give that speed of data through put, its just how best to take that information and translate it into a usable extruder speed,
This RSI server project looks very good. We can help you integrate it. @Phillip, do you think you can help Colin?

For the time being, if you need to calculate the speed of the TCP in real time I would do something like this based on the real time monitoring example I sent in the previous post:

# Infinite loop to calculate speed
while True:
    # If we are connected, this retrieves the position of the real robot
    # (blocks until it receives an update from the real robot)
    joints = robot.Joints().list()
    if joints_changed(joints, joints_last):
        # Get the TCP with respect to the coordinate system
        # (the robot position was just updated from the real robot using Joints())
        tcp_xyz = robot.Pose().Pos() 
        t = time.time()
        if t_last is not None: # Skip the first update            
            # Calculate delta time (s) and delta travel (mm)
            d_time = t - t_last
            # d_time = d_time * RDK.SimulationSpeed() # adjust for real time when simulating
            d_move = norm(subs3(tcp_xyz, tcp_xyz_last))
            if d_time > 0:
                speed = d_move / d_time
                print("TCP speed (mm/s): %.1f" % speed)
        joints_last = joints
        tcp_xyz_last = tcp_xyz
        t_last = t

Attached Files
.py (Size: 2.21 KB / Downloads: 14)

Users browsing this thread:
1 Guest(s)