Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <towr/constraints/base_motion_constraint.h>
00031 #include <towr/variables/variable_names.h>
00032 #include <towr/variables/cartesian_dimensions.h>
00033 #include <towr/variables/spline_holder.h>
00034
00035 namespace towr {
00036
00037
00038 BaseMotionConstraint::BaseMotionConstraint (const Parameters& params,
00039 const SplineHolder& spline_holder)
00040 :TimeDiscretizationConstraint(params.t_total_,
00041 params.dt_constraint_base_motion_,
00042 "BaseMotionConstraint")
00043 {
00044 base_linear_ = spline_holder.base_linear_;
00045 base_angular_ = spline_holder.base_angular_;
00046
00047 double dev_rad = 0.1;
00048 node_bounds_.resize(k6D);
00049 node_bounds_.at(AX) = ifopt::NoBound;
00050 node_bounds_.at(AY) = ifopt::NoBound;
00051 node_bounds_.at(AZ) = ifopt::NoBound;
00052 node_bounds_.at(LX) = ifopt::NoBound;
00053 node_bounds_.at(LY) = ifopt::NoBound;
00054
00055 double z_init = 0.46;
00056 node_bounds_.at(LZ) = Bounds(0.46, 0.55);
00057
00058 int n_constraints_per_node = node_bounds_.size();
00059 SetRows(GetNumberOfNodes()*n_constraints_per_node);
00060 }
00061
00062 void
00063 BaseMotionConstraint::UpdateConstraintAtInstance (double t, int k,
00064 VectorXd& g) const
00065 {
00066 g.middleRows(GetRow(k, LX), k3D) = base_linear_->GetPoint(t).p();
00067 g.middleRows(GetRow(k, AX), k3D) = base_angular_->GetPoint(t).p();
00068 }
00069
00070 void
00071 BaseMotionConstraint::UpdateBoundsAtInstance (double t, int k, VecBound& bounds) const
00072 {
00073 for (int dim=0; dim<node_bounds_.size(); ++dim)
00074 bounds.at(GetRow(k,dim)) = node_bounds_.at(dim);
00075 }
00076
00077 void
00078 BaseMotionConstraint::UpdateJacobianAtInstance (double t, int k,
00079 std::string var_set,
00080 Jacobian& jac) const
00081 {
00082 if (var_set == id::base_ang_nodes)
00083 jac.middleRows(GetRow(k,AX), k3D) = base_angular_->GetJacobianWrtNodes(t, kPos);
00084
00085 if (var_set == id::base_lin_nodes)
00086 jac.middleRows(GetRow(k,LX), k3D) = base_linear_->GetJacobianWrtNodes(t, kPos);
00087 }
00088
00089 int
00090 BaseMotionConstraint::GetRow (int node, int dim) const
00091 {
00092 return node*node_bounds_.size() + dim;
00093 }
00094
00095 }