Skip to main content

Online Trajectory Generation. Real-time. Time-optimal. Jerk-constrained.

Project description

Ruckig

Online Trajectory Generation. Real-time. Time-optimal. Jerk-constrained.

CI Issues Releases LGPL

Ruckig calculates a time-optimal trajectory given a target waypoint with position, velocity, and acceleration starting from any initial state limited by velocity, acceleration, and jerk constraints. Ruckig is a more powerful and open-source alternative to the Reflexxes Type IV library. In fact, Ruckig is the first Type V trajectory generator and even supports directional velocity and acceleration limits, while also being faster on top. For robotics and machining applications, Ruckig allows both instant reactions to unforeseen events as well as simple offline trajectory planning.

Installation

Ruckig has no dependencies (except for testing). To build Ruckig using CMake, just run

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make

To install Ruckig in a system-wide directory, use (sudo) make install. An example of using Ruckig in your CMake project is given by examples/CMakeLists.txt. However, you can also include Ruckig as a directory within your project and call add_subdirectory(ruckig) in your parent CMakeLists.txt. A Python module can be built using the BUILD_PYTHON_MODULE CMake flag.

Tutorial

Furthermore, a tutorial will explain the basics to include online generated trajectories within your application. A working example can be found in the examples directory. A time-optimal trajectory for a single degree of freedom is shown in the figure below.

Trajectory Profile

Waypoint-based Trajectory Generation

Ruckig provides three main interface classes: the Ruckig, the InputParameter, and the OutputParameter class.

First, you'll need to create a Ruckig instance with the number of DoFs as a template parameter, and the control cycle (e.g. in seconds) in the constructor.

Ruckig<6> ruckig {0.001}; // Number DoFs; control cycle in [s]

The input type has 3 blocks of data: the current state, the target state and the corresponding kinematic limits.

InputParameter<6> input; // Number DoFs
input.current_position = {0.2, ...};
input.current_velocity = {0.1, ...};
input.current_acceleration = {0.1, ...};
input.target_position = {0.5, ...};
input.target_velocity = {-0.1, ...};
input.target_acceleration = {0.2, ...};
input.max_velocity = {0.4, ...};
input.max_acceleration = {1.0, ...};
input.max_jerk = {4.0, ...};

OutputParameter<6> output; // Number DoFs

Given all input and output resources, we can iterate over the trajectory at each discrete time step. For most applications, this loop must run within a real-time thread and controls the actual hardware.

while (ruckig.update(input, output) == Result::Working) {
  // Make use of the new state here!

  input.current_position = output.new_position;
  input.current_velocity = output.new_velocity;
  input.current_acceleration = output.new_acceleration;
}

During your update step, you'll need to copy the new kinematic state into the current state. If the current state is not the expected, pre-calculated trajectory, ruckig will calculate a new trajectory with the novel input. When the trajectory has reached the target state, the update function will return Result::Finished.

Input Parameter

To go into more detail, the InputParameter type has following members:

using Vector = std::array<double, DOFs>;

Vector current_position;
Vector current_velocity; // Initialized to zero
Vector current_acceleration; // Initialized to zero

Vector target_position;
Vector target_velocity; // Initialized to zero
Vector target_acceleration; // Initialized to zero

Vector max_velocity;
Vector max_acceleration;
Vector max_jerk;

std::optional<Vector> min_velocity; // If not given, the negative maximum velocity will be used.
std::optional<Vector> min_acceleration; // If not given, the negative maximum acceleration will be used.

std::array<bool, DOFs> enabled; // Initialized to true
std::optional<double> minimum_duration;

Interface interface; // The default position interface controls the full kinematic state.
Synchronization synchronization; // Synchronization behavior of multiple DoFs
DurationDiscretization duration_discretization; // Whether the duration should be a discrete multiple of the control cycle (off by default)

Members are implemented using the C++ standard array and optional type. Note that there are range constraints due to numerical reasons, see below for more details. To check the input before a calculation step, the ruckig.validate_input(input) method returns false if an input is not valid. Of course, the target state needs to be within the given kinematic limits. Additionally, the target acceleration needs to fulfil

