
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/robolab/example_inverse_kinematics.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_robolab_example_inverse_kinematics.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_robolab_example_inverse_kinematics.py:


IK from models
========================

Inverse kinematics from URDF or MuJoCo XML files.

.. GENERATED FROM PYTHON SOURCE LINES 7-26

.. code-block:: default


    import rofunc as rf

    rf.logger.beauty_print("########## Inverse kinematics from URDF or MuJoCo XML files with RobotModel class ##########")
    rf.logger.beauty_print("---------- Inverse kinematics for Franka Panda using URDF file ----------")
    model_path = "../../rofunc/simulator/assets/urdf/franka_description/robots/franka_panda.urdf"

    ee_pose = [0, 0, 0, 0, 0, 0, 1]
    export_link = "panda_hand"
    robot = rf.robolab.RobotModel(model_path, solve_engine="pytorch_kinematics", verbose=True)

    # Get ik solution
    ret = robot.get_ik(ee_pose, export_link)
    print(ret.solutions)

    # Get ik solution near the current configuration
    cur_configs = [[-1.7613,  2.7469, -3.5611, -3.8847,  2.7940,  1.9055,  1.9879]]
    ret = robot.get_ik(ee_pose, export_link, cur_configs=cur_configs)
    print(ret.solutions)


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.000 seconds)


.. _sphx_glr_download_examples_robolab_example_inverse_kinematics.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example




    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: example_inverse_kinematics.py <example_inverse_kinematics.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: example_inverse_kinematics.ipynb <example_inverse_kinematics.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
