Add params in NamedTrajectory

NamedTrajectory.jl support passing parameters as a Tuple when construct a NamedTrajectory.

using NamedTrajectories

First we need to define number of timesteps and timestep

T = 10
dt = 0.1
0.1

then build named tuple of components and data matrices.

components = (
    x = rand(3, T),
    u = rand(2, T),
    Δt = fill(dt, 1, T),
)
(x = [0.3476620977699856 0.198619726446566 … 0.39803866393272225 0.6265174753283287; 0.8046466894423636 0.03134785864356637 … 0.8478921369175382 0.4884145755865088; 0.5666698416360124 0.13976133295517412 … 0.3868516834167772 0.46920304578004846], u = [0.1890540644490638 0.9565296024971514 … 0.9792809421326739 0.4172647591081198; 0.18425375127058363 0.9004171437218287 … 0.0957184688500965 0.9101760015037146], Δt = [0.1 0.1 … 0.1 0.1])

we must specify a timestep and control variable for the trajectory.

timestep = 0.1
control = :u
:u

some global params as a NamedTuple

params = (
    α = rand(1),
    β = rand(1)
)
(α = [0.8572905072360408], β = [0.6245809076559321])

we can now create a NamedTrajectory object with parameters specification.

traj = NamedTrajectory(components; timestep=timestep, controls=control, global_data=params)
NamedTrajectory{Float64}([0.3476620977699856 0.198619726446566 … 0.39803866393272225 0.6265174753283287; 0.8046466894423636 0.03134785864356637 … 0.8478921369175382 0.4884145755865088; … ; 0.18425375127058363 0.9004171437218287 … 0.0957184688500965 0.9101760015037146; 0.1 0.1 … 0.1 0.1], [0.3476620977699856, 0.8046466894423636, 0.5666698416360124, 0.1890540644490638, 0.18425375127058363, 0.1, 0.198619726446566, 0.03134785864356637, 0.13976133295517412, 0.9565296024971514  …  0.3868516834167772, 0.9792809421326739, 0.0957184688500965, 0.1, 0.6265174753283287, 0.4884145755865088, 0.46920304578004846, 0.4172647591081198, 0.9101760015037146, 0.1], 10, 0.1, 6, (x = 3, u = 2, Δt = 1, states = 4, controls = 2), NamedTuple(), NamedTuple(), NamedTuple(), NamedTuple(), (x = 1:3, u = 4:5, Δt = 6:6, states = [1, 2, 3, 6], controls = [4, 5]), (α = [0.8572905072360408], β = [0.6245809076559321]), 2, (α = 1, β = 1), (α = 61:61, β = 62:62), (:x, :u, :Δt), (:x, :Δt), (:u,))

This page was generated using Literate.jl.