Abs(target_acceleration) <= Sqrt(2 * max_jerk * (max_velocity - Abs(target_velocity)))

If a DoF is not enabled, it will be ignored in the calculation. A minimum duration can be optionally given. Furthermore, the minimum velocity and acceleration can be specified. If it is not given, the negative maximum velocity or acceleration will be used (similar to the jerk limit). For example, this might be useful in human robot collaboration settings with a different velocity limit towards a human. Or, the dynamic limits at a given configuration of the robot can be approximated much better with different acceleration limits.

Furthermore, there are some options for advanced functionality, e.g. for velocity control or discrete trajectory durations. We refer to the API documentation of the enumerations within the ruckig namespace for all available options.

Result Type

The update function of the Ruckig class returns a Result type that indicates the current state of the algorithm. Currently, this can either be working, finished if the trajectory has finished, or an error type if something went wrong during calculation. The result type can be compared as a standard integer.

State Error Code
Working 0
Finished 1
Error -1
ErrorInvalidInput -100
ErrorTrajectoryDuration -101
ErrorExecutionTimeCalculation -110
ErrorSynchronizationCalculation -111

Output Parameter

The output class gives the new kinematic state of the trajectory.

Vector new_position;
Vector new_velocity;
Vector new_acceleration;

bool new_calculation; // Whether a new calculation was performed in the last cycle
double calculation_duration; // Duration of the calculation in the last cycle [µs]

Trajectory trajectory; // The current trajectory
double time; // The current, auto-incremented time. Reset to 0 at a new calculation.

Moreover, the trajectory class has a range of useful parameters and methods.

double duration; // Duration of the trajectory
std::array<double, DOFs> independent_min_durations; // Time-optimal profile for each independent DoF

<...> at_time(double time); // Get the kinematic state of the trajectory at a given time
<...> get_position_extrema(); // Returns information about the position extrema and their times

Again, we refer to the API documentation for the exact signatures.

Tests and Numerical Stability

The current test suite validates over 1.000.000.000 random trajectories. The numerical exactness is tested for the final position and final velocity to be within 1e-8, for the velocity, acceleration and jerk limit to be within 1e-12, and for the final acceleration as well to be within a numerical error of 1e-12. The maximal supported trajectory duration is 7e3, which sounds short but should suffice for most applications seeking for time-optimality. Note that Ruckig will also output values outside of this range, there is however no guarantee for correctness.

Benchmark

We find that Ruckig is around twice as fast as Reflexxes Type IV and well-suited for control cycles as low as half a millisecond.

Benchmark

Development

Ruckig is written in C++17. It is continuously tested on ubuntu-latest, macos-latest, and windows-latest against following versions

  • Doctest v2.4 (only for testing)
  • Pybind11 v2.6 (only for python wrapper)

Citation

A publication is submitted ;)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ruckig-0.2.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ruckig-0.2.2-cp39-cp39-manylinux2010_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ x86-64

ruckig-0.2.2-cp39-cp39-manylinux1_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.9

