Project

General

Profile

Actions

Minimal example

import softMotion

# Definition of initial and final conditions:
ic = softMotion.Sm_Condition()
fc = softMotion.Sm_Condition()
ic.a = 10
ic.v = 4
ic.x = 0.
fc.a = 10
fc.v = 6
fc.x = 10.

# Definition of velocity, acceleration and jerk bounds:
#vmin vmax amin amax jmin jmax
limits = softMotion.Sm_Limits(-20, 20, -20, 20, -30, 30)

# Definition of precision parameter
epsilon = softMotion.Sm_Epsilon(1e-5)

# Definition of a trajectory traj to store the result
trajectoire = softMotion.Sm_Cubic7Segments()
# Computing the trajectory trajectoire
ret = softMotion.sm_traj7Segments(limits, ic, fc, epsilon, trajectoire)

# To print the trajectory:
def printSegment(seg, name= ""):
    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

def printTraj(traj):
    printSegment(traj.sj_aa, "sj_aa")
    printSegment(traj.sa_a, "sa_a")
    printSegment(traj.sj_ba, "sj_ba")
    printSegment(traj.sv, "sv")
    printSegment(traj.sj_bb, "sj_bb")
    printSegment(traj.sa_b, "sa_b")
    printSegment(traj.sj_ab, "sj_ab")
    print "fc.a=", traj.fc.a, "fc.v=", traj.fc.v, "fc.x=", traj.fc.x, "  tf=", traj.tf

printTraj(trajectoire)

Updated by Daniel Sidobre over 6 years ago · 1 revisions