예제 #1
0
    return ff


# system state boundary values for a = 0.0 [s] and b = 2.0 [s]
xa = [0.0, 0.0]
xb = [1.0, 0.0]

# constraints dictionary
con = {1: [-0.1, 0.65]}

# create the trajectory object
S = ControlSystem(f,
                  a=0.0,
                  b=2.0,
                  xa=xa,
                  xb=xb,
                  constraints=con,
                  use_chains=False)

# start
x, u = S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation


def draw(xt, image):
    return ff

# boundary values at the start (a = 0.0 [s])
xa = [  0.0,
        0.0,
        0.0,
        0.0]

# boundary values at the end (b = 2.0 [s])
xb = [  1.0,
        0.0,
        0.0,
        0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb)

# change method parameter to increase performance
S.set_param('use_chains', False)

# run iteration
S.solve()


# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

def draw(xti, image):
a = 0.0
xa = [0.0, 0.0, pi, 0.0, pi, 0.0]

b = 4.0
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# here we specify the constraints for the velocity of the car
con = {0 : [-1.0, 1.0],
       1 : [-2.0, 2.0]}

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f, a, b, xa, xb, ua, ub, constraints=con,
                  eps=2e-1, su=20, kx=2, use_chains=False,
                  use_std_approach=False)

# time to run the iteration
x, u = S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

def draw(xt, image):
    x = xt[0]
    phi1 = xt[2]
    phi2 = xt[4]
예제 #4
0
# system state boundary values for a = 0.0 [s] and b = 3.0 [s]
xa = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
xb = [10.0, 0.0, 5.0, 0.0, 0.0, 0.0]

# boundary values for the inputs
ua = [
    0.5 * 9.81 * 50.0 / (cos(5 / 360.0 * 2 * pi)),
    0.5 * 9.81 * 50.0 / (cos(5 / 360.0 * 2 * pi))
]
ub = [
    0.5 * 9.81 * 50.0 / (cos(5 / 360.0 * 2 * pi)),
    0.5 * 9.81 * 50.0 / (cos(5 / 360.0 * 2 * pi))
]

# create trajectory object
S = ControlSystem(f, a=0.0, b=3.0, xa=xa, xb=xb, ua=ua, ub=ub)

# don't take advantage of the system structure (integrator chains)
# (this will result in a faster solution here)
S.set_param('use_chains', False)

# also alter some other method parameters to increase performance
S.set_param('kx', 5)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
    u1, = u
    
    ff = [x2,
          u1]
    
    return ff

# system state boundary values for a = 0.0 [s] and b = 2.0 [s]
xa = [0.0, 0.0]
xb = [1.0, 0.0]

# constraints dictionary
con = {1 : [-0.1, 0.65]}

# create the trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb, constraints=con, use_chains=False)

# start
x, u = S.solve()


# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

def draw(xt, image):
    x = xt[0]
    
    car_width = 0.05
예제 #6
0
ua = 0.0
ub = 0.0

xa = [pi, pi, pi, 0.0, 0.0, 0.0, 0.0, 0.0]
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

# S = ControlSystem(model_rhs, Ta, Tb, xa, xb, ua, ub)
# state, u = S.solve()
from pytrajectory import log

log.console_handler.setLevel(10)

# now we create our Trajectory object and alter some method parameters via the keyword arguments sx=640,
S = ControlSystem(model_rhs, Ta, Tb, xa, xb, ua, ub, constraints=None,
                  eps=4e-1, su=30, kx=2, use_chains=False,
                  use_std_approach=False,
                  sol_steps=200,
                  show_intermediate_result=True)

# dt_sim=0.004
# time to run the iteration
x, u = S.solve()
print "successed!"

IPS()

# N = 100
# for i in range(1, N):
#     print i, "------"
#     first_guess = {'seed' : i}
#     S = ControlSystem(model_rhs, a=Ta, b=Tb, xa=xa, xb=xb, ua=ua, ub=ub, use_chains=False, first_guess=first_guess, ierr=None, maxIt=5, eps=5e-2, sol_steps=30)
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# here we specify the constraints for the velocity of the car
con = {0: [-1.0, 1.0], 1: [-2.0, 2.0]}

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f,
                  a,
                  b,
                  xa,
                  xb,
                  ua,
                  ub,
                  constraints=con,
                  eps=2e-1,
                  su=20,
                  kx=2,
                  use_chains=False,
                  use_std_approach=False)

