Skip to content

Commit 062abbd

Browse files
PhylliadeTanneguydvtdevillemagne
authored
v3.4 - Add complete support for DH parameters (#151)
* enable DH ik (#143) * enable DH * set name at None --------- Co-authored-by: tdevillemagne <tanneguy.de-villemagne@irt-jules-verne.fr> * Refactor tests and bump version * Fix linting --------- Co-authored-by: tanneguy <tanneguy.ga@gmail.com> Co-authored-by: tdevillemagne <tanneguy.de-villemagne@irt-jules-verne.fr>
1 parent d22a63d commit 062abbd

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

src/ikpy/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.3.4'
1+
__version__ = '3.4'

src/ikpy/link.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, name, length, bounds=None, is_final=False):
4040
self.axis_length = length
4141
self.is_final = is_final
4242
self.has_rotation = False
43+
self.has_translation = False
4344
self.joint_type = None
4445

4546
def __repr__(self):
@@ -267,7 +268,12 @@ class DHLink(Link):
267268
d: float
268269
offset along previous z to the common normal
269270
a: float
270-
offset along previous to the common normal
271+
length of the common normal (do not confuse with alpha)
272+
Assuming a revolute joint, this is the radius about previous z
273+
alpha: float
274+
angle about common normal, from old z axis to new z axis
275+
theta: float
276+
angle about previous z, from old x to new x
271277
use_symbolic_matrix: bool
272278
whether the transformation matrix is stored as Numpy array or as a Sympy symbolic matrix.
273279
@@ -277,10 +283,12 @@ class DHLink(Link):
277283
The link object
278284
"""
279285

280-
def __init__(self, name, d=0, a=0, bounds=None, use_symbolic_matrix=True):
281-
Link.__init__(self, use_symbolic_matrix)
286+
def __init__(self, name=None, d=0, a=0, alpha=0, theta=0, bounds=None, use_symbolic_matrix=True, length=0):
287+
Link.__init__(self, use_symbolic_matrix, length=length)
282288
self.d = d
283289
self.a = a
290+
self.alpha = alpha
291+
self.theta = theta
284292

285293
def get_link_frame_matrix(self, parameters):
286294
""" Computes the homogeneous transformation matrix for this link. """

tests/test_chain_dh.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from ikpy.chain import Chain
2+
from ikpy.link import OriginLink, DHLink
3+
from ikpy.utils import plot
4+
5+
import matplotlib.pyplot as plt
6+
7+
import numpy as np
8+
from math import pi
9+
10+
class UR10():
11+
def __init__(self):
12+
self.robot_name = 'UR10'
13+
self.home_config = [0, -pi/2, 0, -pi/2, 0, 0]
14+
self.dh_params = np.array([
15+
[ 0.1273, 0., pi/2, 0.],
16+
[ 0., -0.612, 0, 0.],
17+
[ 0., -0.5723, 0, 0.],
18+
[ 0.163941, 0., pi/2, 0.],
19+
[ 0.1147, 0., -pi/2, 0.],
20+
[ 0.0922, 0., 0, 0.]])
21+
22+
self.joint_limits = [
23+
(-360, 360),
24+
(-360, 360),
25+
(-360, 360),
26+
(-360, 360),
27+
(-360, 360),
28+
(-360, 360)]
29+
30+
def create_dh_robot(robot):
31+
# Create a list of links for the robot
32+
links = []
33+
for i, dh in enumerate(robot.dh_params):
34+
link = DHLink(d=dh[0], a=dh[1], alpha=dh[2], theta=dh[3], length=abs(dh[1]))
35+
link.bounds = robot.joint_limits[i]
36+
links.append(link)
37+
38+
# Create a chain using the robot links
39+
chain = Chain(links, name=robot.robot_name)
40+
return chain
41+
42+
43+
def test_dh_chain():
44+
robot = UR10()
45+
chain = create_dh_robot(robot)
46+
frame = [[1.112918581, -0.209413742, 0.19382176], [0.0, 1.0, 0.0]]
47+
target_position, target_orientation = frame
48+
joint_angles = chain.inverse_kinematics(target_position=target_position, target_orientation=target_orientation, orientation_mode="Z")
49+
50+
print(joint_angles)
51+
52+
fig, ax = plot.init_3d_figure()
53+
chain.plot(robot.home_config, ax)
54+
chain.plot(joint_angles, ax)
55+
plt.savefig("out/UR10.png")

0 commit comments

Comments
 (0)