Git Product home page Git Product logo

s_curve's Introduction

crates.io GitHub Workflow Status crates.io crates.io docs.rs codecov

A library to compute S-Curve trajectories. It can be used to generate motion profiles for robotics.

What is an S-Curve?

An S-Curve is a trajectory which is constrained to maximum jerk, acceleration and velocity. An S-Curve consists of 7 phases:

  • constant maximum jerk until the desired acceleration is reached
  • constant maximum acceleration phase
  • constant minimum jerk until the desired velocity is reached with an acceleration of zero
  • constant velocity phase
  • constant minimum jerk until the minimum acceleration is reached
  • constant minimum acceleration phase
  • constant maximum jerk until the acceleration is zero and the desired position and end velocity is reached

In the picture below you can see an S-Curve Profile which goes from Position 0 to position 10 within 5.5 seconds with a start and end velocity of 0 , a maximum jerk of 3, a maximum acceleration of 2 and a maximum velocity of 3. image

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.));
}

License

Copyright (c) 2020 Marco Boneberger Licensed under either of Apache License, Version 2.0 or MIT license at your option.

s_curve's People

Contributors

marcbone avatar r2k-in-the-vortex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

s_curve's Issues

Can it be no_std?

Hi. I want to use it in my embed project but unfortunately it depends on std

Showcase

Post here your project using s_curve.

Maximum end velocity

is it possible to only have an end position constraint and reach maximum possible velocity at the end?

infinite recusrion on calc_times_case_2

here is my data to reproduce:

 let constraints = SCurveConstraints {
        max_jerk: 3000.,
        max_acceleration: 2600.,
        max_velocity: 600.0,
    };
    let start_conditions = SCurveStartConditions {
        q0: 0.,  
        q1: 1,
        v0: 12.,
        v1: 12.,
    };

Support for inital starting acceleration?

Hi there, thanks for publishing your s-curve implementation!

I've been hunting around the net for an implementation that also accounts for an initial acceleration. I noticed that your implementation handles initial velocity, though assumes an initial acceleration of 0.0. The reason I'm interested in handling the initial acceleration is that I'm currently working with an interactive, kinetic artwork where the actuators' target positions change in real-time. I've been considering implementing something inspired by this paper, though am curious whether you have another approach in mind that you'd consider implementing in this crate?

Support for separate max acceleration and deceleration.

Hello, thanks for this amazing crate!

I was wondering if it would be possible to add support for separate max acceleration and max deceleration, there are situations where slow acceleration but fast deceleration is required.

Thanks again.

another bad results and bad params

Hi. this time its for negative position. params like:

    let constraints = SCurveConstraints {
        max_jerk: 240000.,
        max_acceleration: 260000.,
        max_velocity: 65600.0,
    };
    let start_conditions = SCurveStartConditions {
        q0: 0.,           // start position
        q1: -6400*10, // end position
        v0: 0.,           // start velocity
        v1: 0.,           // end velocity
    };
    ```
    
    
![Screenshot_2021-08-21_04-10-22](https://user-images.githubusercontent.com/707007/130305827-3f58fc24-d0df-4ae3-aeb0-f4098498f33e.png)


Its okay if it is not good params, but I guess if will help. thank you

Beginnger suggestions on how to run the plot.rs in the examples folder

Hello,

Thank you for making this repo public. Just wondering if you may kindly give a few tips on how to run this rust package? I'm very new to rust (just now...) and any suggestion would be helpful. I know it's inappropriate to ask this kind of question. But I came from control background and the rust book does not help much.... I just want to know how to run the plot.rs...

Many thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.