GCOP
1.0
|
#include <trajectory.h>
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< Vectorcd > | us |
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< Vectorud > | 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 | |
Vectorpd * | p |
system parameters (optional, set to zero by default) |
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
typedef Matrix<double, nu, nu> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixcd |
typedef Matrix<double, nu, nx> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixcnd |
typedef Matrix<double, nx, nu> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixncd |
typedef Matrix<double, nx, nx> gcop::Trajectory< T, nx, nu, np, _ns >::Matrixnd |
typedef Matrix<double, nu, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorcd |
typedef Matrix<double, np, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectormd |
typedef Matrix<double, nx, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectornd |
typedef Matrix<double, _np, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorpd |
typedef Matrix<double, _ns, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorsd |
typedef Matrix<double, _nu, 1> gcop::Trajectory< T, nx, nu, np, _ns >::Vectorud |
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)
sys | mechanical system |
sn | trajectory parametrization vector length |
N | number of discrete segments (optional) |
virtual gcop::Trajectory< T, nx, nu, np, _ns >::~Trajectory | ( | ) | [virtual] |
Copy constructor
traj | a trajectory Copy assignment |
traj | a trajectory Initialize a trajectory from a serialized stream |
sys | mechanical system |
istr | stream |
gcop::Trajectory< T, _nx, _nu, _np >::Trajectory | ( | const System< T, _nx, _nu, _np > & | sys, |
int | N | ||
) |
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.
sn | new 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). |
sn | number of segments |
si | start state (optional) |
sf | final 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. |
traj | trajectory to be attached |
back | if true attach to back of this trajectory, else to the front |
time | if 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. |
js | if 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 |
s | state to be attached Clear all states along this trajectory and free associated memory. Set the path times starting from t0 with timestep h |
t0 | start time |
h | time 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. |
x | state |
u | control |
t | time |
p | static parameter (optional) |
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.
t | time |
void gcop::Trajectory< T, nx, nu, np, _ns >::Update | ( | ) | [virtual] |
Clone the trajectory
int gcop::Trajectory< T, nx, nu, np, _ns >::ns |
trajectory parameter dimension
Vectorpd* gcop::Trajectory< T, nx, nu, np, _ns >::p |
system parameters (optional, set to zero by default)
Vectormd gcop::Trajectory< T, nx, nu, np, _ns >::p |
static parameters (could be none)
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.
const System<T, _nx, _nu, _np>& gcop::Trajectory< T, nx, nu, np, _ns >::sys |
system
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.
traj | to 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. |
ti | initial time (must be within this trajectory) |
tf | final time (must be within this trajectory) |
a | number in [0,1] indicating where inside the segment to put the new point Resample the trajectory using sn new equaly spaced segments |
sn | new 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]. |
mn | number 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 |
t | given time |
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
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
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
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