Skip to content

devel0/scurve-speed-eval

Repository files navigation

scurve speed eval

Show how s-curve speed type can be obtained.



Description

For symbolic calculus AngouriMath library was used.

For preliminary analysis sympy with this test was used.

  • lets name

    • t (time)
    • x (distance)
    • d (total duration accel/decel)
    • s (final speed)
  • suppose [0,d/2] the time for acceleration while [d/2,d] the time for deceleration to produce a target final speed s starting from speed=0 and pos=0

  • from base acceleration function 1-cos(t)

  • expanding the period domain from [0,2pi] to [0,d/2] through this subst

  • stretching the accel function so that its integral, the speed, achieve targetspeed

  • acceleration results as this

👉 hit F5 if math not rendered

$$ \large accel(t)=\frac{2\cdot s}{d}\cdot\left(1-\cos\left(\frac{4\cdot\pi\cdot t}{d}\right)\right) $$

  • positive max accel value is at midpoint ( t=1/4d because accel positive in [0,d/2] ) thus above can be simplified into

$$ \large maxAccel=\frac{4\cdot s}{d} $$

$$ \large speed(t) = \frac{2\cdot s}{d} \cdot \left( t - \frac{d\cdot \sin\left(\frac{4\cdot\pi\cdot t}{d}\right)}{4\cdot\pi} \right) $$

$$ \large pos(t) = \frac{s\cdot d \cdot \left( \cos\left(\frac{4\cdot\pi\cdot t}{d}\right)-1 \right)}{8\cdot\pi^2} + \frac{s\cdot t^2}{d} $$

  • targetspeed required from known final position p to reach in required time duration d

$$ \large s = \frac{2\cdot p}{d} $$

  • from base deceleration function cos(t)-1

  • sets th as

$$ \large th=t-\frac{d}{2} $$

  • deceleration results as this

$$ \large deAccel\left(th\right) = \frac{2\cdot s}{d}\cdot\left(\cos\left(\frac{4\cdot\pi\cdot th}{d}\right)-1\right) $$

  • despeed results as this ( given from deAccel integral subtracting integration constant and adding speed achieved by accel at d/2 )

$$ \large deSpeed\left(th\right) = \frac{2\cdot s\cdot\sin\left(\frac{4\cdot\pi\cdot th}{d} \right)}{4\cdot\pi}-\frac{2\cdot s\cdot th}{d}+s $$

  • depos results as this ( given from deSpeed integral subtracting integration constant and adding pos achieved by accel at d/2 )

$$ \large dePos\left(th\right) = \frac{s\cdot d\cdot\left( 1-\cos\left(\frac{4\cdot\pi\cdot th}{d}\right) \right)}{8\cdot\pi^2}-\frac{s\cdot th^2}{d}+s\cdot th+\frac{s\cdot d}{4} $$

Performance considerations

For a realtime purpose a bezier approach should be used like the one implemented in the Marlin.

Example

This example can be executed through

dotnet run --project examples/scurve-xlsx

and it will produce follow output.xlsx by applying above formulas and doing some test calc about max allowable torque based on motion and supposed load.

Prerequisites

Quickstart

git clone https://github.com/devel0/netcore-util
cd netcore-util
git checkout bd8626104f4b5a9cb9de5db624cebbcd77a8b384
cd ..

git clone https://github.com/devel0/netcore-sci
cd netcore-sci
git checkout 151451d5cd40e8ccebf93718379e8d72dbadce86
cd ..

git clone https://github.com/devel0/scurve-speed-eval
cd scurve-speed-eval
dotnet build
dotnet run --project gui

How this project was built

dotnet new console -n scurve-speed-eval
cd scurve-speed-eval
dotnet sln add scurve-speed-eval.csproj
dotnet sln add .
dotnet add reference ../netcore-util/netcore-util
dotnet add reference ../netcore-sci/netcore-sci
dotnet add package AngouriMath --version 1.3.0
dotnet add package Avalonia.Desktop --version 0.10.0-preview6
dotnet add package OxyPlot.Avalonia --version 2.1.0-20200725.1
dotnet add package UnitsNet --version 4.76.0
dotnet run

References