Robotics · Motion planning and control

UR16e Motion Planning and Control

Jun–Aug 2025

Connect collision-checked RRT paths to smooth joint references and nonlinear torque-driven execution.

From an RRT detour to dynamic execution

Torque-driven PyBullet simulation using the UR16e meshes. The red box blocks the direct joint-space route. Orange: desired end-effector path; blue: actual.

Use the video controls to play, pause and seek.

0.001179 rad pooled tracking RMS, 18.349 mm minimum sampled clearance over a 7.02 s planned maneuver. Reference and actual motion were checked separately, with no sampled collisions or joint/velocity/applied-torque violations.

The challenge is more than finding a path: interpolation and tracking errors can move a robot outside its planned corridor. This Python pipeline keeps timing on the checked joint-space edges, executes them with a nonlinear controller, then checks the reference and recorded motion independently.

A consistent six-joint robot model

The supplied URDF defines the six revolute joints, inertial properties, visual meshes and collision meshes. Python loads that model directly, resolves its mesh paths and provides forward kinematics, Jacobians, numerical inverse kinematics, rigid-body dynamics and torque-driven simulation.

Frame checks reconcile standard DH with URDF tool0 expressed in the UR controller base frame. That base is rotated 180° around Z from the simulation's base_link. COM positions and inertia tensors are transformed into consistent frames instead of mixing hand-coded tables with URDF values.

Model and implementation settings

Units are metres, radians and Nm. The base is fixed; damping, friction and contact response are disabled during tracking. Obstacles are independently queried for clearance, rather than used to stop an invalid motion. Simulation effort bounds are [330,330,150,56,56,56] Nm. Clearance uses 5 ms state samples, refined joint-space edges and selected nonadjacent self-collision pairs.

Bounded numerical IK replaces the original analytical branch solver. Edge-preserving quintic timing replaces the earlier B-spline timing workflow. MATLAB/Simulink files, symbolic derivation and robust/noise scenarios are retained in the legacy implementation; the executed results use Python.

Obstacle avoidance: plan first, then verify the motion

Kinematic playback of the RRT plan, with the checked box and sphere, start, goal and end-effector trail.

A joint-space RRT samples configurations, checks each extension along its edge, and connects a detour to the goal. Shortcut smoothing is checked again at finer spacing. Each remaining edge receives a quintic time law with zero velocity and acceleration at its endpoints, so the time parameterization follows the checked geometry instead of cutting corners.

Three planning seeds evaluated in one obstacle scene
SeedPlanning time (s)Raw length (rad)Smoothed length (rad)
51700.1332.69092.0082
51710.3943.36052.2096
51720.1162.79721.9635

All three found paths; the direct edge failed collision checking. Timings exclude smoothing and post-validation. The first seed's timed path was dynamically tracked. At 5 ms state samples, reference and actual minimum clearance were both 18.349 mm over the declared environment/self pairs; refined interval checks also found no collisions.

Per-joint errors during dynamic tracking of the RRT detour; initial errors decay without sustained large tracking errors.
Integrated execution errors are shown in radians, without visual amplification. The half-timestep run uses identical reference samples and differs by at most 7.13e−6 rad.
Scene, collision resolution and limits

Box centre [.635,.570,.482] m, half extents [.055,.055,.070] m; sphere centre [−.25,.50,.30] m, radius .08 m. Planning margin: 15 mm; edge sampling: .04 rad; shortcut checks: .01 rad; final edge validation: .005 rad Euclidean joint distance. Reference and actual states are checked every 5 ms with further interval samples at ≤.005 rad.

Selected nonadjacent link pairs are checked; adjacent/fixed helper pairs are excluded. Collision meshes use the supplied model's representations. Joint position/velocity and applied-torque limits are checked separately. Zero sampled violations do not certify continuous clearance or physical robot safety.

Matched torque-driven controller comparison

A separate six-second joint reference compares PD plus nominal gravity compensation with computed torque on the same nonlinear model. Both start with the same position offset and zero velocity, use the same 0.25 ms timestep, and share actuator bounds. This experiment contains no obstacles.

Matched PD and computed-torque tracking experiments on one clock, with matching viewpoints and scales. Orange is desired end-effector motion; blue is actual.

PD adds joint error feedback to gravity compensation. Computed torque uses nominal inverse dynamics to request desired acceleration plus feedback. Their gain units differ, so matching numerical gain values would not make the controllers equivalent.

Pooled RMS = √mean(error²) over all six joints and all state samples, including the initial error
ConfigurationPooled RMS (rad)Max final joint error (rad)
PD + gravity, nominal0.0086430.001370
Computed torque, nominal0.0096350.00000179
PD + gravity, 1 kg mismatch0.0280080.050365
Computed torque, 1 kg mismatch0.1867580.213234

Computed torque achieves a smaller nominal final error, but PD has lower pooled transient RMS in this configuration. Neither controller saturates in these converged runs.

Six nominal joint-error plots compare PD plus gravity and computed torque; transient errors differ by joint.
Controller equations, gains and applied torques

PD: τ = Kp(qd−q) + Kd(vd−v) + gnom(q)
CT: τ = IDnom(q,v,ad + 64(qd−q) + 16(vd−v))

PD Kp=[180,180,120,50,30,20] Nm/rad; Kd=[30,35,22,8,5,3] Nm·s/rad. CT gains are acceleration-space gains, fixed across nominal and payload cases. An initial 1 ms stiff-wrist numerical failure and the corrected timestep/convergence checks remain in the report.

Per-joint applied torque profiles in Nm for both nominal controllers.

What changes with an unmodeled payload?

Add 1 kg and a declared rotational inertia at tool0 while keeping both controllers' nominal models and gains unchanged. The computed-torque pooled RMS increases to 0.186758 rad, with joint-5 peak error about 0.709 rad. PD also degrades, to 0.028008 rad pooled RMS.

Matched nominal and 1 kg payload simulations, shown on the same clock and scale. The payload changes model inertia; the robot geometry is shared.
Per-joint payload-mismatch errors show larger computed-torque errors in the wrist than in the nominal case.

The equations, gain conventions, payload application and matched settings were checked, and the Python command reproduced the saved results. The payload test measures model-mismatch sensitivity with the same gains and reference trajectory.

Verification beyond a dynamics round trip

An independent implementation builds mass from COM Jacobians and kinetic energy, gravity from potential-energy derivatives, and velocity terms from mass derivatives. Those quantities are compared with the rigid-body engine, so validation does not rely only on forward/inverse routines sharing the same mistake.

The checks compare model quantities across independently sampled configurations.

About the project

Completed during my software engineering internship at UAES. The Python implementation integrates URDF/frame reconciliation, dynamics corrections, independent checks, planning/control experiments, payload studies and mesh-based visualization. Original MATLAB/Simulink sources are retained in the repository.

Reproduce and inspect the implementation

Linux/WSL Python 3.11, PyBullet, NumPy, SciPy, mesh/rendering dependencies and ffmpeg. The CLI provides kinematics, compare, payload, plan-track, verify and visualize commands. Use fresh output folders; configurations, full trajectories and metrics are exported.

Full reproduction commands · Feature mapping · Detailed dynamics and failure analysis