Giter Site home page Giter Site logo

phylliade / ikpy Goto Github PK

View Code? Open in Web Editor NEW
675.0 20.0 148.0 13.55 MB

An Inverse Kinematics library aiming performance and modularity

Home Page: http://phylliade.github.io/ikpy

License: Apache License 2.0

Python 100.00%
inverse-kinematics urdf robotics poppy python

ikpy's Introduction

IKPy

PyPI

DOI

demo

IKPy on the baxter robot

Demo

Live demos of what IKPy can do (click on the image below to see the video):

Also, a presentation of IKPy: Presentation.

Features

With IKPy, you can:

  • Compute the Inverse Kinematics of every existing robot.
  • Compute the Inverse Kinematics in position, orientation, or both
  • Define your kinematic chain using arbitrary representations: DH (Denavit–Hartenberg), URDF, custom...
  • Automatically import a kinematic chain from a URDF file.
  • Support for arbitrary joint types: revolute, prismatic and more to come in the future
  • Use pre-configured robots, such as baxter or the poppy-torso
  • IKPy is precise (up to 7 digits): the only limitation being your underlying model's precision, and fast: from 7 ms to 50 ms (depending on your precision) for a complete IK computation.
  • Plot your kinematic chain: no need to use a real robot (or a simulator) to test your algorithms!
  • Define your own Inverse Kinematics methods.
  • Utils to parse and analyze URDF files:

Moreover, IKPy is a pure-Python library: the install is a matter of seconds, and no compiling is required.

Installation

You have three options:

  1. From PyPI (recommended) - simply run:

    pip install ikpy

    If you intend to plot your robot, you can install the plotting dependencies (mainly matplotlib):

    pip install 'ikpy[plot]'
  2. From source - first download and extract the archive, then run:

    pip install ./

    NB: You must have the proper rights to execute this command

Quickstart

Follow this IPython notebook.

Guides and Tutorials

Go to the wiki. It should introduce you to the basic concepts of IKPy.

API Documentation

An extensive documentation of the API can be found here.

Dependencies and compatibility

Starting with IKPy v3.1, only Python 3 is supported. For versions before v3.1, the library can work with both versions of Python (2.7 and 3.x).

In terms of dependencies, it requires numpy and scipy.

sympy is highly recommended, for fast hybrid computations, that's why it is installed by default.

matplotlib is optional: it is used to plot your models (in 3D).

Contributing

IKPy is designed to be easily customisable: you can add your own IK methods or robot representations (such as DH-Parameters) using a dedicated developer API.

Contributions are welcome: if you have an awesome patented (but also open-source!) IK method, don't hesitate to propose adding it to the library!

Links

  • If performance is your main concern, aversive++ has an inverse kinematics module written in C++, which works the same way IKPy does.

Citation

If you use IKPy as part of a publication, please use the Bibtex below as a citation:

