Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.4 - Add complete support for DH parameters #151

Merged
merged 3 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ikpy/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.3.4'
__version__ = '3.4'
14 changes: 11 additions & 3 deletions src/ikpy/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, name, length, bounds=None, is_final=False):
self.axis_length = length
self.is_final = is_final
self.has_rotation = False
self.has_translation = False
self.joint_type = None

def __repr__(self):
Expand Down Expand Up @@ -267,7 +268,12 @@ class DHLink(Link):
d: float
offset along previous z to the common normal
a: float
offset along previous to the common normal
length of the common normal (do not confuse with alpha)
Assuming a revolute joint, this is the radius about previous z
alpha: float
angle about common normal, from old z axis to new z axis
theta: float
angle about previous z, from old x to new x
use_symbolic_matrix: bool
whether the transformation matrix is stored as Numpy array or as a Sympy symbolic matrix.

Expand All @@ -277,10 +283,12 @@ class DHLink(Link):
The link object
"""

def __init__(self, name, d=0, a=0, bounds=None, use_symbolic_matrix=True):
Link.__init__(self, use_symbolic_matrix)
def __init__(self, name=None, d=0, a=0, alpha=0, theta=0, bounds=None, use_symbolic_matrix=True, length=0):
Link.__init__(self, use_symbolic_matrix, length=length)
self.d = d
self.a = a
self.alpha = alpha
self.theta = theta

def get_link_frame_matrix(self, parameters):
""" Computes the homogeneous transformation matrix for this link. """
Expand Down
55 changes: 55 additions & 0 deletions tests/test_chain_dh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from ikpy.chain import Chain
from ikpy.link import OriginLink, DHLink
from ikpy.utils import plot

import matplotlib.pyplot as plt

import numpy as np
from math import pi

class UR10():
def __init__(self):
self.robot_name = 'UR10'
self.home_config = [0, -pi/2, 0, -pi/2, 0, 0]
self.dh_params = np.array([
[ 0.1273, 0., pi/2, 0.],
[ 0., -0.612, 0, 0.],
[ 0., -0.5723, 0, 0.],
[ 0.163941, 0., pi/2, 0.],
[ 0.1147, 0., -pi/2, 0.],
[ 0.0922, 0., 0, 0.]])

self.joint_limits = [
(-360, 360),
(-360, 360),
(-360, 360),
(-360, 360),
(-360, 360),
(-360, 360)]

def create_dh_robot(robot):
# Create a list of links for the robot
links = []
for i, dh in enumerate(robot.dh_params):
link = DHLink(d=dh[0], a=dh[1], alpha=dh[2], theta=dh[3], length=abs(dh[1]))
link.bounds = robot.joint_limits[i]
links.append(link)

# Create a chain using the robot links
chain = Chain(links, name=robot.robot_name)
return chain


def test_dh_chain():
robot = UR10()
chain = create_dh_robot(robot)
frame = [[1.112918581, -0.209413742, 0.19382176], [0.0, 1.0, 0.0]]
target_position, target_orientation = frame
joint_angles = chain.inverse_kinematics(target_position=target_position, target_orientation=target_orientation, orientation_mode="Z")

print(joint_angles)

fig, ax = plot.init_3d_figure()
chain.plot(robot.home_config, ax)
chain.plot(joint_angles, ax)
plt.savefig("out/UR10.png")
Loading