# Solving inverse kinematics for special configuration (IKFast)

I'm trying to solve the inverse kinematics problem for a custom made robot arm. The robot arm has a special design with the following 5 DoF in serial configuration:

• x-axis prismatic joint
• y-axis prismatic joint
• revolute joint about z-axis
• revolute joint about x-axis
• z-axis prismatic joint

Therefore, I can not reach every configuration in space, namely I'm limited in one of the end-effector angles. For better understanding of the model, I added the URDF at the end.

I was trying to use IKFast to generate an inverse kinematics .cpp file. But when using IK Type "Transform6D" I get an error:

CannotSolveError: need 6 joints


I must admit that it's not totally clear for me what this IK Types mean. I know how to calculate kinematics and inverse kinematics by hand and I can not imagine why this IK Type should matter.

Even trying "TranslationDirection5D" did results in:

CannotSolveError: raghavan roth equations too complex


So I'm wondering if IKFast can solve my problem or how I can do it. I just need the inverse kinematics calculations as "stand alone" (for simplicity) which I will then use in my ROS node. I was following this tutorial:

http://wiki.ros.org/Industrial/Tutorials/Create_a_Fast_IK_Solution

URDF file (Link 7 is just a tool frame with fixed Joint 6):

<robot name="or_robot">
<link name="link1" />
<link name="link2" />
<link name="link3" />
<link name="link4" />
<link name="link5" />
<link name="link6" />
<link name="link7" />

<joint name="joint1" type="prismatic">
<parent link="link1"/>
<child link="link2"/>
<origin xyz="0 0 0.2" rpy="0 0 0" />
<axis xyz="0 1 0" />
<limit effort="1000.0" lower="0.0" upper="0.05" velocity="0.5"/>
</joint>

<joint name="joint2" type="prismatic">
<parent link="link2"/>
<child link="link3"/>
<origin xyz="0 0 0" rpy="0 0 0" />
<axis xyz="1 0 0" />
<limit effort="1000.0" lower="0.0" upper="0.05" velocity="0.5"/>
</joint>

<joint name="joint3" type="revolute">
<parent link="link3"/>
<child link="link4"/>
<origin xyz="0 0 0" rpy="0 0 0" />
<axis xyz="0 0 1" />
<limit effort="1000.0" lower="-0.4" upper="1.57" velocity="0.5"/>
</joint>

<joint name="joint4" type="revolute">
<parent link="link4"/>
<child link="link5"/>
<origin xyz="0.1 0 0" rpy="0 0.2618 0" />
<axis xyz="0 1 0" />
<limit effort="1000.0" lower="0.0" upper="0.785" velocity="0.5"/>
</joint>

<joint name="joint5" type="prismatic">
<parent link="link5"/>
<child link="link6"/>
<origin xyz="0 0 -0.05" rpy="0 0 0" />
<axis xyz="0 0 -1" />
<limit effort="1000.0" lower="0.0" upper="0.048" velocity="0.5"/>
</joint>

<joint name="joint6" type="fixed">
<parent link="link6"/>
<child link="link7"/>
<origin xyz="0 0 -0.02" rpy="0 0 0" />
</joint>

</robot>


Edit: changed units

Originally posted by prex on ROS Answers with karma: 151 on 2018-06-15

Post score: 1

### Original comments

Comment by gvdhoorn on 2018-06-15:
Just a note: you have a robot spanning a volume of 50 by 50 by 48 metres? And the links are 20, 50, 100 and 200 metres apart?

Comment by gvdhoorn on 2018-06-15:\

I know how to calculate kinematics and inverse kinematics by hand and I can not imagine why this IK Type should matter.

So can you tell me then how to solve for an arbitrary 6D pose with a 5dof robot?

Comment by gvdhoorn on 2018-06-15:\

I just need [..]

Be careful with these types of 'just' sentences. They are typically not as simple as they may seem.

Comment by prex on 2018-06-15:
Ups, I was looking for units and couldn't find anything. So I was expecting mm. But this shouldn't be the problem. Will change it.

I was not expecting it to work for arbitrary 6D poses. But you are right. It can not work with a closed form solution which is generated by IKFast.

Comment by gvdhoorn on 2018-06-15:\

I was looking for units and couldn't find anything.

Everything in ROS is SI units (REP-103). That includes URDF.

Comment by gvdhoorn on 2018-06-16:\

It can not work with a closed form solution which is generated by IKFast.

if you mean: ikfast can't work for your robot in general, then I would not necessarily agree with that. I've generated IKFast plugins for 5dof robots in the past.

Comment by prex on 2018-06-16:
I mean it can't work with the "transform6D" mode because of closed form. I also tried to add an additional revolute link for the 6D solution. But I always get "too complex" errors.

Comment by prex on 2018-06-16:
Then can you tell me which parameters to alter or how to do it? I can just choose the IK Type.

Comment by gvdhoorn on 2018-06-17:
Please see the procedure in #q263925. Don't add any dummy joints. It should not be needed. And if you have a 5dof robot, make sure it supports the TranslationDirection5D ik type.

Also: fix your urdf to use the proper units, and make sure it's correct.

Comment by prex on 2018-06-17:
Tried to change my urdf according to Denavit-Hartenberg conventions. Still the same problem. I often get errors as "equation too complex to simplify for rot norm" or "are not all rotational, is this really necessary". I did lower the decimal places of the .dae before.

## 1 Answer

Not sure if this counts as an answer, but I solved my issue by using Orocos KDL library instead of IKFast. IKFast couldn't find a closed form solution. So I was expecting a numerical solver to work better. And KDL obviously did the job.

Originally posted by prex with karma: 151 on 2018-06-24

This answer was ACCEPTED on the original site

Post score: 1

### Original comments

Comment by gvdhoorn on 2018-06-24:
If a numerical solution is good enough, I'd advise you to look at trac_ik. It's much more performant and has a much higher solve rate than KDL.

Comment by prex on 2018-06-24:
Thanks, I will consider that for the final version. But at the moment KDL seems to be very fast for my application.

Comment by gvdhoorn on 2018-06-24:
trac_ik is faster, always. And has a higher solve rate + solutions will be more accurate. Check the paper + website.

Comment by ddl_hust on 2019-05-05:
thank you I have to accpet this solution

Comment by cv_ros_user on 2020-12-01:
TRAC-IK performs a lot better than default KDL IK solver in my use case (8 dof robot).

It is as simple as installing the corresponding ROS package and using the MoveIt setup assistant to use trac_ik_kinematics_plugin/TRAC_IKKinematicsPlugin.