1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*!
# RSRuckig
Ruckig generates trajectories on-the-fly, allowing robots and machines to react instantaneously to sensor input.
This Rust library is a direct port of the [C++ Ruckig library](https://github.com/pantor/ruckig), with adaptations for Rust's
type system and memory management features.
## Overview
Ruckig calculates a trajectory to a *target* waypoint (with position, velocity, and acceleration) starting from *any* initial
state limited by velocity, acceleration, and jerk constraints. Besides the target state, Ruckig allows defining
intermediate positions for waypoint following. For state-to-state motions, Ruckig guarantees a time-optimal solution.
With intermediate waypoints, Ruckig calculates the path and its time parametrization jointly, resulting in significantly
faster trajectories compared to traditional methods.
## Core Components
The library provides three main components:
- `Ruckig`: Main class for trajectory generation
- `InputParameter`: Class defining the kinematic state and constraints
- `OutputParameter`: Class holding the calculated trajectory results
## Getting Started
```rust
use rsruckig::prelude::*;
fn main() {
// Create a Ruckig instance with 1 DoF and the ThrowErrorHandler
let mut otg = Ruckig::<1, ThrowErrorHandler>::new(None, 0.01); // DoF, control cycle in seconds
// Define input parameters
let mut input = InputParameter::new(None);
input.current_position[0] = 0.0;
input.current_velocity[0] = 0.0;
input.current_acceleration[0] = 0.0;
input.target_position[0] = 1.0;
input.target_velocity[0] = 0.0;
input.target_acceleration[0] = 0.0;
input.max_velocity[0] = 0.5;
input.max_acceleration[0] = 1.0;
input.max_jerk[0] = 2.0;
// Create output parameters
let mut output = OutputParameter::new(None);
// Generate trajectory step by step
while otg.update(&input, &mut output).unwrap() == RuckigResult::Working {
// Use the new state (output.new_position, output.new_velocity, etc.)
// Pass the new state to the input for the next iteration
output.pass_to_input(&mut input);
}
}
```
## Features
- **Real-time Trajectory Generation**: Generate trajectories on-the-fly for robots and machines
- **Jerk-limited Motion**: Ensures smooth motion by limiting jerk
- **Waypoint-based Trajectory Generation**: Supports intermediate waypoints for complex paths
- **Customizable Error Handling**: Implement your own error handling strategies using the `RuckigErrorHandler` trait
- **Stack or Heap Allocation**: Choose between compile-time (stack) or runtime (heap) allocation for degrees of freedom
## Error Handling
The library provides two error handlers out of the box:
- `ThrowErrorHandler`: Returns errors when validation or calculation fails
- `IgnoreErrorHandler`: Ignores errors and continues execution
You can also implement custom error handlers by implementing the `RuckigErrorHandler` trait.
## Numerical Stability
The library is tested for numerical stability and guarantees correctness within the following bounds:
- Final position and velocity within `1e-8`
- Final acceleration within `1e-10`
- Velocity, acceleration, and jerk limits within `1e-12`
All kinematic limits should be below `1e12` for reliable operation, and the maximum supported trajectory duration is `7e3`.
See the documentation for individual modules and types for more details.
*/
//! # RSRuckig
//!
//! Ruckig generates trajectories on-the-fly, allowing robots and machines to react instantaneously to sensor input.
//!
//! This Rust library is a direct port of the [C++ Ruckig library](https://github.com/pantor/ruckig), with adaptations for Rust's
//! type system and memory management features.
/// Re-exports of the most commonly used types
///
/// This module provides easy access to the most commonly used types in the RSRuckig library.
// Re-export macros from rsruckig module
pub use cratedaov_heap;
pub use cratedaov_stack;
pub use cratecount_exprs;