panda-py icon indicating copy to clipboard operation
panda-py copied to clipboard

Recording positions

Open colormotor opened this issue 1 year ago • 8 comments

Hi, first of all thanks for the work! I want to record the robot pose while "teaching", is there a suggested way or examples on how to do this with panda-py? I currenly am getting the the pose with panda.get_robot().read_once().O_T_EE

colormotor avatar Oct 03 '23 14:10 colormotor

Hi there! There is a teaching mode that can be activated by calling panda.teaching_mode(True). This will basically only run gravity compensation and allows you to move the robot freely, similarly to the built-in guiding mode. There are also short-hands to read the joint positions or pose, i.e. panda.q and panda.get_pose(). The later will directly return a 4 by 4 numpy array representing the end-effector pose. However, all the short-hands as well as panda.get_state()are only updated while controllers, motion generators or teaching mode is active. By calling read_once directly, the current state will be retrieved, even without an active controller.

I added a simple example to show how to simply read positions and record a trajectory and play them back. The example is in joint space but the same principle applies to Cartesian poses.

JeanElsner avatar Oct 05 '23 00:10 JeanElsner

That's great, many thanks!

colormotor avatar Oct 07 '23 11:10 colormotor

Thanks for your great work! Now my robot is holding a extra load, how can I compensate the gravity of the load when doing teaching? Then when I am doing the impedance control, how can I change the impedance?

xzhuzhu avatar Oct 09 '23 08:10 xzhuzhu

You can set the load by calling Panda.get_robot().set_load(). This function uses the libfranka interface to set the end-effector load, i.e. mass, COM and inertia matrix. This is applied while running all controllers - including teaching mode and impedance control. Impedance for the CartesianImpedance controller can be set in the constructor or by calling CartesianImpedance.set_impedance(). However, if properly configured, you shouldn't need to adapt the impedance to compensate the load.

JeanElsner avatar Oct 09 '23 09:10 JeanElsner

It works, thanks so much~

xzhuzhu avatar Oct 09 '23 12:10 xzhuzhu

Hi @JeanElsner,

thanks for the great work!

robot = panda_py.Panda(hostname)
robot.read_once()

I get

INFO:panda:Connected to robot (192.168.88.140).
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[75], line 2
      1 robot = panda_py.Panda(hostname)
----> 2 robot.read_once()

AttributeError: 'panda_py._core.Panda' object has no attribute 'read_once'

For the gripper, read_once works as expected.

I installed panda_py via pip.

Thank you for a hint how to call read_once() to get a current robot state.

Best, Jan

JKBehrens avatar Oct 24 '23 11:10 JKBehrens

I found my mistake: It should be:

robot = panda_py.Panda(hostname)
state = robot.get_robot().read_once()

JKBehrens avatar Oct 24 '23 16:10 JKBehrens

Hi, regarding my first question, while panda.teaching_mode(True) works great, it can be useful to take advantage of the guiding mode settings in the desk programming mode and then use read_once() to retrieve the current robot configuration. While I can set guiding modes programmatically through the robot interface and set execution vs. programming mode in the Desk UI , are you aware if it possible to switch between these modes using the Desk object?

colormotor avatar Nov 07 '23 14:11 colormotor