API

NamedTrajectory methods

Base.:==Method
:(==)(traj1::NamedTrajectory, traj2::NamedTrajectory)

Check if trajectories are equal w.r.t. using Base.:(==)

source
Base.copyMethod
copy(::NamedTrajectory)

Returns a copy of the trajectory.

source
Base.getindexMethod
getindex(traj, ts::AbstractVector{Int})::Vector{KnotPoint}

Returns the knot points at times ts.

source
Base.getindexMethod
getindex(traj, t::Int)::KnotPoint

Returns the knot point at time t.

source
Base.getindexMethod
getindex(traj, symb::Symbol)

Dispatches indexing of trajectories as either accessing a component or a property via getproperty.

source
Base.getpropertyMethod
getproperty(traj, symb::Symbol)

Returns the component of the trajectory with name symb or the property of the trajectory with name symb.

source
Base.isequalMethod
isequal(traj1::NamedTrajectory, traj2::NamedTrajectory)

Check if trajectories are equal w.r.t. data using Base.isequal

source
Base.lastindexMethod
lastindex(traj::NamedTrajectory)

Returns the final time index of the trajectory.

source
Base.lengthMethod
length(::NamedTrajectory)

Returns the length of all variables of the trajectory, including global data.

source
Base.mergeMethod
merge(traj1::NamedTrajectory, traj2::NamedTrajectory)
merge(trajs::AbstractVector{<:NamedTrajectory})

Returns a new NamedTrajectory object by merging NamedTrajectory objects.

Merge names are used to specify which components to merge by index. If no merge names are provided, all components are merged and name collisions are not allowed. If merge names are provided, the names are merged using the data from the index provided in the merge names.

Joined NamedTrajectory objects must have the same timestep. If a free time trajectory is desired, setting the keyword argument free_time=true will construct the a component for the timestep. In this case, the timestep symbol must be provided.

Arguments

  • traj1::NamedTrajectory: The first NamedTrajectory object.
  • traj2::NamedTrajectory: The second NamedTrajectory object.
  • free_time::Bool=false: Whether to construct a free time problem.
  • timestep_name::Symbol=:Δt: The timestep symbol to use for free time problems.
  • merge_names::Union{Nothing, NamedTuple{<:Any, <:Tuple{Vararg{Int}}}}=nothing: The names to merge by index.
source
Base.setproperty!Method
setproperty!(traj, name::Symbol, val::Any)

Dispatches setting properties of trajectories as either setting a component or a property via setfield! or update!.

source
Base.sizeMethod
size(traj::NamedTrajectory) = (dim = traj.dim, T = traj.T)

Returns the size of the trajectory (dim, T), excluding global data.

TODO: Should global data be in size?

source
Base.vecMethod
vec(::NamedTrajectory)

Returns all variables of the trajectory as a vector, Z⃗.

source
NamedTrajectories.MethodsNamedTrajectory.get_component_namesMethod
get_component_names(traj::NamedTrajectory, comps::AbstractVector{<:Int})

Returns the name of the component with the given indices. If only one component is found, the name is returned as a single symbol. Else, the names are returned as a vector of symbols.

The filter requires that the components are a complete subset of the given indices, so that a partial match is excluded from the returned names.

source
NamedTrajectories.MethodsNamedTrajectory.update_bound!Function
update_bound!(traj, name::Symbol, data::Real)
update_bound!(traj, name::Symbol, data::AbstractVector{<:Real})
update_bound!(traj, name::Symbol, data::Tuple{R, R} where R <: Real)

Update the bound of a component of the trajectory.

source

random trajectory methods

Base.randMethod
rand(
    ::Type{NamedTrajectory},
    T::Int;
    timestep_value::Float64=1.0,
    timestep_name::Symbol=:Δt,
    free_time::Bool=false,
    timestep::Union{Float64,Symbol}=free_time ? timestep_name : timestep_value,
    state_dim::Int=3,
    control_dim::Int=2
)

Create a random NamedTrajectory with T time steps, a state variable x of dimension state_dim, and a control variable u of dimension control_dim. If free_time is true, the time step is a symbol timestep_name and the time step value is timestep_value. Otherwise, the time step is a number timestep_value.

source