Crate s_curve

source ·
Expand description

s_curve

A library to create S-Curve with constrained jerk, acceleration and velocity. It can be used to create a function which desribes the Position, Velocity, Acceleration or Jerk with respect to time. You can create a Motion Profile for robots with it. image

The notation follows loosely the book “Trajectory Planning for Automatic Machinesand Robots” by Luigi Biagotti and Claudio Melchiorri

Example

use s_curve::*;
let constraints = SCurveConstraints {
            max_jerk: 3.,
            max_acceleration: 2.0,
            max_velocity: 3.};
        let  start_conditions = SCurveStartConditions {
            q0: 0., // start position
            q1: 10., // end position
            v0: 0., // start velocity
            v1: 0. // end velocity
        };
        let input = SCurveInput{constraints, start_conditions};
        let (params,s_curve) = s_curve_generator(&input,Derivative::Velocity);
        for i in 0..101 {
            println!("{}", s_curve(i as f64 * params.time_intervals.total_duration() / 100.));
        }

Structs

  • Struct which contains the desired limits for jerk, acceleration and velocity in SI units. These are only the limits. It can happen that the acceleration or Velocity will be actually lower after the S-Curve has been calculated. The actual maximum values are in the SCurveParameters struct
  • Struct which represent the input which is needed so that the S-Curve can be calculated
  • Struct which represents the final parametrization of the S-Curve
  • Represents the Start and End Positions of the S_Curve
  • Represents the different time intervals of the S-Curve

Enums

  • Enum which is used to select whether you want to calculate Position, Velocity, Acceleration or Jerk of your S-Curve

Functions

  • returns the S-Curve parameters and a function which maps time [0,t] to Position, Velocity, Acceleration or Jerk, depending on what you set as Derivative. Note that the acceleration and velocity could be decreased if it is not possible to achieve them.