Esempio n. 1
0
def solve(problem_spec):
    # system state boundary values for a = 0.0 [s] and b = 2.0 [s]
    xa = problem_spec.xx_start
    xb = problem_spec.xx_end

    T_end = problem_spec.T_transition

    # constraints dictionary
    con = problem_spec.constraints

    ua = problem_spec.u_start
    ub = problem_spec.u_end

    def f_pytrajectory(xx, uu, uuref, t, pp):
        """ Right hand side of the vectorfield defining the system dynamics

        This function wraps the rhs-function of the problem_spec to make it compatible to
        pytrajectory.

        :param xx:       state
        :param uu:       input
        :param uuref:    reference input (not used)
        :param t:        time (not used)
        :param pp:       additionial free parameters  (not used)
        :return:        xdot
        """

        return problem_spec.rhs(xx, uu)

    first_guess = problem_spec.first_guess

    # create the trajectory object
    S = TransitionProblem(f_pytrajectory,
                          a=0.0,
                          b=T_end,
                          xa=xa,
                          xb=xb,
                          ua=ua,
                          ub=ub,
                          constraints=con,
                          use_chains=True,
                          first_guess=first_guess)

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

    # start
    x, u = S.solve()

    solution_data = SolutionData()
    solution_data.x_func = x
    solution_data.u_func = u

    save_plot(problem_spec, solution_data)

    return solution_data
Esempio n. 2
0
    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 = TransitionProblem(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


def draw(xti, image):
    x, phi1, phi2 = xti[0], xti[2], xti[4]
        (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 = TransitionProblem(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):
    x = xti[0]
    phi = xti[2]
Esempio n. 4
0
ub = [0.0]

# create System
first_guess = {'seed': 1529}  # choose a seed which leads to quick convergence
S = TransitionProblem(f,
                      a=0.0,
                      b=2.0,
                      xa=xa,
                      xb=xb,
                      ua=ua,
                      ub=ub,
                      use_chains=True,
                      first_guess=first_guess)

# 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):
    phi1, phi2 = xti[0], xti[2]

    L = 0.5
Esempio n. 5
0
        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 = TransitionProblem(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

def draw(xti, image):
    phi1, phi2 = xti[0], xti[2]