Position and velocity of nodes used to generate a Hermite spline. More...
#include <nodes_variables.h>
Classes | |
struct | NodeValueInfo |
Semantic information associated with a scalar node value. More... | |
Public Types | |
enum | Side { Start = 0, End } |
Public Member Functions | |
void | AddFinalBound (Dx deriv, const std::vector< int > &dimensions, const VectorXd &val) |
Restricts the last node in the spline. | |
void | AddObserver (ObserverPtr const spline) |
Adds a dependent observer that gets notified when the nodes change. | |
void | AddStartBound (Dx deriv, const std::vector< int > &dimensions, const VectorXd &val) |
Restricts the first node in the spline. | |
const std::vector< Node > | GetBoundaryNodes (int poly_id) const |
VecBound | GetBounds () const override |
int | GetDim () const |
const std::vector< Node > | GetNodes () const |
virtual std::vector < NodeValueInfo > | GetNodeValuesInfo (int opt_idx) const =0 |
Node values affected by one specific optimization variable. | |
int | GetOptIndex (const NodeValueInfo &nvi) const |
Index in the optimization vector for a specific nodes' pos/vel. | |
int | GetPolynomialCount () const |
VectorXd | GetValues () const override |
Pure optimization variables that define the nodes. | |
void | SetByLinearInterpolation (const VectorXd &initial_val, const VectorXd &final_val, double t_total) |
Sets nodes pos/vel equally spaced from initial to final position. | |
void | SetVariables (const VectorXd &x) override |
Sets some node positions and velocity from the optimization variables. | |
Static Public Member Functions | |
static int | GetNodeId (int poly_id, Side side) |
The node ID that belongs to a specific side of a specific polynomial. | |
Static Public Attributes | |
static const int | NodeValueNotOptimized = -1 |
Protected Member Functions | |
NodesVariables (const std::string &variable_name) | |
virtual | ~NodesVariables () |
Protected Attributes | |
VecBound | bounds_ |
the bounds on the node values. | |
int | n_dim_ |
std::vector< Node > | nodes_ |
Private Member Functions | |
void | AddBound (const NodeValueInfo &node_info, double value) |
Restricts a specific optimization variables. | |
void | AddBounds (int node_id, Dx deriv, const std::vector< int > &dim, const VectorXd &values) |
Bounds a specific node variables. | |
void | UpdateObservers () const |
Notifies the subscribed observers that the node values changes. | |
Private Attributes | |
std::vector< ObserverPtr > | observers_ |
Position and velocity of nodes used to generate a Hermite spline.
#### Four nodes defining a single spline (e.g. foot position in x-direction)
Instead of setting the polynomial coefficients directly, a third-order polynomial is also fully defined by the value and first-derivative of the start and end of the polynomial as well as the duration. This class holds these node values composed of position and velocity.
In the above image the nodes are defined by the scalar position and velocity values x0, x0d, ..., xT, xTd. By optimizing over these nodes, different spline shapes are generated. It is important to note that **not all node values must be optimized over**. We can fix specific node values in advance, or _one_ optimization variables can represent _multiple_ nodes values in the spline. This is exploited in the subclass NodesVariablesPhaseBased using _Phase-based End-effector Parameterization_.
Definition at line 71 of file nodes_variables.h.
Definition at line 159 of file nodes_variables.h.
towr::NodesVariables::NodesVariables | ( | const std::string & | variable_name | ) | [protected] |
n_dim | The number of dimensions (x,y,..) each node has. |
variable_name | The name of the variables in the optimization problem. |
Definition at line 35 of file nodes_variables.cc.
virtual towr::NodesVariables::~NodesVariables | ( | ) | [protected, virtual] |
void towr::NodesVariables::AddBound | ( | const NodeValueInfo & | node_info, |
double | value | ||
) | [private] |
Restricts a specific optimization variables.
node_info | The specs of the optimization variables to restrict. |
value | The value to set the bounds to. |
Definition at line 162 of file nodes_variables.cc.
void towr::NodesVariables::AddBounds | ( | int | node_id, |
Dx | deriv, | ||
const std::vector< int > & | dim, | ||
const VectorXd & | values | ||
) | [private] |
Bounds a specific node variables.
node_id | The ID of the node to bound. |
deriv | The derivative of the node to set. |
dim | The dimension of the node to bound. |
values | The values to set the bounds to. |
Definition at line 153 of file nodes_variables.cc.
void towr::NodesVariables::AddFinalBound | ( | Dx | deriv, |
const std::vector< int > & | dimensions, | ||
const VectorXd & | val | ||
) |
Restricts the last node in the spline.
deriv | Which derivative (pos,vel,...) should be restricted. |
dimensions | Which dimensions (x,y,z) should be restricted. |
val | The values the last node should be set to. |
Definition at line 177 of file nodes_variables.cc.
void towr::NodesVariables::AddObserver | ( | ObserverPtr const | spline | ) |
Adds a dependent observer that gets notified when the nodes change.
spline | Usually a pointer to a spline which uses the node values. |
Definition at line 82 of file nodes_variables.cc.
void towr::NodesVariables::AddStartBound | ( | Dx | deriv, |
const std::vector< int > & | dimensions, | ||
const VectorXd & | val | ||
) |
Restricts the first node in the spline.
deriv | Which derivative (pos,vel,...) should be restricted. |
dimensions | Which dimensions (x,y,z) should be restricted. |
val | The values the fist node should be set to. |
Definition at line 171 of file nodes_variables.cc.
const std::vector< Node > towr::NodesVariables::GetBoundaryNodes | ( | int | poly_id | ) | const |
Definition at line 94 of file nodes_variables.cc.
NodesVariables::VecBound towr::NodesVariables::GetBounds | ( | ) | const [override] |
Definition at line 115 of file nodes_variables.cc.
int towr::NodesVariables::GetDim | ( | ) | const |
Definition at line 103 of file nodes_variables.cc.
int towr::NodesVariables::GetNodeId | ( | int | poly_id, |
Side | side | ||
) | [static] |
The node ID that belongs to a specific side of a specific polynomial.
poly_id | The ID of the polynomial within the spline. |
side | The side from which the node ID is required. |
Definition at line 88 of file nodes_variables.cc.
const std::vector< Node > towr::NodesVariables::GetNodes | ( | ) | const |
Definition at line 121 of file nodes_variables.cc.
virtual std::vector<NodeValueInfo> towr::NodesVariables::GetNodeValuesInfo | ( | int | opt_idx | ) | const [pure virtual] |
Node values affected by one specific optimization variable.
opt_idx | The index (=row) of the optimization variable. |
This function determines which node values are optimized over, and which nodes values are set by the same optimization variable.
Reverse of GetOptIndex().
Implemented in towr::NodesVariablesPhaseBased, and towr::NodesVariablesAll.
int towr::NodesVariables::GetOptIndex | ( | const NodeValueInfo & | nvi | ) | const |
Index in the optimization vector for a specific nodes' pos/vel.
nvi | Description of node value we want to know the index for. |
Reverse of GetNodeInfoAtOptIndex().
Definition at line 41 of file nodes_variables.cc.
int towr::NodesVariables::GetPolynomialCount | ( | ) | const |
Definition at line 109 of file nodes_variables.cc.
Eigen::VectorXd towr::NodesVariables::GetValues | ( | ) | const [override] |
Pure optimization variables that define the nodes.
Not all node position and velocities are independent or optimized over, so usually the number of optimization variables is less than all nodes' pos/vel.
Definition at line 53 of file nodes_variables.cc.
void towr::NodesVariables::SetByLinearInterpolation | ( | const VectorXd & | initial_val, |
const VectorXd & | final_val, | ||
double | t_total | ||
) |
Sets nodes pos/vel equally spaced from initial to final position.
initial_val | value of the first node. |
final_val | value of the final node. |
t_total | The total duration to reach final node (to set velocities). |
Definition at line 127 of file nodes_variables.cc.
void towr::NodesVariables::SetVariables | ( | const VectorXd & | x | ) | [override] |
Sets some node positions and velocity from the optimization variables.
x | The optimization variables. |
Not all node position and velocities are independent or optimized over, so usually the number of optimization variables is less than all nodes pos/vel.
Definition at line 65 of file nodes_variables.cc.
void towr::NodesVariables::UpdateObservers | ( | ) | const [private] |
Notifies the subscribed observers that the node values changes.
Definition at line 75 of file nodes_variables.cc.
VecBound towr::NodesVariables::bounds_ [protected] |
the bounds on the node values.
Definition at line 214 of file nodes_variables.h.
int towr::NodesVariables::n_dim_ [protected] |
Definition at line 216 of file nodes_variables.h.
std::vector<Node> towr::NodesVariables::nodes_ [protected] |
Definition at line 215 of file nodes_variables.h.
const int towr::NodesVariables::NodeValueNotOptimized = -1 [static] |
Definition at line 115 of file nodes_variables.h.
std::vector<ObserverPtr> towr::NodesVariables::observers_ [private] |
Definition at line 223 of file nodes_variables.h.