# time to run the iteration
x, u = S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation
            (1/l)*(g*sin(x3)+u1*cos(x3))]
    
    return ff

# then we specify all boundary conditions
a = 0.0
xa = [0.0, 0.0, pi, 0.0]

b = 2.0
xb = [0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f, a, b, xa, xb, ua, ub, kx=5, use_chains=False)

# time to run the iteration
S.solve()


# now that we (hopefully) have found a solution,
# we can visualise our systems dynamic

# therefore we define a function that draws an image of the system
# according to the given simulation data
def draw(xt, image):
    # to draw the image we just need the translation `x` of the
    # cart and the deflection angle `phi` of the pendulum.
    x = xt[0]
    phi = xt[2]
예제 #9
0
    ff = np.array([
        x2, m * s * (-l * x4**2 + g * c) / (M + m * s**2) + 1 /
        (M + m * s**2) * u1, x4, s * (-m * l * x4**2 * c + g * (M + m)) /
        (M * l + m * l * s**2) + c / (M * l + l * m * s**2) * u1
    ])
    return ff


# boundary values at the start (a = 0.0 [s])
xa = [0.0, 0.0, 0.0, 0.0]

# boundary values at the end (b = 2.0 [s])
xb = [1.0, 0.0, 0.0, 0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb)

# change method parameter to increase performance
S.set_param('use_chains', False)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation


def draw(xti, image):
예제 #10
0
    b = 3.5
    xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

    ua = [0.0]
    ub = [0.0]

    # here we specify the constraints for the velocity of the car
    con = {0: [-1.0, 1.0], 1: [-5.0, 5.0]}

    # now we create our Trajectory object and alter some method parameters via the keyword arguments
    S = ControlSystem(f,
                      a,
                      b,
                      xa,
                      xb,
                      ua,
                      ub,
                      constraints=con,
                      eps=4e-1,
                      su=20,
                      kx=2,
                      use_chains=False)

    # time to run the iteration
    x, u = S.solve()

    # the following code provides an animation of the system above
    # for a more detailed explanation have a look at the 'Visualisation' section in the documentation
    import sys
    import matplotlib as mpl
    from pytrajectory.visualisation import Animation
예제 #11
0
    return ff


# then we specify all boundary conditions
a = 0.0
xa = [0.0, 0.0, pi, 0.0]

b = 2.0
xb = [0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f, a, b, xa, xb, ua, ub, kx=5, use_chains=False)

# time to run the iteration
S.solve()

# now that we (hopefully) have found a solution,
# we can visualise our systems dynamic


# therefore we define a function that draws an image of the system
# according to the given simulation data
def draw(xt, image):
    # to draw the image we just need the translation `x` of the
    # cart and the deflection angle `phi` of the pendulum.
    x = xt[0]
    phi = xt[2]
                            x6,
                (1/l2)*(g*sin(x5)+u*cos(x5))
                    ])
    
	return ff

# system state boundary values for a = 0.0 [s] and b = 2.0 [s]
xa = [0.0, 0.0,  np.pi, 0.0,  np.pi, 0.0]
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

# boundary values for the input
ua = [0.0]
ub = [0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb, ua=ua, ub=ub)

# alter some method parameters to increase performance
S.set_param('su', 10)
S.set_param('eps', 8e-2)

# run iteration
S.solve()


# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation
# then we specify all boundary conditions
a = 0.0
xa = [0.0, 0.0, np.pi, 0.0]

b = 3.0
xb = [0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# next, this is the dictionary containing the constraints
con = { 0 : [-0.8, 0.3], 
        1 : [-2.0, 2.0] }

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f, a, b, xa, xb, ua, ub, constraints=con, kx=5, use_chains=False)

# time to run the iteration
S.solve()


# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

def draw(xt, image):
    x = xt[0]
    phi = xt[2]
    
예제 #14
0
    ff = np.array([x2, u1, x4, -1 / d11 * (h1 + phi1 + d12 * u1)])

    return ff


# system state boundary values for a = 0.0 [s] and b = 2.0 [s]
xa = [0.0, 0.0, 3 / 2.0 * np.pi, 0.0]

xb = [0.0, 0.0, 1 / 2.0 * np.pi, 0.0]

# boundary values for the inputs
ua = [0.0]
ub = [0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb, ua=ua, ub=ub)

# alter some method parameters to increase performance
S.set_param('su', 10)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation


def draw(xti, image):
        (1 / l2) * (g * sin(x5) + u * cos(x5))
    ])

    return ff