@software{manceron_pierre_2022_6551158,
  author       = {Manceron, Pierre},
  title        = {IKPy},
  month        = may,
  year         = 2022,
  note         = {{If you use this software, please cite it using the 
                   metadata from this file.}},
  publisher    = {Zenodo},
  version      = {v3.3.3},
  doi          = {10.5281/zenodo.6551158},
  url          = {https://doi.org/10.5281/zenodo.6551158}
}

ikpy's People

Contributors

01halibut avatar buschbapti avatar deepserket avatar fabienrohrer avatar gitter-badger avatar hassony2 avatar kdercksen avatar luzpaz avatar maximkulkin avatar phylliade avatar pierre-rouanet avatar pygeek03 avatar simon-steinmann avatar ymollard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ikpy's Issues

Normalize angles to 2*pi

I am seeing things like this:

print("The angles of each joints are : ", my_chain.inverse_kinematics(target_frame))
('The angles of each joints are : ', array([ 0. , -60.47565859, -69.55194186, -104.00364979, 0. ]))

I suggest that the joint angles have a "% twopi" on them where twopi=2*3.14159265359.

Great library, unfortunately I can't figure out how to use limits (or if the limits in the chain really work), so it wants to drive my arm through the table in some cases. I think I'm going to have to use Caliko with FABRIK, but your library is a lot easier to install & use!

Thanks!

Support for orientation using one Axis

A popular feature is related to orientation.

A first step would be to support orientation regarding one axis, e.g. only reaching an orientation for the x axis

Target with rotation

Hey guys,
is there a way to get a solution for a rotated target? We would like to use ikpy for our robotik, animations in unity, but therefor we need to rotate the target.

Any ideas?

Creating chain from URDF

Hi, I am trying to create a chain from URDF file of Baxter and is facing following error. I can't figure out why? What is wrong in this declaration? Any help please

my_chain = ikpy.chain.Chain.from_urdf_file("../baxter_common/baxter_description/urdf/baxter.urdf",
    base_elements=["right_upper_shoulder", "right_lower_shoulder", "right_upper_elbow", "right_lower_elbow", 
                   "right_upper_forearm", "right_lower_forearm", "right_wrist", "right_hand"], 
    last_link_vector=[0.0, 0.0, 0.025], 
    active_links_mask=[False, True, True, True, True, True, True,True])

I am using this file: Baxter URDF

And get this error!!!

raise ValueError("Your active links mask length of {} is different from the number of your links, which is {}".format(len(active_links_mask), len(self.links)))
ValueError: Your active links mask length of 8 is different from the number of your links, which is 2

'NoneType' object has no attribute 'attrib'

I'm getting the following error when trying to import a chain defined by a URDF.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-36-91ab49d6370e> in <module>
----> 1 ur10_chain = ikpy.chain.Chain.from_urdf_file("bot.urdf")

/miniconda3/lib/python3.6/site-packages/ikpy/chain.py in from_urdf_file(cls, urdf_file, base_elements, last_link_vector, base_element_type, active_links_mask, name)
    155             base_elements = ["base_link"]
    156 
--> 157         links = URDF_utils.get_urdf_parameters(urdf_file, base_elements=base_elements, last_link_vector=last_link_vector, base_element_type=base_element_type)
    158         # Add an origin link at the beginning
    159         return cls([link_lib.OriginLink()] + links, active_links_mask=active_links_mask, name=name)

/miniconda3/lib/python3.6/site-packages/ikpy/URDF_utils.py in get_urdf_parameters(urdf_file, base_elements, last_link_vector, base_element_type)
    152         if node_type == "link":
    153             # Current element is a link, find child joint
--> 154             (has_next, current_joint) = find_next_joint(root, current_link, next_element)
    155             node_type = "joint"
    156             if has_next:

/miniconda3/lib/python3.6/site-packages/ikpy/URDF_utils.py in find_next_joint(root, current_link, next_joint_name)
     48             # FIXME: We are not sending a warning when we have two children for the same link
     49             # Even if this is not possible, we should ensure something coherent
---> 50             if joint.find("parent").attrib["link"] == current_link_name:
     51                 has_next = True
     52                 next_joint = joint

AttributeError: 'NoneType' object has no attribute 'attrib'

I'm not too familiar with the URDF format, or ikpy's parser to figure out what this error means. Any suggestions on how to proceed would be much appreciated.

Can you find certain joint locations?

I know that this library can find end effector position, with F.K. However I would like to know whether you can find certain joint position and orientation in space?

Ex. I have a 6 DOF robot, I would like to find position of 3rd joint in space.

Le lancement du fichier poppy_torso.URDF

J'ai eu un problème quand je lance les codes: dans le dossier 'src', la classe chain a une fonction 'from_urdf_file' qui peut lire tous les joints dans le fichier URDF, mais quand je utilise le fichier 'poppy_torso.URDF' dans le dossier 'source', la fonction 'from_urdf_file' ne peut pas lire les joints, mais avec le fichier 'poppy_torso.URDF', cela marche.
Est-ce que cette faute est a cause de ma mal compréhension des codes ou je manque quelques choses ?
En plus, monsieur, si cela ne vous déranger pas, est-ce que vous pourriez m'expliquer comment faire la transformation entre les angles des joints et leurs positions Cartisienne, maintenant, j'ai une liste d'angle de chaque joint, avec la fonction 'forward_kinematics' , je peux avoir la matrice f-k, et puis, qu'est-ce que je doit faire?

Definition of the robot

Hi,

Thank you for your work. I have few questions about the use of this library.

  • I have concern about the definition of the robot with DH-Table. It seems that the function to crate links with DH-Parameters is not implemented yet. Do you know a way to transform easily DH-Parameters into URDF parameters (Translation_vector, orientation and rotation) ?

  • My robot is a KUKA KR-100 HA with a 7th prismatic joint. I haven't found a way to define a prismatic joint, is there a solution in your program ? And is the program able to compute inverse solution for redundant robot ?

Thank you very much

Marc

IT DOES NOT RESPECT LIMITS

Hi,

As written on the tittle, the tool does not respect limits sent by URDF, I do not know if it is a problem of my URDF of function call, can anyone give me hints?

URDF

function call
my_chain = ikpy.chain.Chain.from_urdf_file("/home/matteo/rover_ws/urdf/youbot.urdf", base_elements=["base_link", "arm_joint_0", "arm_link_0", "arm_joint_1", "arm_link_1", "arm_joint_2", "arm_link_2", "arm_joint_3", "arm_link_3", "arm_joint_4", "arm_link_4", "arm_joint_5", "arm_link_5"]) ax = matplotlib.pyplot.figure().add_subplot(111, projection='3d')

can not plot the chain

I am using Miniconda 64bit python. 3.6 on w10
both lines
%matplotlib inline
%matplotlib notebook
result in an error (invalid syntax)
commenting both out does not show a plot window.

Exception "RuntimeError: generator raised StopIteration" with Python3.7

Python 3.7 has change the behavior of generators : when they reach the end now they emit a RuntimeError exception...
In the file URDF_utils.py there are two occurences of next(...) that can raise RuntimeError exception, lines 91 and 103.

Line 103 "chain = list(next(it) for it in itertools.cycle(iters))" can be replaced by:

chain = []
    for it in itertools.cycle(iters):
        try:
            item = next(it)
        except:
            break
        chain.append(item)

Prismatic joint works as revolute one

Hi , i created a following URDF

<robot
  name="flat">
  <link
    name="base_link">
  </link>
  <link
    name="U_shape">
  </link>
  <joint
    name="m1"
    type="prismatic">
    <origin
      xyz="10 0 0"
      rpy="0 0 0" />
    <parent
      link="base_link" />
    <child
      link="U_shape" />
    <axis
      xyz="1 0 0" />
  </joint>
</robot> 

When trying to do chain.forward_kinematic , it outputs this:

command
my_chain.forward_kinematics([0,10],True)

output

array([[  1.        ,   0.        ,   0.        ,  10.        ],
       [  0.        ,  -0.83907153,   0.54402111,   0.        ],
       [  0.        ,  -0.54402111,  -0.83907153,   0.        ],
       [  0.        ,   0.        ,   0.        ,   1.        ]])

seems it rotates about X-axis, but translate from X-axis was expected.
Is prismatic joint supported ? thanks.

Requirements.txt is not consistent with setup.py

In [1]: import ikpy
ImportError                               Traceback (most recent call last)
<ipython-input-1-7df5a6184463> in <module>()
----> 1 import ikpy

/Volumes/data/home/miniconda2/lib/python2.7/site-packages/ikpy/__init__.py in <module>()
----> 1 from . import chain

/Volumes/data/home/miniconda2/lib/python2.7/site-packages/ikpy/chain.py in <module>()
      7 from . import URDF_utils
      8 from . import inverse_kinematics as ik
----> 9 from . import plot_utils
     10 import numpy as np
     11 from . import link as link_lib

/Volumes/data/home/miniconda2/lib/python2.7/site-packages/ikpy/plot_utils.py in <module>()
      1 # coding= utf8
----> 2 import matplotlib.pyplot
      3 import numpy as np
      4 from . import geometry_utils
      5 import matplotlib.animation

ImportError: No module named matplotlib.pyplot

You should load your requirements.txt in your setup.py (to add matplotlib as required), or better, refactor your code to make matplotlib an optional dependency.

Jacobian Implementation

Hello Phylliade,

I am trying to use your code for a 6-dof manipulator I am building. However I want to take the Jacobian from my created chain and there isn't such function. Will you implement it in the near future? After I saw that, I am trying to implement it myself, but I am having trouble as I want the symbolic transformation matrix of each link, then multiply them all and get the final (symbolic) transformation matrix. After that it's a matter of differentiation with respect to the thetas I plug in. However the symbolic_transformation_matrix of every link is a function and not a sympy matrix, so i can't multiply them all together. Apart from that I want to specify the names of the variables (of the "thetas") for every symbolic matrix(every variable is called "theta"). Could you please help me in any way?

Plotting with a 2D axes seems to raise an unclear Error

Using my custom IK chain, this works well:

ax = figure().add_subplot(111, projection='3d')
poppy.l_arm_chain.plot([0]*9, ax)

but this:

ax = figure().add_subplot(111)
poppy.l_arm_chain.plot([0]*9, ax)

raises this Exception:

[...]
/Users/pierrerouanet/.pyenv/versions/anaconda-2.4.0/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _grab_next_args(self, *args, **kwargs)
    384                 return
    385             if len(remaining) <= 3:
--> 386                 for seg in self._plot_args(remaining, kwargs):
    387                     yield seg
    388                 return
/Users/pierrerouanet/.pyenv/versions/anaconda-2.4.0/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _plot_args(self, tup, kwargs)
    337             tup = tup[:-1]
    338         elif len(tup) == 3:
--> 339             raise ValueError('third arg must be a format string')
    340         else:
    341             linestyle, marker, color = None, None, None

ValueError: third arg must be a format string

error trying to import forward_kinematics

Hello! I was trying to run the Quickstart tutorial for poppy-humanoid, and it's throwing an import error looking for the forward_kinematics file, which (after some digging) i found was deleted in this commit 164a5ba

Should it still be around, or should that import be removed? It looked like it wasn't just a stray import because fk functions are used throughout the code, should the forward kinematics file be re-added or should all the references be removed?

thanks!

inverse, forward kinematics problem

Hi Phylliade
I am using your code to solve the ur5 kinematics.
However when I use the conmands inverse_kinematics and forward_kinematics,
the resuts are very strange.
For example in your "Getting Stated"
I simply copped the code like this:

import numpy as np
import matplotlib.pyplot as plt
import ikpy as ik


from ikpy import chain
from ikpy import plot_utils

my_chain = ik.chain.Chain.from_urdf_file("ik/poppy_ergo.URDF")



fk = my_chain.forward_kinematics([  0.00000000e+00,  -7.83311388e-01,  -1.13929769e+00,
     8.39373996e-01,   6.05357632e-05,   7.31474063e-01,
     0.00000000e+00])

print(fk)

and it returns

[[ -7.05670648e-01 6.43585169e-01 2.96356318e-01 1.49993875e-01]
[ 7.08540003e-01 6.40968301e-01 2.95179100e-01 1.50195323e-01]
[ 1.78851283e-05 4.18279534e-01 -9.08318354e-01 1.67503064e-01]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00]]

