Thank you for your reply.
I took a look at the pixi_ur_ros2 implementation and went through the controller code. For now, however, I am mainly focusing on a URScript-based approach where I stream joint position targets and use the direct torque control interface to track them.
My current implementation is a simple joint-space PD controller:
tau[j] = Kp[j] * (q_ref[j] - q[j]) - Kd[j] * qd[j]
I am not using a mass matrix, Coriolis compensation, or explicit gravity compensation since direct_torque() already performs gravity compensation internally.
I have also tested a fairly large range of gains. For joints J1-J6, I have experimented with Kp values roughly between 700 and 1500, but I consistently run into the same trade-off:
-
If I increase gains to reduce oscillations and tracking error, the robot starts producing noticeable humming/noise and appears to be under higher motor load.
-
If I reduce gains to avoid the humming and make the motion smoother, the tracking error increases significantly, sometimes growing from sub-degree levels to several degrees.
I also tested your gain set:
Kp = [900, 900, 1100, 70, 50, 1] with damping computed from the critical damping formula (ζ = 1).
One thing I was curious about: is there a specific reason you chose Kp = 1 for Wrist 3 (J6)? In my experiments, such a low gain on J6 results in very large tracking errors for that joint.
The bigger challenge is when I run actual VLA / diffusion-policy rollouts. ServoJ performs very well and the robot almost always completes the task successfully. With direct torque control, however, I typically observe gradual drift after the initial steps. The accumulated tracking error eventually causes task failure, even though the commanded trajectory itself is reasonable.
I also experimented with the pixi_ur_ros2 setup. While it works, I still found that Kp/Kv tuning is critical.
I think someone from the UR team or the community may be able to provide better guidance on tuning gains for the new direct_torque() API. Since gravity compensation and other low-level dynamics are handled internally by the UR controller, there may be a more effective tuning approach. My main challenge is to make long-horizon learning-based policies execute reliably.
Thank you!
there my 20 waypoint tracking logs , sorry for being too long.
`Waypoints: 20
Trajectory: 5693 steps (113.9s at 50Hz)
Max step: 0.05 deg/joint
Settle time: 1.0s per waypoint
Controllers to test: [‘1’, ‘2’, ‘servoj’]
Total time: ~5.7 min
======================================================================
TESTING: C1
Uploading URScript (4345 bytes)…
┌─ UR Official PD + Alpha @500Hz ─────────────────┐
│ MODE: POSITION (absolute joint targets) │
│ q_smooth += alpha*(q_target - q_smooth) │
│ tau = Kp*(q_smooth - q) - Kd*qd │
│ tau = clamp(tau, max_torque) │
│ Kp = [1500.0, 1500.0, 1000.0, 2000.0, 1000.0, 1000.0]
│ Kd = [77.5, 115.6, 86.7, 72.1, 51.0, 56.6]
│ max_torque = [150.0, 150.0, 150.0, 28.0, 28.0, 28.0]
│ alpha = 1.0 | coriolis=0 | M(q)=0
│ max_delta_tau = 0.5
│ max_speed = 1.5 rad/s (86 deg/s)
└─────────────────────────────────────────────────┘
Running 5693 steps (113.9s at 50Hz)…
step 250/5693 (5.0s) max=0.180° | J0=0.076 J1=0.000 J2=0.082 J3=0.049 J4=0.058 J5=0.180
step 500/5693 (10.0s) max=0.209° | J0=0.209 J1=0.097 J2=0.106 J3=0.057 J4=0.080 J5=0.175
step 750/5693 (15.0s) max=0.181° | J0=0.119 J1=0.027 J2=0.059 J3=0.052 J4=0.089 J5=0.181
step 1000/5693 (20.0s) max=0.177° | J0=0.042 J1=0.139 J2=0.086 J3=0.056 J4=0.060 J5=0.177
step 1250/5693 (25.0s) max=0.183° | J0=0.143 J1=0.095 J2=0.103 J3=0.062 J4=0.051 J5=0.183
step 1500/5693 (30.0s) max=0.130° | J0=0.028 J1=0.130 J2=0.026 J3=0.020 J4=0.043 J5=0.021
step 1750/5693 (35.0s) max=0.042° | J0=0.006 J1=0.006 J2=0.030 J3=0.042 J4=0.011 J5=0.022
step 2000/5693 (40.0s) max=0.265° | J0=0.265 J1=0.106 J2=0.164 J3=0.044 J4=0.020 J5=0.019
step 2250/5693 (45.0s) max=0.300° | J0=0.055 J1=0.234 J2=0.300 J3=0.125 J4=0.026 J5=0.019
step 2500/5693 (50.0s) max=0.119° | J0=0.030 J1=0.077 J2=0.119 J3=0.020 J4=0.060 J5=0.018
step 2750/5693 (55.0s) max=0.219° | J0=0.015 J1=0.009 J2=0.219 J3=0.023 J4=0.085 J5=0.019
step 3000/5693 (60.0s) max=0.262° | J0=0.262 J1=0.024 J2=0.212 J3=0.023 J4=0.026 J5=0.018
step 3250/5693 (65.0s) max=0.246° | J0=0.246 J1=0.073 J2=0.192 J3=0.009 J4=0.027 J5=0.020
step 3500/5693 (70.0s) max=0.068° | J0=0.036 J1=0.068 J2=0.065 J3=0.014 J4=0.059 J5=0.022
step 3750/5693 (75.0s) max=0.172° | J0=0.172 J1=0.150 J2=0.080 J3=0.018 J4=0.169 J5=0.023
step 4000/5693 (80.0s) max=0.309° | J0=0.309 J1=0.205 J2=0.285 J3=0.131 J4=0.025 J5=0.020
step 4250/5693 (85.0s) max=0.250° | J0=0.250 J1=0.056 J2=0.060 J3=0.014 J4=0.024 J5=0.022
step 4500/5693 (90.0s) max=0.181° | J0=0.071 J1=0.126 J2=0.151 J3=0.079 J4=0.074 J5=0.181
step 4750/5693 (95.0s) max=0.183° | J0=0.110 J1=0.064 J2=0.165 J3=0.078 J4=0.048 J5=0.183
step 5000/5693 (100.0s) max=0.324° | J0=0.107 J1=0.120 J2=0.324 J3=0.075 J4=0.093 J5=0.178
step 5250/5693 (105.0s) max=0.180° | J0=0.098 J1=0.104 J2=0.134 J3=0.079 J4=0.052 J5=0.180
step 5500/5693 (110.0s) max=0.186° | J0=0.109 J1=0.044 J2=0.115 J3=0.086 J4=0.042 J5=0.186
======================================================================
TESTING: C2
Uploading URScript (4336 bytes)…
┌─ UR Official PD + A@500Hz ─────────────────┐
│ MODE: POSITION (absolute joint targets) │
│ q_smooth += alpha*(q_target - q_smooth) │
│ tau = Kp*(q_smooth - q) - Kd*qd │
│ tau = clamp(tau, max_torque) │
│ Kp = [900.0, 900.0, 1100.0, 70.0, 50.0, 1.0]
│ Kd = [72.0, 107.51892856609017, 109.1406432086599, 16.18888507587845, 13.682105101189654,
2.146625258399798]
│ max_torque = [150.0, 150.0, 150.0, 28.0, 28.0, 28.0]
│ alpha = 1.0 | coriolis=0 | M(q)=0
│ max_delta_tau = 0.5
│ max_speed = 1.5 rad/s (86 deg/s)
└─────────────────────────────────────────────────┘
Running 5693 steps (113.9s at 50Hz)…
step 250/5693 (5.0s) max=12.352° | J0=0.124 J1=0.146 J2=0.088 J3=1.020 J4=0.155 J5=12.352
step 500/5693 (10.0s) max=24.851° | J0=0.188 J1=0.099 J2=0.108 J3=0.490 J4=0.242 J5=24.851
step 750/5693 (15.0s) max=34.970° | J0=0.438 J1=0.266 J2=0.072 J3=1.479 J4=0.331 J5=34.970
step 1000/5693 (20.0s) max=14.569° | J0=0.119 J1=0.046 J2=0.086 J3=0.658 J4=0.415 J5=14.569
step 1250/5693 (25.0s) max=18.936° | J0=0.369 J1=0.211 J2=0.121 J3=0.643 J4=0.504 J5=18.936
step 1500/5693 (30.0s) max=22.935° | J0=0.102 J1=0.041 J2=0.010 J3=0.375 J4=0.499 J5=22.935
step 1750/5693 (35.0s) max=22.935° | J0=0.102 J1=0.075 J2=0.015 J3=0.407 J4=0.468 J5=22.935
step 2000/5693 (40.0s) max=22.932° | J0=0.466 J1=0.126 J2=0.148 J3=0.491 J4=0.194 J5=22.932
step 2250/5693 (45.0s) max=22.931° | J0=0.138 J1=0.340 J2=0.291 J3=0.990 J4=0.147 J5=22.931
step 2500/5693 (50.0s) max=22.930° | J0=0.082 J1=0.311 J2=0.154 J3=0.512 J4=0.593 J5=22.930
step 2750/5693 (55.0s) max=22.930° | J0=0.108 J1=0.114 J2=0.069 J3=1.109 J4=0.687 J5=22.930
step 3000/5693 (60.0s) max=22.932° | J0=0.397 J1=0.110 J2=0.212 J3=1.108 J4=0.368 J5=22.932
step 3250/5693 (65.0s) max=22.934° | J0=0.373 J1=0.249 J2=0.189 J3=1.093 J4=0.371 J5=22.934
step 3500/5693 (70.0s) max=22.934° | J0=0.082 J1=0.088 J2=0.077 J3=0.150 J4=0.899 J5=22.934
step 3750/5693 (75.0s) max=22.936° | J0=0.256 J1=0.209 J2=0.092 J3=0.186 J4=1.165 J5=22.936
step 4000/5693 (80.0s) max=22.934° | J0=0.333 J1=0.218 J2=0.289 J3=0.818 J4=0.217 J5=22.934
step 4250/5693 (85.0s) max=22.934° | J0=0.383 J1=0.063 J2=0.054 J3=0.315 J4=0.227 J5=22.934
step 4500/5693 (90.0s) max=13.484° | J0=0.217 J1=0.145 J2=0.144 J3=0.642 J4=0.730 J5=13.484
step 4750/5693 (95.0s) max=1.128° | J0=0.373 J1=0.083 J2=0.139 J3=0.520 J4=1.128 J5=0.988
step 5000/5693 (100.0s) max=11.506° | J0=0.141 J1=0.202 J2=0.298 J3=0.540 J4=0.608 J5=11.506
step 5250/5693 (105.0s) max=23.353° | J0=0.173 J1=0.346 J2=0.128 J3=0.548 J4=1.279 J5=23.353
step 5500/5693 (110.0s) max=35.853° | J0=0.344 J1=0.068 J2=0.113 J3=0.581 J4=1.020 J5=35.853
======================================================================
TESTING: ServoJ
Running 5693 steps (113.9s at 50Hz)…
step 250/5693 (5.0s) max=0.350° | J0=0.055 J1=0.006 J2=0.146 J3=0.133 J4=0.001 J5=0.350
step 500/5693 (10.0s) max=0.350° | J0=0.056 J1=0.007 J2=0.148 J3=0.133 J4=0.004 J5=0.350
step 750/5693 (15.0s) max=0.350° | J0=0.054 J1=0.006 J2=0.143 J3=0.133 J4=0.005 J5=0.350
step 1000/5693 (20.0s) max=0.352° | J0=0.054 J1=0.008 J2=0.146 J3=0.133 J4=0.003 J5=0.352
step 1250/5693 (25.0s) max=0.351° | J0=0.055 J1=0.005 J2=0.149 J3=0.131 J4=0.002 J5=0.351
step 1500/5693 (30.0s) max=0.002° | J0=0.001 J1=0.002 J2=0.000 J3=0.001 J4=0.001 J5=0.000
step 1750/5693 (35.0s) max=0.002° | J0=0.001 J1=0.001 J2=0.002 J3=0.000 J4=0.001 J5=0.001
step 2000/5693 (40.0s) max=0.350° | J0=0.350 J1=0.011 J2=0.018 J3=0.000 J4=0.004 J5=0.000
step 2250/5693 (45.0s) max=0.352° | J0=0.027 J1=0.352 J2=0.004 J3=0.336 J4=0.001 J5=0.001
step 2500/5693 (50.0s) max=0.001° | J0=0.001 J1=0.001 J2=0.001 J3=0.001 J4=0.001 J5=0.000
step 2750/5693 (55.0s) max=0.024° | J0=0.024 J1=0.014 J2=0.018 J3=0.000 J4=0.001 J5=0.000
step 3000/5693 (60.0s) max=0.348° | J0=0.348 J1=0.093 J2=0.123 J3=0.001 J4=0.001 J5=0.000
step 3250/5693 (65.0s) max=0.349° | J0=0.349 J1=0.090 J2=0.144 J3=0.001 J4=0.001 J5=0.001
step 3500/5693 (70.0s) max=0.002° | J0=0.000 J1=0.001 J2=0.002 J3=0.000 J4=0.001 J5=0.000
step 3750/5693 (75.0s) max=0.350° | J0=0.173 J1=0.255 J2=0.165 J3=0.006 J4=0.350 J5=0.001
step 4000/5693 (80.0s) max=0.308° | J0=0.205 J1=0.124 J2=0.260 J3=0.308 J4=0.032 J5=0.000
step 4250/5693 (85.0s) max=0.350° | J0=0.350 J1=0.001 J2=0.002 J3=0.001 J4=0.001 J5=0.000
step 4500/5693 (90.0s) max=0.350° | J0=0.095 J1=0.137 J2=0.096 J3=0.190 J4=0.019 J5=0.350
step 4750/5693 (95.0s) max=0.349° | J0=0.094 J1=0.134 J2=0.092 J3=0.191 J4=0.020 J5=0.349
step 5000/5693 (100.0s) max=0.350° | J0=0.099 J1=0.135 J2=0.096 J3=0.190 J4=0.019 J5=0.350
step 5250/5693 (105.0s) max=0.352° | J0=0.095 J1=0.135 J2=0.094 J3=0.192 J4=0.019 J5=0.352
step 5500/5693 (110.0s) max=0.351° | J0=0.096 J1=0.135 J2=0.094 J3=0.192 J4=0.021 J5=0.351
| Controller | RMS (all) | Max (all) | RMS J1 | RMS J2 | RMS J3 | RMS J4 | RMS J5 | RMS J6 | TCP Avg | TCP Max |
| ---------- | --------- | --------- | ------ | ------ | ------ | ------ | ------ | ------- | ------- | ------- |
| C1 | 0.128° | 0.459° | 0.176° | 0.108° | 0.180° | 0.057° | 0.064° | 0.126° | 0.36 mm | 0.87 mm |
| C2 | 9.119° | 42.951° | 0.293° | 0.170° | 0.163° | 0.754° | 0.650° | 22.311° | 4.32 mm | 8.54 mm |
| ServoJ | 0.153° | 0.357° | 0.193° | 0.107° | 0.110° | 0.136° | 0.062° | 0.240° | 0.30 mm | 0.68 mm |