S7RTT is a lightweight, high-performance C++/C/Python/ST library designed for generating 7-segment S-curve motion profiles (jerk-limited trajectories).
While conceptually similar to the renowned Ruckig library, S7RTT is specifically optimized for single-axis applications, offering a streamlined alternative for embedded systems and real-time control loops where low latency and deterministic execution are paramount.
S7RTT provides a robust solution for time-optimal trajectory generation with the following capabilities:
- Arbitrary Initial State: Calculate trajectories starting from any position, velocity, and acceleration.
- Target State Control: Reach any desired target position and velocity.
- Note: The target acceleration is fixed at
0and cannot be modified.
- Note: The target acceleration is fixed at
- Full Jerk Constraints: Implements complete jerk limitation to ensure smooth, third-order continuous motion, reducing mechanical stress.
- Real-Time Interruption: Supports "online" trajectory generation. You can interrupt the motion at any time with new target parameters, and the library will calculate a smooth transition from the current kinematic state.
S7RTT is not intended to replace Ruckig for multi-DOF cases, but it offers distinct advantages in single-axis scenarios:
- Standard Trajectories: For normal point-to-point moves, calculation results are consistent with Ruckig.

- Velocity Limits: S7RTT demonstrates superior trajectory optimization when handling cases where the maximum velocity limit is dynamically lowered or constrained.

- Boundary Conditions:
- In many edge cases, performance is comparable.

- Ruckig does exhibit better solutions under certain boundary conditions.

- However, more often than not, even within the constraints, Ruckig still attempts to insert a Brake motion, which leads to a suboptimal final solution.

- Specifically, Ruckig advises using 'm' as unit to avoid high-jerk planning failures, whereas S7RTT suggests 'mm'. Here is the stress test comparison for normal and extreme cases:
- In many edge cases, performance is comparable.
################################################################################
Test in normal operation (vmax is 1000.0, amax is 10000.0, jmax is 100000.0)
################################################################################
Total Tests: 100000
----------------------------------------
CATEGORY | S7RTT | RUCKIG
----------------------------------------
Plan Failures | 0 | 0
Sim Acc Failures | 0 | 0
----------------------------------------
Faster Count | 3953 | 0
Draws | 96047 | 96047
################################################################################
################################################################################
Test in extreme cases (random vmax in [10,1000], amax in [10,10000], jmax in [10,10000])
################################################################################
Total Tests: 100000
----------------------------------------
CATEGORY | S7RTT | RUCKIG
----------------------------------------
Plan Failures | 0 | 13
Sim Acc Failures | 2 | 13
----------------------------------------
Faster Count | 9039 | 1
Draws | 90934 | 90934
################################################################################
Benchmarks conducted on C++ platforms evaluate the performance of S7RTT compared to Ruckig:
- Reduced Average Load: S7RTT reduces the average CPU time per calculation cycle by approximately 30%, improving overall computational efficiency.
- Comparable Real-Time Limits: Despite the lower average, the maximum execution time (peak latency) remains similar to Ruckig. This indicates that for hard real-time constraints (worst-case scenarios), the practical performance envelope is equivalent.
(Measure cycle time compare in Preempt_RT Linux, The unit is nanoseconds)

The core challenge of S-curve generation is calculating a time-optimal trajectory from an arbitrary initial state (
S7RTT differentiates itself from other solvers through its numerical approach:
-
Analytical Complexity: Libraries like Ruckig or TwinCAT typically solve cubic or quartic equations (using Cardano, Ferrari, or Newton methods) for exact roots. However, at specific boundary conditions—particularly when the target velocity is non-zero—these analytical methods can hit singularities. This often forces a fallback to bisection search.
-
Brent’s Method & Heuristics: Instead of relying solely on analytical root-finding, S7RTT employs trajectory extrapolation combined with Brent’s method for iterative approximation.
- This "fuzzy solving" approach prioritizes convergence stability over absolute theoretical precision.
- If a time-optimal solution cannot be found numerically, the algorithm safely degrades to a strategy of "reducing acceleration to zero before planning," ensuring a valid solution exists.
-
Usage Recommendations: To maximize performance, the algorithm is designed for a "Plan Once, Sample Many" workflow. Users are advised to call
plan()only when the target changes, and useat_time()for per-cycle updates, rather than re-planning every cycle. However, immediate interruption with new parameters is fully supported.
S7RTT aims to provide a simple, fast, and reliable trajectory generator for single-axis motion control tasks. By simplifying the problem space (fixing target acceleration to zero), it achieves extremely high performance and code simplicity.
Special thanks to Gemini 3 Pro for the assistance in the development and optimization of this library.
