Error "Does your IK Solver support approximate IK ?" Moveit!
Hello,
I am trying to write a script using move_group in order to move a custom robot in Moveit!. Using the joints as targets works perfectly, bu I have an issue when I try to target a pose, I get this error and the robot doesn't move :
Traceback (most recent call last):
File "/home/edith/catkinws/src/testmoveit/scripts/test.py", line 84, inmovegroup.setjointvaluetarget(posegoal, "linkeff",True) File "/opt/ros/melodic/lib/python2.7/dist-packages/moveitcommander/movegroup.py", line 219, in setjointvaluetarget raise MoveItCommanderException("Error setting joint target. Does your IK solver support approximate IK?") moveitcommander.exception.MoveItCommanderException: Error setting joint target. Does your IK solver support approximate IK?
I use ROS melodic on a virtual machine with Ubuntu 18.04. My robot is a RRR robot (3DOF) and I use an IKFast solver, with parameter "TranslationXY2D".
I follow this tutorial : https://ros-planning.github.io/moveit_tutorials/doc/move_group_python_interface/move_group_python_interface_tutorial.html
Instead of
movegroup.setposetarget(posegoal)
I used
movegroup.setjointvaluetarget(posegoal, "linkeff",True)
Because this instruction allows IK approximate solutions with the boolean "True", unlike the other one : http://docs.ros.org/jade/api/moveit_commander/html/classmoveit__commander_1_1move__group_1_1MoveGroupCommander.html#a55db2d061bbf73d05b9a06df7f31ea39
I know that the pose asked is reachable by the robot arm. At this point I don't know what else I can do, so thank to those who will take some time to answer ! Please find the URDF file and the concerned code. The URDF was generated from Solidworks with the exporter SW2URDF.
Code :
import sys import copy import rospy import moveitcommander import moveitmsgs.msg import math import time import stdmsgs.msg import geometrymsgs.msg import moveit_commander.conversions
moveitcommander.roscppinitialize(sys.argv)
rospy.initnode('movegrouppythoninterface_tutorial', anonymous=True)
robot = moveit_commander.RobotCommander()
groupname = "Arm" movegroup = moveitcommander.MoveGroupCommander(groupname)
jointgoal = movegroup.getcurrentjoint_values()
jointgoal[0] = 0.1744 jointgoal[1] = 0 jointgoal[2] = 0.3489 movegroup.go(jointgoal, wait=True) movegroup.stop()
posegoal = movegroup.getcurrentpose()
time.sleep(0.5) posegoal.pose.orientation.w = 1.0 time.sleep(0.5) posegoal.pose.position.x = 0.671 time.sleep(0.5) pose_goal.pose.position.y = -0.667
movegroup.setjointvaluetarget(posegoal, "linkeff",True)*
URDF :
<?xml version="1.0" encoding="utf-8"?>
<robot
name="swurdf">
<link
name="base_link">
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/base_link.STL" />
</geometry>
<material
name="">
<color
rgba="1 0 0 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/base_link.STL" />
</geometry>
</collision>
<link
name="link_1">
<inertial>
<origin
xyz="0.19475 -1.4951E-18 6.6018E-18"
rpy="0 0 0" />
<mass
value="60" />
<inertia
ixx="0.0084601"
ixy="3.2514E-18"
ixz="5.5791E-19"
iyy="0.062842"
iyz="3.9785E-19"
izz="0.069912" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_1.STL" />
</geometry>
<material
name="">
<color
rgba="0 1 0 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_1.STL" />
</geometry>
</collision>
<joint
name="J1"
type="revolute">
<origin
xyz="0 0 0"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="link_1" />
<axis
xyz="0 0 -1" />
<limit
lower="-0.349"
upper="0.1745"
effort="1000"
velocity="0.1745" />
<link
name="link_2">
<inertial>
<origin
xyz="0.2353 -5.5511E-17 3.6564E-18"
rpy="0 0 0" />
<mass
value="50" />
<inertia
ixx="0.012036"
ixy="1.4745E-17"
ixz="-2.5398E-18"
iyy="0.11576"
iyz="-4.117E-19"
izz="0.12386" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_2.STL" />
</geometry>
<material
name="">
<color
rgba="0 0 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_2.STL" />
</geometry>
</collision>
<joint
name="J2"
type="revolute">
<origin
xyz="0.3895 0 0"
rpy="0 0 -0.37437" />
<parent
link="link_1" />
<child
link="link_2" />
<axis
xyz="0 0 -1" />
<limit
lower="-0.349"
upper="0"
effort="1000"
velocity="0.1745" />
<link
name="link_3">
<inertial>
<origin
xyz="-0.17974 2.2204E-16 9.2478E-18"
rpy="0 0 0" />
<mass
value="55" />
<inertia
ixx="0.0089046"
ixy="9.541E-18"
ixz="4.0602E-20"
iyy="0.060983"
iyz="-3.5161E-19"
izz="0.066959" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_3.STL" />
</geometry>
<material
name="">
<color
rgba="0 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_3.STL" />
</geometry>
</collision>
<joint
name="J3"
type="revolute">
<origin
xyz="0.48 0 0"
rpy="3.1416 0 2.1331" />
<parent
link="link_2" />
<child
link="link_3" />
<axis
xyz="0 0 1" />
<limit
lower="-0.349"
upper="0.349"
effort="1000"
velocity="0.1745" />
<link
name="link_eff">
<inertial>
<origin
xyz="-0.18691 -0.035548 -1.5796E-17"
rpy="0 0 0" />
<mass
value="0" />
<inertia
ixx="0.010723"
ixy="-0.0095589"
ixz="-3.6746E-20"
iyy="0.059165"
iyz="4.3033E-19"
izz="0.066959" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_eff.STL" />
</geometry>
<material
name="">
<color
rgba="0 1 1 0" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://swurdf/meshes/link_eff.STL" />
</geometry>
</collision>
<joint
name="JE"
type="fixed">
<origin
xyz="-0.37 0 0"
rpy="3.1416 0 -2.9536" />
<parent
link="link_3" />
<child
link="link_eff" />
<axis
xyz="0 0 0" />
Asked by edote on 2020-03-05 11:43:11 UTC
Answers
Answering my own question : the solvers provided by Moveit are not adapted for robots wich don't have 6 DOF. It is possible to generate an analytical solver with IKFast http://docs.ros.org/melodic/api/moveit_tutorials/html/doc/ikfast/ikfast_tutorial.html
Asked by edote on 2020-05-22 09:54:18 UTC
Comments
It is possible to generate an analytical solver with TracIK http://wiki.ros.org/trac_ik
Aren't you thinking of IKFast instead?
TracIK does not generate any solvers (depending on how you define the term "generate").
Asked by gvdhoorn on 2020-05-23 03:40:47 UTC
Yes you're right, thanks I'll edit it
Asked by edote on 2020-05-25 02:00:48 UTC
@edote I also reach the problem of "Allow Aprox IK solutions" in a python program. But i belive there is something wrong in your own answer. If the problem is the IK plugin why we can use the rviz marker to calculate it?
In the following links they say the issue is solved with that method:
- https://groups.google.com/forum/#!topic/moveit-users/h75nDpwOKLk
- https://answers.ros.org/question/329107/moveit-approximate-ik-solutions/
Asked by inaciose on 2020-05-25 17:50:38 UTC
@inaciose In my case I can't use the rviz marker. I saw these answers but they didn't help me. I think it depends of your robot, I had a 3 DOF arm with non orthogonal axis. I had issues with IKFast but it is the only solver that gave me a result.
Asked by edote on 2020-06-02 05:05:01 UTC
Your arg2 is bad. You should not use the end effector, but the link in the arm that connect to the end effector. If should you use: move_group.set_joint_value_target(pose_goal, "link_3",True)
Asked by inaciose on 2020-05-25 18:33:34 UTC
Comments
Hello! Were you by chance able to find a solution to this?
Asked by Ryan P on 2020-05-15 16:26:53 UTC
Hello, I found out that the solvers provided by moveit are designed to work with verry common robot models. They are optimized for 6 DOF robots, for other models it is more complicated. You should use TracIK to generate a custom solver if your robot doesn't have 6 DOF. And when you manipulate it by hand in Rviz you should always check "Allow Approx IK Solutions" in MotionPlanning -> Planning. My robot is a special one, it has less than 6 DOF and it doesn't have orthogonal axes. My colleague adapted an existing solver and she is testing it.
Asked by edote on 2020-05-22 09:51:26 UTC