API
NamedTrajectory methods
Base.merge
— Methodmerge(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.
Keyword Arguments
timestep::Symbol
: The timestep symbol to use for free time problems. Default to the last trajectory.merge_names::Union{Nothing, NamedTuple{<:Any, <:Tuple{Vararg{Int}}}}=nothing
: The names to merge by index.
NamedTrajectories.MethodsNamedTrajectory.add_component
— Methodadd_component(traj, name::Symbol, data::AbstractVecOrMat)
Add a component to the trajectory.
Keyword arguments: - type::Symbol
: The type of the component, can be :state
, :control
, :slack
, or :global
. Default is :state
.
NamedTrajectories.MethodsNamedTrajectory.add_components
— Methodadd_components(traj, comps)
Add components to the trajectory.
Keyword arguments: - type::Symbol
: The type of the component, can be :state
, :control
, :slack
, or :global
. Default is :state
.
NamedTrajectories.MethodsNamedTrajectory.add_suffix
— Functionadd_suffix(obj::T, suffix::String)
Add the suffix to the symbols of the object.
NamedTrajectories.MethodsNamedTrajectory.get_component_names
— Methodget_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.
NamedTrajectories.MethodsNamedTrajectory.get_components
— Methodget_components(names, ::NamedTrajectory)
Returns a NamedTuple containing the names and corresponding data matrices of the trajectory.
NamedTrajectories.MethodsNamedTrajectory.get_duration
— Methodget_duration(::NamedTrajectory)
Returns the duration of a trajectory.
NamedTrajectories.MethodsNamedTrajectory.get_suffix
— Functionget_suffix(obj::T, suffix::String; remove::Bool=false)
Get the data with the suffix from the object. Remove the suffix if remove=true
.
NamedTrajectories.MethodsNamedTrajectory.get_times
— Methodget_times(traj)::Vector{Float64}
Returns the times of a trajectory as a vector.
NamedTrajectories.MethodsNamedTrajectory.get_timesteps
— Methodget_timesteps(::NamedTrajectory)
Returns the timesteps of a trajectory as a vector.
NamedTrajectories.MethodsNamedTrajectory.merge_outer
— Methodmerge_outer(objs::AbstractVector{<:Any})
Merge objects. An error is reported if a key collision is detected.
NamedTrajectories.MethodsNamedTrajectory.remove_component
— Methodremove_component(traj, name::Symbol)
Remove a component from the trajectory.
NamedTrajectories.MethodsNamedTrajectory.remove_components
— Methodremove_components(traj, names::Vector{Symbol})
Remove a set of components from the trajectory.
NamedTrajectories.MethodsNamedTrajectory.remove_suffix
— Functionremove_suffix(obj::T, suffix::String)
Remove the suffix from the symbols of the object.
NamedTrajectories.MethodsNamedTrajectory.update!
— Methodupdate!(traj, datavec::AbstractVector{Float64})
Update the trajectory with a new datavec.
Keyword arguments: - type::Symbol
: The type of the datavec, can be :data
, :global
, or :both
. Default is global
.
NamedTrajectories.MethodsNamedTrajectory.update!
— Methodupdate!(traj, name::Symbol, data::AbstractMatrix{Float64})
Update a component of the trajectory.
NamedTrajectories.MethodsNamedTrajectory.update_bound!
— Methodupdate_bound!(traj, name, new_bound)
Update the bound of a component of the trajectory.
Base.getproperty
— Methodgetproperty(slice::KnotPoint, symb::Symbol)
Returns the component of the knot point with name symb
(as a view) or the property of the knot point with name symb
.
Base.setproperty!
— Methodsetproperty!(slice::KnotPoint, symb::Symbol, val::Any)
Dispatches setting properties of knot points as either setting a component or a property via update!
or setfield!
, respectively.
NamedTrajectories.MethodsKnotPoint.update!
— Methodupdate!(slice::KnotPoint, symb::Symbol, data::AbstractVector{Float64})
Update a component of the knot point.
Random trajectory methods
Base.rand
— Methodrand(
::Type{NamedTrajectory},
T::Int;
timestep_value::Float64=1.0,
timestep_name::Symbol=:Δt,
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
. The time step is a symbol timestep_name
and the time step value is timestep_value
.
Struct Methods
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— TypeNamedTrajectory{R <: Real}
Container for trajectory optimization problems, which includes the trajectory data, bounds dimensions, initial and final conditions, goal states, and components.
This struct is designed to hold trajectory data in a named format, allowing for easy access to knot points by Symbol
.
NamedTrajectory is designed to make allocation-free access easy to write. The data can be updated after construction, but the fields cannot.
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(component_data, global_components_data)
Construct a NamedTrajectory
from component data and global component data
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(component_data)
Construct a NamedTrajectory
from component data.
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(component_data::NamedTuple, timestep; kwargs...)
Construct a NamedTrajectory
from mixed Matrix/Vector component data.
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(data, traj)
Construct a NamedTrajectory
from an existing NamedTrajectory
.
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(data, components; kwargs...)
Construct a NamedTrajectory
from a data matrix and components.
NamedTrajectories.StructNamedTrajectory.NamedTrajectory
— MethodNamedTrajectory(datavec, components, T)
Construct a named trajectory from a data vector, components, and knot points.
NamedTrajectories.StructNamedTrajectory.get_bounds_from_dims
— Methodget_bounds_from_dims(bounds, dims; dtype=Float64)
Process bounds
from allowed types using dims
and convert to dtype
.
NamedTrajectories.StructNamedTrajectory.inspect_dims_pairs
— Methodinspect_dims_pairs(dims_pairs, bounds, initial, final, goal)
Check for proper formatting of trajectory components.
NamedTrajectories.StructNamedTrajectory.inspect_names
— Methodinspect_names(names, controls, initial, final, goal, bounds)
Check for missing names in the trajectory components.
NamedTrajectories.StructKnotPoint.KnotPoint
— TypeKnotPoint constructor
Trajectory Utilities
NamedTrajectories.Utils.derivative
— Methodderivative(X::AbstractMatrix, Δt::AbstractVecOrMat)
derivative(X::AbstractMatrix, Δt::Float64)
Compute the derivative of the data matrix X
.
NamedTrajectories.Utils.integral
— Methodintegral(X::AbstractMatrix, Δt::AbstractVector)
integral(X::AbstractMatrix, Δt::Float64)
Compute the integral of the data matrix X
.