base_motion_constraint.cc
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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;//Bounds(-dev_rad, dev_rad); euler angles bounds!
00050   node_bounds_.at(AY) = ifopt::NoBound;//Bounds(-dev_rad, dev_rad);
00051   node_bounds_.at(AZ) = ifopt::NoBound;//Bounds(-dev_rad, dev_rad); // NoBound
00052   node_bounds_.at(LX) = ifopt::NoBound;
00053   node_bounds_.at(LY) = ifopt::NoBound;//Bounds(-0.05, 0.05);
00054 
00055   double z_init = 0.46;//base_linear_.GetPoint(0.0).p().z();
00056   node_bounds_.at(LZ) = Bounds(0.46, 0.55); // allow to move dev_z cm up and down
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 } /* namespace towr */


towr_core
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 9 2018 03:12:44