Skip to content

Commit

Permalink
finished example application doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mhubii committed Sep 8, 2024
1 parent 5dfe8ec commit 3471f53
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ See the [examples](examples/).
4. Setup the hardware, see [Hardware Setup](https://lbr-stack.readthedocs.io/en/latest/lbr_fri_ros2_stack/lbr_fri_ros2_stack/doc/hardware_setup.html).

5. Checkout the [example applications](https://lbr-stack.readthedocs.io/en/latest/pyfri/doc/example_applications.html#example-applications).
5. Checkout the [Example Applications](https://lbr-stack.readthedocs.io/en/latest/pyfri/doc/example_applications.html#example-applications).

## Citation
If you enjoyed using this repository for your work, we would really appreciate ❤️ if you could leave a ⭐ and / or cite it, as it helps us to continue offering support.
Expand Down
102 changes: 74 additions & 28 deletions doc/example_applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,37 @@ Collecting Data from the Robot
We provide additional functionality to the LBR client application class that enables data collection to a text file.
In Python, simply add the following

```python
app = fri.ClientApplication(client)
app.collect_data(file_name)
```
.. code-block:: python
app = fri.ClientApplication(client)
app.collect_data(file_name)
The string ``file_name`` should contain the file name for the data file.
We use the comma-separated values format for the data file, and so the file name should end with the extension ``.csv`` - *note*, if this isn't the case then ``.csv`` is automatically appended to the given file name.

The columns in the recorded csv file are as follows:
* ``index``: the index of the recorded data, starts at 0, and is incremented by 1 at each call to the ``step`` method.
* ``time``: the time of the command, starts at 0.0, then is incremented by the sample time at each call to the ``step`` method.
* ``record_time_nsec``: the epoch time collected when the data in the current time step is recorded.
* ``tsec``: controller time as specified by the FRI in seconds. See FRI documentation for ``getTimestampSec``.
* ``tnsec``: controller time as specified by the FRI in nanoseconds. See FRI documentation for ``getTimestampNanoSec``.
* ``mp1, ..., mp7``: The measured joint position for the robot.
* ``ip1, ..., ip7``: The ipo joint position for the robot.
* ``mt1, ..., mt7``: The measured torque for the robot.
* ``et1, ..., et7``: The external torque for the robot.
* ``dt``: The sample time specified on the KUKA controller.

See the [examples/LBRJointSineOverlay.py](examples/LBRJointSineOverlay.py) example that demonstrates how to easily collect data from the robot.

- ``index``: the index of the recorded data, starts at 0, and is incremented by 1 at each call to the ``step`` method.
- ``time``: the time of the command, starts at 0.0, then is incremented by the sample time at each call to the ``step`` method.
- ``record_time_nsec``: the epoch time collected when the data in the current time step is recorded.
- ``tsec``: controller time as specified by the FRI in seconds. See FRI documentation for ``getTimestampSec``.
- ``tnsec``: controller time as specified by the FRI in nanoseconds. See FRI documentation for ``getTimestampNanoSec``.
- ``mp1, ..., mp7``: The measured joint position for the robot.
- ``ip1, ..., ip7``: The ipo joint position for the robot.
- ``mt1, ..., mt7``: The measured torque for the robot.
- ``et1, ..., et7``: The external torque for the robot.
- ``dt``: The sample time specified on the KUKA controller.

See the `LBRJointSineOverlay.py <https://github.com/lbr-stack/pyfri/blob/main/examples/LBRJointSineOverlay.py>`_:octicon:`link-external` example that demonstrates how to easily collect data from the robot.

Example Applications
~~~~~~~~~~~~~~~~~~~~
.. note::
Make sure you followed :doc:`Hardware Setup <../../../lbr_fri_ros2_stack/lbr_fri_ros2_stack/doc/hardware_setup>` first.

.. warning::
Do always execute in ``T1`` mode first.

First, ensure the corresponding Java applications for each example are installed (these were supplied with KUKA Sunrise).
Then turn on the robot, connect your laptop via ethernet, and follow these steps on your laptop.

Expand All @@ -54,6 +61,8 @@ Hand-guiding
^^^^^^^^^^^^
Source code: `hand_guide.py <https://github.com/lbr-stack/pyfri/blob/main/examples/hand_guide.py>`_:octicon:`link-external`

This demos allows the user to hand-guide the robot's end-effector through estimating applied forces via the external joint torques.

#. Remote side configurations:

#. .. dropdown:: Launch the ``LBRServer`` application on the ``KUKA smartPAD``
Expand All @@ -69,10 +78,18 @@ Source code: `hand_guide.py <https://github.com/lbr-stack/pyfri/blob/main/exampl

#. Client side:

.. code-block:: bash
python3 hand_guide.py --lbr-ver 7
Now gently move the robot's end-effector to see the robot follow your movements.

Joint Teleoperation
^^^^^^^^^^^^^^^^^^^
Source code: `joint_teleop.py <https://github.com/lbr-stack/pyfri/blob/main/examples/joint_teleop.py>`_:octicon:`link-external`

This example application lets users control individual joints via the keyboard.

#. Remote side configurations:

#. .. dropdown:: Launch the ``LBRServer`` application on the ``KUKA smartPAD``
Expand All @@ -86,15 +103,20 @@ Source code: `joint_teleop.py <https://github.com/lbr-stack/pyfri/blob/main/exam
- ``FRI control mode``: ``POSITION_CONTROL``
- ``FRI client command mode``: ``POSITION``

#. Client side:
#. On the client side, run:

- ``$ python3 joint_teleop.py``
.. code-block:: bash
python3 joint_teleop.py
Press ``1-7`` to enable / disable the corresponding joint. Press ``left`` / ``right`` arrow keys to move the joint.

Task Teleoperation
^^^^^^^^^^^^^^^^^^
Source code: `task_teleop.py <https://github.com/lbr-stack/pyfri/blob/main/examples/task_teleop.py>`_:octicon:`link-external`

This example application lets users control the end-effector of the robot via the keyboard.

#. Remote side configurations:

#. .. dropdown:: Launch the ``LBRServer`` application on the ``KUKA smartPAD``
Expand All @@ -108,10 +130,18 @@ Source code: `task_teleop.py <https://github.com/lbr-stack/pyfri/blob/main/examp
- ``FRI control mode``: ``POSITION_CONTROL``
- ``FRI client command mode``: ``POSITION``

- ``$ python3 task_teleop.py``
#. On the client side, run:

.. code-block:: bash
python3 task_teleop.py --lbr-ver 7 # or 14 if you are using med14 / iiwa14
Press ``x, y, z, r, p, a`` to enable the a specific axis. Press ``left`` / ``right`` arrow keys to move the axis.

KUKA Default Demos
^^^^^^^^^^^^^^^^^^
These demos mirror the demos that are provided with the C++ FRI client SDK from KUKA, only using the Python bindings instead.

LBR Joint Sine Overlay
""""""""""""""""""""""
Source code: `LBRJointSineOverlay.py <https://github.com/lbr-stack/pyfri/blob/main/examples/LBRJointSineOverlay.py>`_:octicon:`link-external`
Expand All @@ -129,8 +159,13 @@ Source code: `LBRJointSineOverlay.py <https://github.com/lbr-stack/pyfri/blob/ma
- ``FRI control mode``: ``POSITION_CONTROL``
- ``FRI client command mode``: ``POSITION``

- ``$ python3 LBRJointSineOverlay.py # based on examples provided by KUKA``
#. Client side:

.. code-block:: bash
python3 LBRJointSineOverlay.py # based on examples provided by KUKA
You should see joint ``A4`` moving in a sine wave.

LBR Torque Sine Overlay
"""""""""""""""""""""""
Expand All @@ -144,13 +179,18 @@ Source code: `LBRTorqueSineOverlay.py <https://github.com/lbr-stack/pyfri/blob/m

#. Select

- ``FRI send period``: ``10 ms``
- ``FRI send period``: ``2 ms``
- ``IP address``: ``your configuration``
- ``FRI control mode``: ``POSITION_CONTROL``
- ``FRI client command mode``: ``POSITION``
- ``FRI control mode``: ``JOINT_IMPEDANCE_CONTROL``
- ``FRI client command mode``: ``TORQUE``

#. Client side:

- ``$ python3 LBRTorqueSineOverlay.py # based on examples provided by KUKA``
.. code-block:: bash
python3 LBRTorqueSineOverlay.py # based on examples provided by KUKA
You should see joint ``A4`` moving in a sine wave.

LBR Wrench Sine Overlay
"""""""""""""""""""""""
Expand All @@ -164,9 +204,15 @@ Source code: `LBRWrenchSineOverlay.py <https://github.com/lbr-stack/pyfri/blob/m

#. Select

- ``FRI send period``: ``10 ms``
- ``FRI send period``: ``2 ms``
- ``IP address``: ``your configuration``
- ``FRI control mode``: ``POSITION_CONTROL``
- ``FRI client command mode``: ``POSITION``
- ``FRI control mode``: ``CARTESIAN_IMPEDANCE_CONTROL``
- ``FRI client command mode``: ``WRENCH``

#. Client side:

.. code-block:: bash
python3 LBRWrenchSineOverlay.py # based on examples provided by KUKA
- ``$ python3 LBRWrenchSineOverlay.py # based on examples provided by KUKA``
You should see the end-effector circulating.
1 change: 0 additions & 1 deletion examples/hand_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def waitForCommand(self):
)
raise SystemExit

self.wrench_estimator.update()
self.q = self.robotState().getIpoJointPosition()
self.command_position()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def build_extension(self, ext: CMakeExtension) -> None:

setup(
name="pyfri",
version="1.2.0",
version="1.2.1",
author="Christopher E. Mower, Martin Huber",
author_email="[email protected], [email protected]",
description="Python bindings for the FRI Client SDK library.",
Expand Down

0 comments on commit 3471f53

Please sign in to comment.