Trajectories

When dealing with dynamical sytems, we often need to keep track of and represent trajectories of our system. RobotDynamics provides an AbstractTrajectory that can represent any trajectory, continuous or discrete. The only requirements on an AbstractTrajectory are that you can query the state and control at some time t, and that the trajectory has some notion of initial and final time for which it is defined.

RobotDynamics.AbstractTrajectoryType
AbstractTrajectory

An abstract representation of a state and control trajectory.

Required methodsBrief description
getstate(Z, t)Get the state at time t.
getcontrol(Z, t)Get the control at time t.
getinitialtime(Z)Get the initial time of the trajectory.
getfinaltime(Z)Get the final time of the trajectory.

One convenient way of representing a trajectory is by sampling the states and controls along it. RobotDynamics provides the SampledTrajectory type which is basically a vector of AbstractKnotPoint types. This is described by the following API:

RobotDynamics.SampledTrajectoryType
SampledTrajectory{Nx,Nu,T,KP} <: AbstractTrajectory

A trajectory represented by a sample of knot points. A vector of AbstractKnotPoints of type KP with state dimension Nx, control dimension Nu, and value type T.

Supports iteration and indexing.

Constructors

SampledTrajectory{Nx,Nu}(n, m; [equal, dt, tf, N])
SampledTrajectory{Nx,Nu}(X, U; [dt, tf, N=length(X)])

SampledTrajectory(n, m; [equal, dt, tf, N])
SampledTrajectory(X, U; [dt, tf, N=length(X)])

where at least 2 of dt, tf, or N must be specified. The length N is automatically inferred when passing in state and control trajectories X and U, which can either be vectors of vectors or a 2D matrix whose 2nd dimension is time.

RobotDynamics.statesFunction
states(Z)
states(Z, i::Integer)
states(Z, inds)

Get a list of all the state vectors for the trajectory Z. Passing an integer extracts a vector of the ith state. Passing a vector of integers provides a list of N-dimensional vectors, containing the time history for each state index in the vector.

RobotDynamics.controlsFunction
controls(Z)
controls(Z, i::Integer)
controls(Z, inds)

Get a list of all the control vectors for the trajectory Z. Passing an integer extracts a vector of the ith control. Passing a vector of integers provides a list of N-dimensional vectors, containing the time history for each control index in the vector.

RobotDynamics.setstates!Function
setstates!(Z, X)

Set the states of a trajectory Z, where X can be a vector of vectors or a matrix of size (n,N).

RobotDynamics.setcontrols!Function
setcontrols!(Z, U)

Set the controls of a trajectory Z, where U can be a vector of vectors or a matrix of size (m,N) or a single vector of size (m,), which will be copied to all the time steps.

RobotDynamics.setinitialtime!Function
setinitialtime!(Z, t0)

Set the initial time of the trajectory, shifting all of the times by the required amount.