Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording positions #9

Open
colormotor opened this issue Oct 3, 2023 · 8 comments
Open

Recording positions #9

colormotor opened this issue Oct 3, 2023 · 8 comments

Comments

@colormotor
Copy link

colormotor commented Oct 3, 2023

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

@JeanElsner
Copy link
Owner

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.

@colormotor
Copy link
Author

That's great, many thanks!

@xzhuzhu
Copy link

xzhuzhu commented Oct 9, 2023

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?

@JeanElsner
Copy link
Owner

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.

@xzhuzhu
Copy link

xzhuzhu commented Oct 9, 2023

It works, thanks so much~

@JKBehrens
Copy link

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
Copy link

I found my mistake: It should be:

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

@colormotor
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants