Project

General

Profile

Minimal example » History » Version 1

Daniel Sidobre, 2018-07-11 15:55

1 1 Daniel Sidobre
h1. Minimal example
2
3
<pre><code class="python">
4
import softMotion
5
6
# Definition of initial and final conditions:
7
ic = softMotion.Sm_Condition()
8
fc = softMotion.Sm_Condition()
9
ic.a = 10
10
ic.v = 4
11
ic.x = 0.
12
fc.a = 10
13
fc.v = 6
14
fc.x = 10.
15
16
# Definition of velocity, acceleration and jerk bounds:
17
#vmin vmax amin amax jmin jmax
18
limits = softMotion.Sm_Limits(-20, 20, -20, 20, -30, 30)
19
20
# Definition of precision parameter
21
epsilon = softMotion.Sm_Epsilon(1e-5)
22
23
# Definition of a trajectory traj to store the result
24
trajectoire = softMotion.Sm_Cubic7Segments()
25
# Computing the trajectory trajectoire
26
ret = softMotion.sm_traj7Segments(limits, ic, fc, epsilon, trajectoire)
27
28
# To print the trajectory:
29
def printSegment(seg, name= ""):
30
    print name, "j=", seg.j, "ic.a=", seg.ic.a, "ic.v=", seg.ic.v, "ic.x=", seg.ic.x, "  t0=", seg.t0, "tf=", seg.tf
31
 
32
def printTraj(traj):
33
    printSegment(traj.sj_aa, "sj_aa")
34
    printSegment(traj.sa_a, "sa_a")
35
    printSegment(traj.sj_ba, "sj_ba")
36
    printSegment(traj.sv, "sv")
37
    printSegment(traj.sj_bb, "sj_bb")
38
    printSegment(traj.sa_b, "sa_b")
39
    printSegment(traj.sj_ab, "sj_ab")
40
    print "fc.a=", traj.fc.a, "fc.v=", traj.fc.v, "fc.x=", traj.fc.x, "  tf=", traj.tf
41
42
printTraj(trajectoire)
43
44
</code></pre>