Frankx
0.2.0
A High-Level Motion API for Franka
|
Frankx is a high-level motion library (both C++ and Python) for the Franka Emika robot. It adds a Python wrapper around libfranka, while replacing necessary real-time programming with higher-level motion commands. As frankx focuses on making real-time trajectory generation easy, it allows the robot to react to unforeseen events.
To start using frankx with Python and libfranka 0.9.0, just install it via
Frankx is based on libfranka, Eigen for transformation calculations and pybind11 for the Python bindings. Frankx uses the Ruckig Community Version for Online Trajectory Generation (OTG). As the Franka is quite sensitive to acceleration discontinuities, it requires constrained jerk for all motions. After installing the dependencies (the exact versions can be found below), you can build and install frankx via
To use frankx, you can also include it as a subproject in your parent CMake via add_subdirectory(frankx)
and then target_link_libraries(<target> libfrankx)
. If you need only the Python module, you can install frankx via
Make sure that the built library can be found from Python by adapting your Python Path.
To use frankx within Docker we have supplied a Dockerfile which you currently need to build yourself:
To use another version of libfranka than the default (v.0.7.0) simply change the build argument. Then, to run the container simply:
The container requires access to the host machines network and elevated user rights to allow the docker user to set RT capabilities of the processes run from within it.
Frankx comes with both a C++ and Python API that differ only regarding real-time capability. We will introduce both languages next to each other. In your C++ project, just include include <frankx/frankx.hpp>
and link the library. For Python, just import frankx
. As a first example, only four lines of code are needed for simple robotic motions.
The corresponding program in Python is
Furthermore, we will introduce methods for geometric calculations, for moving the robot according to different motion types, how to implement real-time reactions and changing waypoints in real time as well as controlling the gripper.
frankx::Affine
is a thin wrapper around Eigen::Affine3d. It is used for Cartesian poses, frames and transformation. Frankx simplifies the usage of Euler angles (default ZYX-convention).
In all cases, distances are in [m] and rotations in [rad]. Additionally, there are several helper functions for conversion between Eigen and libfranka's std::array objects. In python, this translates into
As the trajectory generation works in the Euler space, please make sure to have continuous Euler angles around your working point. You can adapt this by setting the flange to end-effector transformation via setEE(...)
.
We wrapped most of the libfanka API (including the RobotState or ErrorMessage) for Python. Moreover, we added methods to adapt the dynamics of the robot for all motions. The rel
name denotes that this a factor of the maximum constraints of the robot.
Frankx defines five different motion types. In python, you can use them as follows:
The real robot can be moved by applying a motion to the robot using move
:
Using MotionData, you can adapt the dynamics (velocity, acceleration and jerk) of a specific motion.
By adding reactions to the motion data, the robot can react to unforeseen events. In the Python API, you can define conditions by using a comparison between a robot's value and a given threshold. If the threshold is exceeded, the reaction fires. Following comparisons are currently implemented
Once a reaction has fired, it will be neglected furthermore. In C++ you can additionally use lambdas to define more complex behaviours:
While the robot moves in a background thread, you can change the waypoints in real-time.
In the frankx::Gripper
class, the default gripper force and gripper speed can be set. Then, additionally to the libfranka commands, the following helper methods can be used:
The Python API should be very straight-forward for the Gripper class.
Frankx includes a rudimentary, non-realtime-capable forward and inverse kinematics.
An auto-generated documentation can be found at https://pantor.github.io/frankx/. Moreover, there are multiple examples for both C++ and Python in the examples directory. We will add a more detailed documentation once frankx reaches v1.0.
Frankx is written in C++17 and Python3.7. It is currently tested against following versions
For non-commercial applications, this software is licensed under the LGPL v3.0. If you want to use frankx within commercial applications or under a different license, please contact us for individual agreements.