GCOP  1.0
Public Types | Public Member Functions | Public Attributes
gcop::Trajectory< T, nx, nu, np, _ns > Class Template Reference

#include <trajectory.h>

Collaboration diagram for gcop::Trajectory< T, nx, nu, np, _ns >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef Matrix< double, nx, 1 > Vectornd
typedef Matrix< double, nu, 1 > Vectorcd
typedef Matrix< double, nx, nx > Matrixnd
typedef Matrix< double, nx, nu > Matrixncd
typedef Matrix< double, nu, nx > Matrixcnd
typedef Matrix< double, nu, nu > Matrixcd
typedef Matrix< double, np, 1 > Vectormd
typedef Matrix< double, _ns, 1 > Vectorsd
typedef Matrix< double, _nu, 1 > Vectorud
typedef Matrix< double, _np, 1 > Vectorpd

Public Member Functions

 Trajectory (const System< T, nx, nu, np > &sys, int ns=0, int N=0)
virtual ~Trajectory ()
virtual bool Update ()
virtual bool Get (T &x, Vectorcd &u, double t) const
int Get (double t) const
 Trajectory (const System< T, _nx, _nu, _np > &sys, int N)

Public Attributes

const System< T, nx, nu, np > & sys
 mechanical system
int ns
 trajectory parameter dimension
Vectorsd s
 continuous trajectory parametrization vector (this given vector should uniqely determine the whole continuous trajectory, typically together with a given initial state x0 and initial time t0). Examples of what s should be include: 1) simply a discrete sequence of constant controls applied during each discrete time-segment (this is the default -- in which case, s represents the sequence of controls us); 2) interpolating points for more general control curve parametrization using spline basis functions, 3) interpolating points for flat output parametrization using spline basis functions, 4) both control, state, and static params parametrizations often requires for direct collocation/multiple-shooting methods.
vector< double > ts
 sequence of times (length is N+1, and always at least 1 element, the first is the start time t0)
vector< T > xs
 sequence of states (length is N+1, and always at least 1, the first is the start state x0)
vector< Vectorcdus
 sequence of controls (length is N), i.e. i-th control is regarded as the average control input over i-th segment
Vectormd p
 static parameters (could be none)
const System< T, _nx, _nu, _np > & sys
 system
vector< Vectorudus
 sequence of (N) control inputs (regarded as paremetrizing the control signal along the i-th segment, for i=0,...,N-1) e.g. constant control during the interval $[t_k,t_{k+1}]$
Vectorpdp
 system parameters (optional, set to zero by default)

Detailed Description

template<typename T, int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
class gcop::Trajectory< T, nx, nu, np, _ns >

Basic control system trajectory represented by a set of discrete nodes

This should serve as a base class for implementing trajectories for a particular mechanical system described by the System class

Author: Marin Kobilarov -- Copyright (C) 2006

A container for generic trajectory (this could be discrete or continuous) but in any case we contain a discrete-time representation for computational/visualization purposes

Author: Marin Kobilarov (c) marin(at)jhu.edu


Member Typedef Documentation

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nu, nu> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixcd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nu, nx> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixcnd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nx, nu> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixncd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nx, nx> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixnd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nu, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorcd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, np, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectormd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, nx, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectornd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, _np, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorpd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, _ns, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorsd
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
typedef Matrix<double, _nu, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorud

Constructor & Destructor Documentation

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
gcop::Trajectory< T, nx, nu, np, _ns >::Trajectory ( const System< T, nx, nu, np > &  sys,
int  ns = 0,
int  N = 0 
)

Initialize a trajectory for the system sys Once a trajectory is initialized with this constructor one should call Init(sn,...) with the appropriate number of discrete points desired. Otherwise the trajectory would contain only one point (usually the origin)

Parameters:
sysmechanical system
sntrajectory parametrization vector length
Nnumber of discrete segments (optional)
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
virtual gcop::Trajectory< T, nx, nu, np, _ns >::~Trajectory ( ) [virtual]

Copy constructor

Parameters:
traja trajectory Copy assignment
traja trajectory Initialize a trajectory from a serialized stream
sysmechanical system
istrstream
template<typename T , int _nx, int _nu, int _np>
gcop::Trajectory< T, _nx, _nu, _np >::Trajectory ( const System< T, _nx, _nu, _np > &  sys,
int  N 
)

Member Function Documentation

template<typename T , int nx, int nu, int np, int _ns>
bool gcop::Trajectory< T, nx, nu, np, _ns >::Get ( T &  x,
Vectorcd u,
double  t 
) const [virtual]

Resize the discrete trajectory keeping any previous states and if necessary adding empty states at the end.

