krishauser / Klampt

Kris' Locomotion and Manipulation Planning Toolkit
BSD 3-Clause "New" or "Revised" License
377 stars 96 forks source link

How to attach link/geometry from different "robot"? #107

Closed clemense closed 3 years ago

clemense commented 3 years ago

Hi, I'm populating my world with two "robots" (one manipulator, and one articulated description of the environment). I would like to attach a particular link from the environment (potentially a link connected by a floating joint) to the manipulator. Unfortunately, the setParent(..) method Can't set a link to have a parent on a different robot. How can I achieve my goal?

Thanks!

krishauser commented 3 years ago

RobotModels are limited in how much you can mix-and-match links between robots. The main way to accomplish something like what you are doing is the RobotModel.mount() function, which allows you to add a robot as a child of another robot. This is usually done when mounting a gripper to an arm, or an arm to a base, for example.

There are currently no plans to add link-specific transfer functionality to the Python API. Such a routine would have to be very complex to deal with the possible options of how to deal with the robot configuration, the descendant links, and link drivers which can group together multiple links.

clemense commented 3 years ago

Ah, thanks! A quick follow-up: I actually just need to add a rigid object to the end-effector (to plan a collision-free path). Is the easiest way to achieve this by setting the geometry of the end-effector as a GeometryGroup and adding the geometry of the object? I think I'm looking e.g. for a Python version of this tutorial part https://github.com/krishauser/Klampt/blob/master/Cpp/docs/Tutorials/Grasp-object.md#planning-transfer-and-ungrasping-paths which says "Coming soon" (the link for the tutorial code also seems to be outdated, I can't find pickandplace.cpp anywhere).

krishauser commented 3 years ago

It’s easiest to make a Group geometry. Something like this should work, attaching the object geometry in its current pose relative to the link’s current pose.

link = robot.link(name) lgeom = link.geometry() lxform = link.getTransform() ogeom= object.geometry().copy() #dont modify object’s actual geometry oxform = object.getTransform() relxform = se3.mul(se3.inv(lxform),oxform) ogeom.transform(*relxform) group = Geometry3D() group.setGroup() group.setElement(0,lgeom) group.setElement(1,ogeom) link.geometry().set(group)

clemense commented 3 years ago

Great, thanks! Tiny change I had to make: object.geometry().clone() instead of object.geometry().copy().