Not as expected

[[1, 0, 0, 2],
[0, 1, 0, 2],
[0, 0, 1, 2],
[0, 0, 0, 1]]

Moreover, when I input the transfer matrix fk as above, into a inverse_kinematics, the result is not the same with what I used

ik = my_chain.inverse_kinematics(fk)

print(ik)

It returns
[ 0. -0.78674925 -1.14065448 0.84229575 -0.00591668 0.72914705

  1.    ]
    

Am I using the code the right way, or something is wrong.

Thanks a lot!

How to load resources/contrib/baxter.urdf?

I removed the <transmission> and <gazebo>, and got

% python -c "import ikpy; print ikpy.chain.Chain.from_urdf_file('baxter.urdf', ['base'])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/wkentaro/Projects/ikpy/ikpy/src/ikpy/chain.py", line 123, in from_urdf_file
    links = URDF_utils.get_urdf_parameters(urdf_file, base_elements=base_elements, last_link_vector=last_link_vector, base_element_type=base_element_type)
  File "/Users/wkentaro/Projects/ikpy/ikpy/src/ikpy/URDF_utils.py", line 141, in get_urdf_parameters
    rotation = joint.find("axis").attrib['xyz'].split()
AttributeError: 'NoneType' object has no attribute 'attrib'

so added <axis xyz="0 0 1" /> to all <joint></joint>, but got:

