stephane-caron / pink

Python inverse kinematics based on Pinocchio
Apache License 2.0
191 stars 12 forks source link

pink installation on mac #5

Closed shbang91 closed 1 year ago

shbang91 commented 1 year ago

Hello Stephan,

Thank you for your effort in maintaining this nice repo!

While using pink, I get the following two questions for you.

  1. I've installed pink on my mac which is intel OSX Monterey 12.5.1 and I am using anaconda virtual environment (python version 3.8). When I tried to run the upkie_crouching.py example, it kept complaining there is no module named pink.models. So, instead of running the script, I manually tried opening the python interpreter(python version 3.8) in the same anaconda environment and typed the code in upkie_crouching.py line by line, and it successfully imported all the modules. I don't know how this could be possible. Do you have anything in your mind?

  2. Other than the aforementioned software issue, I have another question regarding the inverse kinematics solver interface (API). I have a 7-DoF robotic manipulator which has a holonomic constraint (q_1 = q_2) so it has 6 active joints with one passive joint. Given any cartesian tasks, I would like to solve the inverse geometry problem to get the joint positions satisfying the holonomic constraint. In this case, I think one way to solve the problem is by setting the holonomic constraint as a task in the cost function and giving the larger task gain compared to the cartesian task. Another way to solve the problem is using projected jacobian (J_cartesian_task * N_holonomic_constraint) with N = I - JJ_pseudo_inverse. Do you think those two methods sound okay to obtain the solution that I want? If so, can you point out which API in pink I should use to set the holonomic constraint as a cost in the QP (I think I could try the latter one by myself)?

Thank you, Seung Hyeon

stephane-caron commented 1 year ago

I don't have a macOS machine to reproduce your issue 1, but my guess is that it is related to your PYTHONPATH. It's likely when you try to run the example directly you are doing it from a regular terminal (where Anaconda hasn't configured its PYTHONPATH yet), and when you paste the example into the conda interpreter then the path is configured properly and therefore it finds pink.models alright. Something in the line of these questions:

In this case, I think one way to solve the problem is by setting the holonomic constraint as a task in the cost function and giving the larger task gain compared to the cartesian task.

Yes, that would be the first thing to try. This approach will be less sensitive to numerical instability around singularities, compared to the projected Jacobian (and if you get instabilities, you can tune them via costs and LM damping).

Note that you should give the holonomic task a large cost (a.k.a. "weight") rather than a large gain:

shbang91 commented 1 year ago

Thanks for your suggestion! It helps me a lot.