NamedTrajectories.jl is a package for working with trajectories of named variables. It is designed to be used with the Piccolo.jl ecosystem.
NamedTrajectories.jl is registered! Install in the REPL by entering pkg mode with ]
and then running
pkg> add NamedTrajectories
or to install the latest master branch run
pkg> add NamedTrajectories#main
- Abstract away messy indexing and vectorization details required for interfacing with numerical solvers.
- Easily handle multiple trajectories with different names, e.g. various states and controls.
- Simple plotting of trajectories.
- Provide a variety of helpful methods for common tasks.
Users can define NamedTrajectory
types which have lots of useful functionality. For example, you can access the data by name or index. In the case of an index, a KnotPoint
is returned which contains the data for that timestep.
using NamedTrajectories
# define number of timesteps and timestep
T = 10
dt = 0.1
# build named tuple of components and data matrices
components = (
x = rand(3, T),
u = rand(2, T),
)
# build trajectory
traj = NamedTrajectory(components; timestep=dt, controls=:u)
# access data by name
traj.x # returns 3x10 matrix of x data
traj.u # returns 2x10 matrix of u data
z1 = traj[1] # returns KnotPoint with x and u data
z1.x # returns 3 element vector of x data at timestep 1
z1.u # returns 2 element vector of u data at timestep 1
traj.data # returns data as 5x10 matrix
traj.names # returns names as tuple (:x, :u)
NamedTrajectories.jl is designed to aid in the messy indexing involved in solving trajectory optimization problems of the form
where
In more detail, this problem might look something like
where
It is common practice in trajectory optimization to bundle all of the state and control variables together into a single knot point
The trajectory optimization problem can then be succinctly written as
The NamedTrajectories
package provides a NamedTrajectory
type which abstracts away the messy indexing and vectorization details required for interfacing with numerical solvers. It also provides a variety of helpful methods for common tasks. For example, you can access the data by name or index. In the case of an index, a KnotPoint
is returned which contains the data for that timestep.