cambel / ur_ikfast

Python IKFast library for Universal Robots
MIT License
85 stars 18 forks source link

Find joint angles to closest end effector pose in workspace #8

Closed richardrl closed 2 months ago

richardrl commented 4 months ago

Is there a way to use this library to find the joint angles for the closest end effector pose in the workspace compared to a target end effector pose?

cambel commented 4 months ago

@richardrl Hi, I am not sure what you need exactly regarding the "closest end-effector pose in the workspace". However, as long as you have a desired end-effector pose, then yes, you can use this library to find the joint angles. In other words, it won't choose an end-effector pose for you. But given one, it can find the joint angles.

richardrl commented 4 months ago

@cambel Hey, my point is many desired end effector poses are outside the ur workspace and this library returns “None”.

for example, I recorded with motion capture trajectories of human wrists manipulating objects and tried to use this library for IK, but it just kept returning None

cambel commented 4 months ago

@richardrl

many desired end effector poses are outside the ur workspace

I am still not sure what you are trying to do. The libraries here consider the poses from the UR's base_link to the tool0. If you want to consider a different link as the end-effector, such as the tip of the gripper. You are tracking the gripper pose for your given task and you want to know the IK solution for some pose in tcp, then, you need to compute the transformation between such gripper -> tool0 and only then use this library to compute the IK.

richardrl commented 4 months ago

I am trying to servo the end effector to the closest end effector pose to a target end effector pose (where closeness is defined by a L2-norm metric over the transformation matrices) within the kinematic workspace of the UR3e.

If I give you some pose $X \in \mathbb{R}^{4 \times 4}$ if the pose is not in the workspace, the current library returns None. That is not my desired behavior, I want to return a pose within the workspace that is closest in L2 norm to my desired pose.

By workspace, I mean the set of all reachable task space poses. Many poses are not reachable, i.e. there is no joint angle that exactly equals that pose via forward kinematics.

cambel commented 4 months ago

Right, that is not within the scope of this library. It only works within the robot's workspace.

You need to compute that "reachable" pose first, then use this library, otherwise you won't get an IK solution.

If you find a suitable solution for your problem, feel free to document it here in case other people would like to follow in your steps.

richardrl commented 4 months ago

I see - do you know of any works that try to project the pose into reachable workspace - any references?

cambel commented 4 months ago

I don't know any library that does that but just projecting it does not seem too difficult if you manually define the reachable workspace of the robot and then compute the closest point to the given pose.

However, it seems to me that projecting the pose into the reachable workspace is not what you really want to be doing. It does not seem particularly useful IMHO.

I recorded with motion capture trajectories of human wrists manipulating objects

From the description of your application, you have a mismatch of perhaps the reachability of the UR3e robot to that of the human arm. Instead of projecting the given poses to the closes in the reachable workspace, it may be more useful to manipulate the entire trajectory to lie within the reachable workspace by for example, uniformly scaling the distance of each point to the shoulder of the human/robot.