% python -c "import ikpy; print ikpy.chain.Chain.from_urdf_file('baxter.urdf', ['base'])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/wkentaro/Projects/ikpy/ikpy/src/ikpy/chain.py", line 125, in from_urdf_file
    return cls([link_lib.OriginLink()] + links, active_links_mask=active_links_mask, name=name)
  File "/Users/wkentaro/Projects/ikpy/ikpy/src/ikpy/chain.py", line 27, in __init__
    link._axis_length = self.links[index - 1]._axis_length
AttributeError: 'OriginLink' object has no attribute '_axis_length'

so commented out

# chain.py
        # # Avoid length of zero in a link
        # for (index, link) in enumerate(self.links):
        #     if link._length == 0:
        #         link._axis_length = self.links[index - 1]._axis_length

now I get

% python -c "import ikpy; print ikpy.chain.Chain.from_urdf_file('baxter.urdf', ['base'])"
Kinematic chain name=chain links=[Link name=Base link, Link name=torso_t0, Link name=left_torso_arm_mount, Link name=left_s0, Link name=left_s1, Link name=left_e0_fixed] active_links=[ True  True  True  True  True  True]

It seems strange because there is no right arm. Do you have any idea how to fix this?
Or am I missing something?

Inverse Kinematic expected target shape.