Parameters:
snnew number of discrete segments Reverse the states+control alongs trajectory. keep same times Initialize the trajectory using sn segments and optionally (if both si and sf are povided) interpolate the states between states si and sf. In fact, Init(sn) is equivalent to Resize(sn).
snnumber of segments
sistart state (optional)
sffinal state (optional) Attach trajectory traj to this trajectory. This trajectory is modified and its size becomes as explained below. This operation is fairly efficient since it is based on raw memory manipulation.
trajtrajectory to be attached
backif true attach to back of this trajectory, else to the front
timeif true then adjust time along the newly added states by incrementing/decrementing each state's time based on the last/first state's time in the current trajectory depending on whether attaching to back/front, respectively.
jsif true then treat the end point of this trajectory and the first point of the given trajectory traj as the same points (with same time)--in this case the total number of segments would be this->sn + traj.sn, otherwise it is this->sn + traj.sn + 1 void Attach(const Trajectory<T, nx, nu, np, _ns> &traj, bool back = true, bool time = false, bool js = true); Append a state to the end of this trajectory
sstate to be attached Clear all states along this trajectory and free associated memory. Set the path times starting from t0 with timestep h
t0start time
htime step Get the state at time t (t should already be set in the state s) t should be in the valid range of trajectory times. This uses the base interpolation define in System::Get. For now this method assumes that all segments have equal time duration.
xstate
ucontrol
ttime
pstatic parameter (optional)
Returns:
true if arguments are feasible
template<typename T , int nx, int nu, int np, int _ns>
int gcop::Trajectory< T, nx, nu, np, _ns >::Get ( double  t) const

Get the index of trajectory segment in which time t falls. For now this method assumes that all segments have equal time duration.

Parameters:
ttime
Returns:
discrete trajectory segment where t falls (returns -1 if t is out of bounds)
template<typename T , int nx, int nu, int np, int _ns>
void gcop::Trajectory< T, nx, nu, np, _ns >::Update ( ) [virtual]

Clone the trajectory

Returns:
a copy of this trajectory Updates the discrete trajectory using the parameter vector s, i.e. : s -> (ts,xs,us,p)
true if the resulting discrete trajectory is feasible

Member Data Documentation

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
int gcop::Trajectory< T, nx, nu, np, _ns >::ns

trajectory parameter dimension

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
Vectorpd* gcop::Trajectory< T, nx, nu, np, _ns >::p

system parameters (optional, set to zero by default)

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
Vectormd gcop::Trajectory< T, nx, nu, np, _ns >::p

static parameters (could be none)

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
Vectorsd gcop::Trajectory< T, nx, nu, np, _ns >::s

continuous trajectory parametrization vector (this given vector should uniqely determine the whole continuous trajectory, typically together with a given initial state x0 and initial time t0). Examples of what s should be include: 1) simply a discrete sequence of constant controls applied during each discrete time-segment (this is the default -- in which case, s represents the sequence of controls us); 2) interpolating points for more general control curve parametrization using spline basis functions, 3) interpolating points for flat output parametrization using spline basis functions, 4) both control, state, and static params parametrizations often requires for direct collocation/multiple-shooting methods.

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
const System<T, _nx, _nu, _np>& gcop::Trajectory< T, nx, nu, np, _ns >::sys

system

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
const System<T, nx, nu, np>& gcop::Trajectory< T, nx, nu, np, _ns >::sys

mechanical system

Get a subtrajectory given two starting times. Utilizes the System::Get implementation.

Parameters:
trajto be filled in (the number of discrete segments traj.sn is used to determine the time step, so the discrete length of traj is not modified). Hence, one should pass traj with already existing states, and with traj->sn >0. If traj->sn=0 then just use GetState.
tiinitial time (must be within this trajectory)
tffinal time (must be within this trajectory)
Returns:
true if arguments are feasible Add a point interpolated at s inside every trajectory segment new trajectory has 2*sn+1 points
Parameters:
anumber in [0,1] indicating where inside the segment to put the new point Resample the trajectory using sn new equaly spaced segments
snnew number of discrete segments Add mn new states to the trajectory after points with indices in mi and interpolated between states at indices mi[i] and mi[i+1] using the number mu[i] in [0,1].
mnnumber of new states to insert in the trajectory
mi(mn-array) indices of old states after which the new point will be inserted
mu(mn-array) numbers in the range [0,1] indicating where in the mi[i]-th segment the new state will be interpolated Checks whether this trajectory contains time t
tgiven time
Returns:
true if t is between the start and end times of the trajectory
template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
vector< double > gcop::Trajectory< T, nx, nu, np, _ns >::ts

sequence of times (length is N+1, and always at least 1 element, the first is the start time t0)

sequence of (N+1) times

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
vector<Vectorud> gcop::Trajectory< T, nx, nu, np, _ns >::us

sequence of (N) control inputs (regarded as paremetrizing the control signal along the i-th segment, for i=0,...,N-1) e.g. constant control during the interval $[t_k,t_{k+1}]$

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
vector<Vectorcd> gcop::Trajectory< T, nx, nu, np, _ns >::us

sequence of controls (length is N), i.e. i-th control is regarded as the average control input over i-th segment

template<typename T , int nx = Dynamic, int nu = Dynamic, int np = Dynamic, int _ns = Dynamic>
vector< T > gcop::Trajectory< T, nx, nu, np, _ns >::xs

sequence of states (length is N+1, and always at least 1, the first is the start state x0)

sequence of (N+1) states


The documentation for this class was generated from the following files: