DHCalc – Symbolic Denavit–Hartenberg Calculator in C++

DHCalc is a C++ command-line tool and library for computing forward kinematics of robotic manipulators using Denavit–Hartenberg parameters. It supports both numeric and symbolic DH tables, allowing you to work with variables. Under the hood it uses SymEngine for symbolic algebra in C++.

Example of usage on Stanford Arm:
stanford_arm.dh.tsv:

joint	θ	α	r	d
1	θ1	90	l2	l1
2	90+θ2	90	0	0
3	90	0	0	l3+l4+d3

Run with ./dhcalc -i ../examples/stanford_arm.dh.tsv

Output:

[ 1.0*sin(0.0175*θ1), -1.0*cos(0.0175*(90 + θ2))*cos(0.0175*θ1), 1.0*sin(0.0175*(90 + θ2))*cos(0.0175*θ1), 1.0*l2*cos(0.0175*θ1) + 1.0*d3*sin(0.0175*(90 + θ2))*cos(0.0175*θ1) + 1.0*l3*sin(0.0175*(90 + θ2))*cos(0.0175*θ1) + 1.0*l4*sin(0.0175*(90 + θ2))*cos(0.0175*θ1) ]
[ -1.0*cos(0.0175*θ1), -1.0*cos(0.0175*(90 + θ2))*sin(0.0175*θ1), 1.0*sin(0.0175*(90 + θ2))*sin(0.0175*θ1), 1.0*l2*sin(0.0175*θ1) + 1.0*d3*sin(0.0175*(90 + θ2))*sin(0.0175*θ1) + 1.0*l3*sin(0.0175*(90 + θ2))*sin(0.0175*θ1) + 1.0*l4*sin(0.0175*(90 + θ2))*sin(0.0175*θ1) ]
[ 0, -1.0*sin(0.0175*(90 + θ2)), -1.0*cos(0.0175*(90 + θ2)), 1.0*l1 - 1.0*d3*cos(0.0175*(90 + θ2)) - 1.0*l3*cos(0.0175*(90 + θ2)) - 1.0*l4*cos(0.0175*(90 + θ2)) ]
[ 0, 0, 0, 1.0 ]
1 Like