I've create a Chain using an Urdf file an chain of link, joint like this:

motors=poppy.torso + poppy.l_arm
urdf_chain = get_chain_from_joints(poppy.urdf_file, [m.name for m in motors])

#get_urdf_parameters(poppy.urdf_file, chain)
from ikpy.chain import Chain

c = Chain.from_urdf_file(poppy.urdf_file, urdf_chain)

print([l.name for l in c.links])
>>> ['Base link', 'abs_z', 'bust_y', 'bust_x', 'l_shoulder_y', 'l_shoulder_x', 'l_arm_z', 'l_elbow_y']

When I'm trying the forward kinematic everything seems fine:

print(c.forward_kinematics([0]* len(c.links)))
>>>array([[ -1.83869638e-02,   9.99830945e-01,  -6.75390860e-08,
          2.53582184e-01],
       [  9.99830945e-01,   1.83869638e-02,   3.67258413e-06,
         -2.13820077e-03],
       [  3.67320510e-06,   3.22997617e-15,  -1.00000000e+00,
          2.10999975e-01],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00]])

Yet when I'm trying the inverse kinematic I got some exceptions:

c.inverse_kinematics(c.forward_kinematics([0]* len(c.links)), [0]*len(c.links))

[...]

/Users/pierrerouanet/dev/ikpy/src/ikpy/inverse_kinematics.pyc in optimize_target(x)
     14     def optimize_target(x):
     15         y = np.append(starting_nodes_angles[:first_active_joint], x)
---> 16         squared_distance = np.linalg.norm(chain.forward_kinematics(y)[:3, -1] - target)
     17         return squared_distance
     18 
ValueError: operands could not be broadcast together with shapes (3,) (4,4) 

Any ideas? It seems to me that the forward is returning the whole 4x4 homogeneous matrix while the inverse is only expecting the translation vector?

Actually, this seems to work:

c.inverse_kinematics(c.forward_kinematics([0]* len(c.links))[:3, 3],
                     [0]*len(c.links))
>>> 
Inverse kinematic optimisation OK, done in 0 iterations
Out[13]:
array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])

Limits issue

Hi,

I've seen this issue brought up in other issues and I'm having it as well.
My urdf is fairly simple, you can have a look at it:

























<joint name="rot_joint" type="revolute">
		<parent link="base_link"/>
		<child link="platform_link"/>
		<origin xyz="0 0 0.09" rpy="0 0 0" /> 
		<axis xyz="0 0 1" />  
</joint>

<joint name="shoulder_joint" type="revolute">
		<parent link="platform_link"/>
		<child link="arm_link"/>
		<origin xyz="0 0 0.05" rpy="0 0 0" /> 
		<axis xyz="0 1 0" /> 
	<limit effort="3.1" lower="-0.02" upper="0.02" velocity="7.0"></limit>
</joint>

<joint name="elbow_joint" type="revolute">
		<parent link="arm_link"/>
		<child link="forearm_link"/>
		<origin xyz="-0.037 0 0.172" rpy="0 0 0" />
	<limit effort="3.1" lower="-0.2" upper="0.2" velocity="7.0"/> 
		<axis xyz="0 1 0" /> 
</joint>

<joint name="grip_joint" type="revolute">
		<parent link="forearm_link"/>
		<child link="gripper_link"/>
		<origin xyz="0.135 0 -0.172" rpy="0 0 0" /> 
		<axis xyz="0 1 0" /> 
	<limit effort="3.1" lower="-0.2" upper="0.2" velocity="7.0"/> 
</joint>

In the shoulder joint, I've set the limit between -0.2 and 0.2 rad, however it doe snot respect the limit at all, am I missing something?

Thanks,

Samuel

AttributeError: 'DHLink' object has no attribute '_length'

