If you have a 5DOF arm and keep the target pose orientation within the reachable space of your arm, IK should work. If however, you for example rotate the target pose around the axis of the missing sixth DOF (if it's rotational), IK will naturally fail.
I can recommend the OpenRAVE ikfast module and it's 'TranslationDirection5D' IK option for such a scenario. It is also shortly talked about here.
I documented how I generated the IK for our 5DOF arm, so here goes:
Generating a OpenRAVE-Collada robot model (assumes you have OpenRAVE installed):
roscd hector_arm_urdf/urdf
rosrun xacro xacro.py hector_arm_ax12_5dof_standalone.xacro > hector_arm_ax12_5dof_standalone.urdf
rosrun collada_urdf urdf_to_collada hector_arm_ax12_5dof_standalone.urdf hector_arm_ax12_5dof_standalone.dae
In the next step, a OpenRAVE scene description file has to be created in the same directory. For this example, this would be "hector_arm_ax12_5dof_standalone.xml". With following contents:
<Robot name="hector_arm_ax12_5dof_standalone" file="hector_arm_ax12_5dof_standalone.dae">
<Manipulator name="hector_arm_5dof">
<base>arm_base_link</base>
<effector>endeffector_yaw_link</effector>
<direction>1 0 0</direction>
<translation>0 0 0</translation>
</Manipulator>
</Robot>
You can do a visual inspection of the model by starting OpenRAVE and then loading the OpenRAVE scene description XML file created above. The endeffector should look as described here when using the red arrow tool to the top right and clicking on the robot.
roscd openrave/bin
export PYTHONPATH=$PYTHONPATH:`./openrave-config --python-dir`
./openrave.py
Finally, generating 5DOF IK:
roscd openrave/bin
export PYTHONPATH=$PYTHONPATH:`./openrave-config --python-dir`
./openrave.py --database inversekinematics --robot=/home/stefan/rosext/hector/ros/stacks/hector_arm/hector_arm_urdf/urdf/hector_arm_ax12_5dof_standalone.xml --iktype=TranslationDirection5D
The generated IK library or .cpp can then be used for calculating inverse kinematics in ROS. This of course is an option that needs a little more effort than relying on the KDL based iterative solver provided with the ROS tools.
Originally posted by Stefan Kohlbrecher with karma: 24361 on 2012-02-01
This answer was ACCEPTED on the original site
Post score: 6
Original comments
Comment by Rosen Diankov on 2012-02-02:
check to see if your STL file is binary. if it is, the first 5 letters cannot be 'solid'
Comment by Fei Liu on 2012-02-02:
Hi, Sefan, Thank you for your detailed explanation. I almost go through everything you suggest. I have a problem in using the mesh for my manipulator, I got "failed to load resource package://cob_description/ros/meshes/arm_v0/arm2.stl" when I try to generate urdf to collada. How you run your mesh?
Comment by Rosen Diankov on 2012-02-01:
Hi Stefan, excellent answer! In openrave changes a couple of hours ago, we increased the katana arm ik success rate by 15%. Also, you can bring in all of openrave to your shell by adding the following (recommended) line: source rospack find openrave
/openrave_svn/openrave.bash rospack find openrave
Comment by mirsking on 2014-10-02:
Hi, Rosen, I've met the same problem of "failed to load resource package", and my STL file is binary with the first 5 letters being 'solid'. But after I delete the 5 letters 'solid', it still doesn't work. How can I solve this problem?
Comment by BrettHemes on 2016-05-05:
This is an old question but thought I would post a reference to an answer for the "solid" issue from here:
Just go to the folder with STL's with this problem and do:
sed -i 's/^solid/robot/' *