# system state boundary values for a = 0.0 [s] and b = 2.0 [s]
xa = [0.0, 0.0, np.pi, 0.0, np.pi, 0.0]
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

# boundary values for the input
ua = [0.0]
ub = [0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb, ua=ua, ub=ub)

# alter some method parameters to increase performance
S.set_param('su', 10)
S.set_param('eps', 8e-2)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

예제 #16
0
xa = [  0.0,
        0.0,
        3/2.0*np.pi,
        0.0]

xb = [  0.0,
        0.0,
        1/2.0*np.pi,
        0.0]

# boundary values for the inputs
ua = [0.0]
ub = [0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=2.0, xa=xa, xb=xb, ua=ua, ub=ub)

# alter some method parameters to increase performance
S.set_param('su', 10)

# run iteration
S.solve()


# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

def draw(xti, image):
예제 #17
0
# get callable function for vectorfield that can be used with PyTrajectory
f = solve_motion_equations(M, B, state_vars, input_vars)

# then we specify all boundary conditions
a = 0.0
xa = [0.0, 0.0, pi, 0.0, pi, 0.0, pi, 0.0]

b = 3.5
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f, a, b, xa, xb, ua, ub, constraints=None,
                  eps=4e-1, su=30, kx=2, use_chains=False,
                  use_std_approach=False)

# time to run the iteration
x, u = S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section
# in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

# all rods have the same length
rod_lengths = [0.5] * N
예제 #18
0
                    -g+c/M*(u1+u2) +s/M*(u1-u2)*sa ,
                                x6,
                    1/J*(u1-u2)*(l*ca+h*sa)])
    
    return ff 

# system state boundary values for a = 0.0 [s] and b = 3.0 [s]
xa = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
xb = [10.0, 0.0, 5.0, 0.0, 0.0, 0.0]

# boundary values for the inputs
ua = [0.5*9.81*50.0/(cos(5/360.0*2*pi)), 0.5*9.81*50.0/(cos(5/360.0*2*pi))]
ub = [0.5*9.81*50.0/(cos(5/360.0*2*pi)), 0.5*9.81*50.0/(cos(5/360.0*2*pi))]

# create trajectory object
S = ControlSystem(f, a=0.0, b=3.0, xa=xa, xb=xb, ua=ua, ub=ub)

# don't take advantage of the system structure (integrator chains)
# (this will result in a faster solution here)
S.set_param('use_chains', False)

# also alter some other method parameters to increase performance
S.set_param('kx', 5)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
예제 #19
0
    ff = np.array([x2, u1, x4, -e * x2**2 * s - (1 + e * c) * u1])

    return ff


# system state boundary values for a = 0.0 [s] and b = 1.8 [s]
xa = [0.0, 0.0, 0.4 * np.pi, 0.0]

xb = [0.2 * np.pi, 0.0, 0.2 * np.pi, 0.0]

# boundary values for the inputs
ua = [0.0]
ub = [0.0]

# create trajectory object
S = ControlSystem(f, a=0.0, b=1.8, xa=xa, xb=xb, ua=ua, ub=ub)

# also alter some method parameters to increase performance
S.set_param('su', 20)
S.set_param('kx', 3)

# run iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

예제 #20
0
b = 3.0
xb = [0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# next, this is the dictionary containing the constraints
con = {0: [-0.8, 0.3], 1: [-2.0, 2.0]}

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f,
                  a,
                  b,
                  xa,
                  xb,
                  ua,
                  ub,
                  constraints=con,
                  kx=5,
                  use_chains=False)

# time to run the iteration
S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section in the documentation
import sys
import matplotlib as mpl
from pytrajectory.visualisation import Animation

예제 #21
0
xa = [0.0, 0.0, pi, 0.0, pi, 0.0, pi, 0.0]

b = 3.5
xb = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

ua = [0.0]
ub = [0.0]

# now we create our Trajectory object and alter some method parameters via the keyword arguments
S = ControlSystem(f,
                  a,
                  b,
                  xa,
                  xb,
                  ua,
                  ub,
                  constraints=None,
                  eps=4e-1,
                  su=30,
                  kx=2,
                  use_chains=False,
                  use_std_approach=False)

# time to run the iteration
x, u = S.solve()

# the following code provides an animation of the system above
# for a more detailed explanation have a look at the 'Visualisation' section
# in the documentation
import sys
import matplotlib as mpl