The above error arises because the self._length parameter is not defined in the DHLink class (found at https://github.com/Phylliade/ikpy/blob/master/src/ikpy/link.py)

So, if I try to initialize the bot by using the following code :

# Define the bot based on Denavit-Hartenberg values
robot_chain = Chain(name="robotic_chain", links=[
    DHLink(
        name="base",
        d=65,
        a=0
    ),
    DHLink(
        name="shoulder",
        d=0,
        a=241
    ),
    DHLink(
        name="elbow",
        d=0,
        a=165
    ),
    DHLink(
        name="wrist_pitch",
        d=0,
        a=110
    ),
    DHLink(
        name="wrist_roll",
        d=110,
        a=0
    )
])

I would end up with an error : "AttributeError: 'DHLink' object has no attribute '_length'". Does anyone know how to calculate the _length from the DH Parameters?

Create Chain method will not make chain from URDF file and also does not throw an error

Hi, while using the library on a raspberry PI, the .from_urdf_file() method seems to run fine on the tutorial file poppy_ergo.URDF. But when given my URDF file to create a chain it does not actually create a chain, merely creating a simple base_link fill in. It also does not throw any error when trying to parse the file, it simply takes it and does not parse any data.
Screenshot (8)
Screenshot (9)

How to create chain of links from DH table, I got an error while trying to do that.

l0 = ikpy.link.OriginLink() l1 = ikpy.link.DHLink('l1', d=3, a=0, bounds=None, use_symbolic_matrix=True) l2 = ikpy.link.DHLink('l2', d=0, a=5.75, bounds=None, use_symbolic_matrix=True) l3 = ikpy.link.DHLink('l3', d=0, a=7.375, bounds=None, use_symbolic_matrix=True) l4 = ikpy.link.DHLink('l4', d=0, a=0, bounds=None, use_symbolic_matrix=True) l5 = ikpy.link.DHLink('l5', d=4.125, a=0, bounds=None, use_symbolic_matrix=True) my_chain = ikpy.chain.Chain([l0,l1,l2,l3,l4,l5])
I got this error
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 my_chain = ikpy.chain.Chain([l0,l1,l2,l3,l4,l5])

~/.local/lib/python3.5/site-packages/ikpy/chain.py in init(self, links, active_links_mask, name, profile, **kwargs)
21 self.name = name
22 self.links = links
---> 23 self._length = sum([link._length for link in links])
24 # Avoid length of zero in a link
25 for (index, link) in enumerate(self.links):

~/.local/lib/python3.5/site-packages/ikpy/chain.py in (.0)
21 self.name = name
22 self.links = links
---> 23 self._length = sum([link._length for link in links])
24 # Avoid length of zero in a link
25 for (index, link) in enumerate(self.links):

AttributeError: 'DHLink' object has no attribute '_length'`

Also I got this error when trying to import from ikpy import plot_utils

from ikpy import plot_utils

error

`---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in ()
1 import ikpy
2 import numpy as np
----> 3 from ikpy import plot_utils

~/.local/lib/python3.5/site-packages/ikpy/plot_utils.py in ()
4 from . import geometry_utils
5 import matplotlib.animation
----> 6 from mpl_toolkits.mplot3d import Axes3D
7
8

/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/init.py in ()
2 unicode_literals)
3
----> 4 from matplotlib.externals import six
5
6 from .axes3d import Axes3D

