Plot 2D or 3D Robot Workspace

Version 1.0.2 (1.3 MB) by Niklas Z
An add-on that allows plotting 2D and 3D robots' workspaces using their DH parameters
391 Downloads
Updated 18 Feb 2024

Robotic Arm Workspace Plotter

This is a Matlab add-on that allows plotting the reachable workspace 2D and 3D robotic arms using the DH parameters.

Quickstart

2D Example

Here's a basic example for plotting a 2D robot's workspace via plot2dworkspace.m:

syms theta1 theta2 theta3 real
syms d1 d2 real

% DH parameters
test_dh = [0 0 0 theta1; ...
           120 0 0 theta2; ...
           60 0 0 0]
% Parameter ranges
theta1_range = linspace(0,2*pi, 180);
theta2_range = linspace(0,2*pi, 180);
test_map = containers.Map({'theta1', 'theta2'},{theta1_range,theta2_range});

% Workspace plotting function
plot2dworkspace(test_dh, test_map)

Which will render as follows:

For more examples, see /examples.

3D Example

Here's a basic example for plotting a 3D robot's workspace via plot3dworkspace.m:

syms theta1 theta2 theta3 theta4 theta5 theta6 real
syms d1 d2 d3 d4 real

% DH parameters
test_dh = [18.5 0 42 theta1; ...
           16 pi 0 theta2; ...
           0 0 d3 0; ...
           0 0 7 theta4]
% Parameter ranges
theta1_range = arr2Rad(linspace(0,300, 50));
theta2_range = arr2Rad(linspace(0,300, 50));
d3_range = linspace(0,12, 50);
% Note the specification states 540°, but anything past 360° is redundant
theta4_range = arr2Rad(linspace(0,360, 50));
test_map = containers.Map({'theta1', 'theta2', 'd3','theta4'}, ...
    {theta1_range, theta2_range, d3_range, theta4_range}); 
% Workspace plotting function
plot3dworkspace(test_dh, test_map, @get_alternative_dh_transform)


function out = arr2Rad(A)
    out = arrayfun(@(angle) deg2rad(angle), A);
end

function T = get_alternative_dh_transform(a,alpha,d,theta)
T = [cos(theta) -cos(alpha)*sin(theta) sin(alpha)*sin(theta) a*cos(theta)
     sin(theta) cos(alpha)*cos(theta) -sin(alpha)*sin(theta) a*sin(theta)
     0 sin(alpha) cos(alpha) d
     0 0 0 1];
end

Which will render as follows:

For more examples, see /examples.

Notes

  • Performance - this add-on uses a brute-force method that calculates the end-effector's position for every possible DH parameter combination. While reasonably well-optimised this can become expensive quickly. For example, if you have a 6 DOF robot and want to explore 20 possible values per parameter, this will take 20^6 = 64,000,000 operations and units of memory.
  • DH Parameter Convention - there are conventions to construct the DH transformation matrix, based on the order of the individual transforms for the DH parameters. By default this add-on uses the one here, but it is possible to provide an alternative function that returns a different matrix (see above 3D example).

Cite As

Niklas Z (2024). Plot 2D or 3D Robot Workspace (https://github.com/NiklasZ/robotic_arm_workspace/releases/tag/v1.0.2), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.2

See release notes for this release on GitHub: https://github.com/NiklasZ/robotic_arm_workspace/releases/tag/v1.0.2

1.0.1

See release notes for this release on GitHub: https://github.com/NiklasZ/robotic_arm_workspace/releases/tag/v1.0.1

1.0.0

0.1.0.0

See release notes for this release on GitHub: https://github.com/NiklasZ/robotic_arm_workspace/releases/tag/v0.1.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.