ruckig-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl (50.4 kB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

ruckig-0.2.2-cp38-cp38-manylinux2010_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

ruckig-0.2.2-cp38-cp38-manylinux1_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.8

ruckig-0.2.2-cp38-cp38-macosx_10_15_x86_64.whl (50.4 kB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

ruckig-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

ruckig-0.2.2-cp37-cp37m-manylinux1_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.7m

ruckig-0.2.2-cp37-cp37m-macosx_10_15_x86_64.whl (50.4 kB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

ruckig-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

ruckig-0.2.2-cp36-cp36m-manylinux1_x86_64.whl (82.1 kB view details)

Uploaded CPython 3.6m

ruckig-0.2.2-cp36-cp36m-macosx_10_15_x86_64.whl (50.4 kB view details)

Uploaded CPython 3.6mmacOS 10.15+ x86-64

File details

Details for the file ruckig-0.2.2.tar.gz.

File metadata

  • Download URL: ruckig-0.2.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2bc86f4b8e9989c40e0161df6f0d6ed5ea018f617d73b68aed3d157d59a35f78
MD5 4197d89d88476e805d61f60df9ee4a1b
BLAKE2b-256 45380441d72a9e98164151557d3d8d89fab697d9782feed1c1cf9edaaf82a013

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp39-cp39-manylinux2010_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp39-cp39-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.9, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 2325fc74ac92c96f09e629dc67e871e07a7d5211041f3f343c1152a77763b0e5
MD5 c22ec55dfe00cacc30140c2286d6c666
BLAKE2b-256 5c06adcc880760552642f9abc56c1f159d9df1aed974237640e1d18adfe4249d

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2deb6d3c17ed7df249a3725bd1cb1f91d97ccfe4b1267e395e3fee4cbd20741e
MD5 66cdb6a4d90f79a50b039717e254b37c
BLAKE2b-256 b6eeaa8d0bf6fba7dcebafead0b23548173075730e049c3a1c19440f8a44011d

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for ruckig-0.2.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 38fa27fc532ffd9df47b6c471329fbe2e2e1d7abaf8ee6d56d0d911f461e9286
MD5 c753ad61c8e38267f4f1426e4d58b97a
BLAKE2b-256 822a7ca2c282ebf8372135247977a1bf2b6b0e984bb4268cd19131b95804c867

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f033dba54dc7a3c4fed8b07ce190190cbe7678ff2b0112be0ed5cfe6f3f3e399
MD5 7970d26263016161cb79b5346b23003c
BLAKE2b-256 4229e38bd6761c6e0136f734d1c610f9dad2f9d518ab97d3ed342ea630274220

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 62b4b411b2405567e11ec4978b81c9a61a252f1a84198b1b703404377bacb2e5
MD5 0490b2550ef39e65d728f7319511c2b3
BLAKE2b-256 5151a7072deb3d64860e5e9f86dea0369d8e7cb74546df3304c568a7b2edc251

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1a7374cfdb833265e4caafef31290526ad399e01b485cf98f23e58cd977a950a
MD5 fa81cb9355e9c4d47d9b5a095f7946b5
BLAKE2b-256 06370c5197486faee00708ac48b9cee5f6ef5248d5ade93f2bb041fc8407d699

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 738bb5678929badef28f0bd63f02a669544ef9fd1e0c792f4e9fb26ad5c76b9f
MD5 fe5516dea8591d7deba35408340c59dc
BLAKE2b-256 81eeee533ff3ac70ed2ce0700d9ec8fd834e4f7298fc842129a576baf822a78d

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b36701bec6207884e3e2d951aabf949a230291198906dd7e71ade32c53215a3d
MD5 1f0125757d4ede572bced63c2bc7704e
BLAKE2b-256 67367ed49b723798eeb077a66fb786d4c148ec66a12405dbacb1ca59a87f7428

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.10

File hashes

Hashes for ruckig-0.2.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 961f87e1a50c234b397c8253d65709c3436812dd8104d5a72f52ae36cf627106
MD5 bcc5b1c09df3468194611b467075ec6d
BLAKE2b-256 18579a69b9681619447f8bc7695d9010d47dbc12ec55b4b39cd311fa54942ac6

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 5e385ea4fb53e4f66161af5e3145dcbfc1487aacc1490ef8e4337019820cd5e2
MD5 80f431a9504dbe682d5d80c41dca5896
BLAKE2b-256 fd20033df41efb0c3d3ca43596b0a162501d448714a7c178b34e64dfcb01ed91

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for ruckig-0.2.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 58bb04c3c5e90b7ce134b12eb9903a2e5cd4b365873b14ff9032a63976bf3acc
MD5 f54b2f170a645a50fa900b248cbce7a6
BLAKE2b-256 8580cbae163894b0ec31390c705ceee0328b2e76181084582ac8837d4c9ddc35

See more details on using hashes here.

File details

Details for the file ruckig-0.2.2-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: ruckig-0.2.2-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 50.4 kB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.9.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.13

File hashes

Hashes for ruckig-0.2.2-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ddd74f65edde033583a3a8f4f4b0f1a86bc4ebd237ba075941d10e1caa8179a9
MD5 7205ccf2a9938b5f076123836f0bb3d2
BLAKE2b-256 560147d3477088bfe705865c55ebde9ba39af52a0cae1f229903c13dcf968d7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page