ImportError: No module named 'matplotlib.externals'`

Thank you.

Solving not only the position but orientation including

I try to solve IK for my robot. Is there any way to solve not only the position but the orientation, too?

I need a IK-Solver with such function to get the angles for my joints depending on the orientation for the end-effector of my robot. Is that possible with your library?

ParseError: not well-formed (invalid token): line 45, column 93

Hello
Sorry but I am not a coder.
I will try to follow your step to step with poppy Urdf in a file and i have this error

my_chain = ikpy.chain.Chain.from_urdf_file ("C:\POPPY\poppy_ergo.URDF")
Traceback (most recent call last):

File "C:\Users\alexa\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3326, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in
my_chain = ikpy.chain.Chain.from_urdf_file ("C:\POPPY\poppy_ergo.URDF")

File "C:\Users\alexa\Anaconda3\lib\site-packages\ikpy\chain.py", line 166, in from_urdf_file
links = URDF_utils.get_urdf_parameters(urdf_file, base_elements=base_elements, last_link_vector=last_link_vector, base_element_type=base_element_type)

File "C:\Users\alexa\Anaconda3\lib\site-packages\ikpy\URDF_utils.py", line 127, in get_urdf_parameters
tree = ET.parse(urdf_file)

File "C:\Users\alexa\Anaconda3\lib\xml\etree\ElementTree.py", line 1197, in parse
tree.parse(source, parser)

File "C:\Users\alexa\Anaconda3\lib\xml\etree\ElementTree.py", line 598, in parse
self._root = parser._parse_whole(source)

File "", line unknown
ParseError: not well-formed (invalid token): line 45, column 93

Thanks a lot for your help

How to create a Chain without an URDF file?

I'm aiding a 3 DOF manipulator development, and I'm looking through the library to use it on the project. But, as I'm helping making it from scratch, there is no URDF file to use, and the examples on the tutorial pages are always using it. How can I code a chain without having it previously on an URDF file?

Ways to deal with self-collisions?

Hello, great library, thanks for your work!

Is there any way to ensure that the joint angles returned from inverse kinematics won't result in a self-collision? I have my own functions for detecting these but how could I influence or change the optimisation to avoid them?

Should I change link bounds as the arm moves and is this possible/advisable?

AttributeError: 'Robot' object has no attribute 'goto_target'

I'm in the Inverse kinematics with the ErgoJr tutorial, and in cell 7 i'm getting

----
AttributeError                            Traceback (most recent call last)
<ipython-input-7-d1db5050b446> in <module>()
----> 1 poppy.goto([-0.00670386, -0.17439168,  0.15083097])

AttributeError: 'Robot' object has no attribute 'goto'

I've tried to track this down but without luck, can't find where the Robot object is stored, any ideas?

Transform matrix, whom to whom?

Hi, thanks for your work. Great one, I like it. I'm doing some deeplearning research, thus I'm not quite familiar with robotics. Sorry for my innocent,
So here's my problem about what is 'real_frame' in code, does that mean to transform from end-effector to old one? (I think it is, but not sure)
Take two frame for example, world_frame and new_frame, when joint is given:


> <joint                 
>   name="joint1"        
>   type="revolute">     
>   <origin              
>     xyz="0 -0.43 0"    
>     rpy="1.5708 0 0" />        <-------rotation around axis X?    counter-clock wise? I guess?
>   <parent              
>     link="base_link" />
>   <child               
>     link="link1" />    
>   <axis                
>     xyz="0 0 1" />     
>   <limit               
>     lower="0"          
>     upper="0"          
>     effort="0"         
>     velocity="0" />    
> </joint>               

then returned two frames are:
[[[ 1. 0. 0. 0. ]
[ 0. 1. 0. 0. ]
[ 0. 0. 1. 0. ]
[ 0. 0. 0. 1. ]]

[[ 1. 0. 0. 0. ]
[ 0. -0. -1. -0.43]
[ 0. 1. -0. 0. ]
[ 0. 0. 0. 1. ]]

Document how to create custom URDFs

It would be great to document how to write custom URDFs, for robots that don't have any, or non-compliant ones.
It could be the occasion to add new URDF samples, like the Baxter one, a standard robotics arm, etc...

Not position but Orientation for IK solver

I tested your library, pretty decent by selecting active joints. However your library minimize its IK solver error by position not by its Orientation. In other words it solves for the Position of the Homo. Transformation Matrix and after that it checks orientation.

How I can solve for orientation as priority?

As I see in the code:

    def optimize_target(x):
        # y = np.append(starting_nodes_angles[:chain.first_active_joint], x)
        y = chain.active_to_full(x, starting_nodes_angles)
        squared_distance = np.linalg.norm(chain.forward_kinematics(y)[:3, -1] - target)
        return squared_distance

This section is specified for target which is position. Any suggestion for Orientation?

Question - Generating Links from World Points

Hi, I am pretty new to this all. But I was wondering if someone could help me. I have a set of world coords for different joints and I have been trying to build chains for these points however I am having trouble figuring it out.

Here is an example:

{
'left_leg': ([-23.4254, -23.5361, -23.9642], # X-points
              [-4.2424, -4.2233, -4.3618], # Y-Points
              [1.0065, 0.5614, 0.6598]), # Z-Points
}

Where we would have three joints all connect like this

joint_0 = (-23.0585, -4.3753, 0.208)
joint_1 = (-23.0799, -4.3955, 0.6677)
joint_2 = (-23.3939, -4.4256, 1.0013)

The end goal is to simulate a human's leg and solve for toe position.

Thanks for your help in advance!

Update conda package

2 things to do :

  • Update the conda package to te last version
  • Add a version for Python 2.7

ik angles for more than one axis of rotation

Hi,

i was trying out the sample code and modified the chain to as below
left_arm_chain = Chain(name='left_arm', links=[ OriginLink(), URDFLink( name="shoulder", translation_vector=[1, 0, 0], orientation=[0, 0, 0], rotation=[0, 1, 1], ), URDFLink( name="elbow", translation_vector=[10, 0, 0], orientation=[0, 0, 0], rotation=[0, 0, 1], ), URDFLink( name="wrist", translation_vector=[10, 0, 0], orientation=[0, 0, 0], rotation=[0, 0, 1], ) ])

the ik plot is showing properly.

but i am not able to understand how the angles are being printed.

when i run
print(left_arm_chain.inverse_kinematics([[1, 0, 0, 11], [0, 1, 0, 6], [0, 0, 1, 6], [0, 0, 0, 1]]))

i get the output
[ 0. -0.6926806 2.01853327 0. ]

shouldn't the first rotation angle have 2 angles? one in z and another in y?

please help me understand how to get 2 angles from this.

Thanks

Remove `poppy-inverse-kinematics`

poppy-inverse-kinematics is an old module used at the beginnings of the library. It, (and its tutorials) should be removed from the main repo.

Origin Link is not working

We check our handmade robot arm with ikpy. but when we use OriginLink it was not giving us the exact value.

then we use this

from ikpy.chain import Chain
from ikpy.link import OriginLink, URDFLink
from ikpy import geometry_utils
import numpy as np
import math

robotarm = Chain(name='left_arm', links=[

URDFLink(
  name="mx",
  translation_vector=[0,0, 0],
  orientation=[0, 0, 0],
  rotation=[0, 0, 1],
),
URDFLink(
  name="mb",
  translation_vector=[42,32.42, 0],
  orientation=[0, 0, 0.658],
  rotation=[0, 0, 1],
),
URDFLink(
  name="mm",
  translation_vector=[-32.7,25.54, 0],
  orientation=[0, 0, 2.47],
  rotation=[0, 0, 1],
)

])

tvalues = geometry_utils.to_transformation_matrix([-9.4,66.64,0])
tmax = robotarm.inverse_kinematics(tvalues)
mb_val =math.degrees(tmax[0] + 0.658)
mm_val =math.degrees(tmax[1] + 2.47)
print mb_val
print mm_val

print tmax

youbot.urdf IK

Hi,

I am trying to use ikpy on my urdf file, generated by the command:
rosrun xacro xacro.py -o model.urdf model.urdf.xacro
And here the file auto-generated: youbot.txt

As long I am developing a project in a simulation environment (V-REP) I must connect arm_link_0 to base_footprint instead of base_link otherwise the tf transformation will not work, the simulation program cannot manage it properly.

So now I am trying to do the inverse kinematics using this urdf, but I think that not having the base_link could arise in some problems like the one I am having now:

matteo@matteo-S551LB:~/rover_ws/src/kuka_arm_cmd/src$ python kinematics.py 
Traceback (most recent call last):
  File "kinematics.py", line 57, in <module>
    my_chain = ikpy.chain.Chain.from_urdf_file("/home/matteo/rover_ws/urdf/youbot.urdf")
  File "/usr/local/lib/python2.7/dist-packages/ikpy/chain.py", line 123, in from_urdf_file
    links = URDF_utils.get_urdf_parameters(urdf_file, base_elements=base_elements, last_link_vector=last_link_vector, base_element_type=base_element_type)
  File "/usr/local/lib/python2.7/dist-packages/ikpy/URDF_utils.py", line 123, in get_urdf_parameters
    (has_next, current_joint) = find_next_joint(root, current_link, next_element)
  File "/usr/local/lib/python2.7/dist-packages/ikpy/URDF_utils.py", line 40, in find_next_joint
    if joint.find("parent").attrib["link"] == current_link_name:
AttributeError: 'NoneType' object has no attribute 'attrib'

Any hints?

Thanks

Importing two Chain objects from URDF raises an unclear error

I tried to create two distinct Chain objects, both of them being imported from URDF files:

chain1 = Chain.from_urdf_file("poppy_ergo.URDF")
chain2 = Chain.from_urdf_file("poppy_ergo.URDF")

The first object is OK and works well as long as no other URDF import is performed. I can include several kinematics calculations between these two instanciations, and nothing wrong happens. But when instanciating the second object, I get an AttributeError:

AttributeError: 'NoneType' object has no attribute 'find'

coming from

.../site-packages/ikpy/URDF_utils.py in find_next_link
    53    if next_link_name is None:
    54        # If the name of the next link is not provided, find it
--> 55        next_link_name = current_joint.find("child").attrib["link"]

This error occurs:

  • only when URDF import is used for the second time: multiple manually-built chains seem to work fine
  • whether the involved URDF files are different or not
  • whether the import creates a new Chainobject or overwrites an old one

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.