nlp_factory.h
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
30 #ifndef TOWR_NLP_FACTORY_H_
31 #define TOWR_NLP_FACTORY_H_
32 
33 #include <ifopt/variable_set.h>
34 #include <ifopt/constraint_set.h>
35 #include <ifopt/cost_term.h>
36 
38 
39 #include "robot_model.h"
40 #include "height_map.h"
41 #include "parameters.h"
42 
43 namespace towr {
44 
51 class NlpFactory {
52 public:
53  using VariablePtrVec = std::vector<ifopt::VariableSet::Ptr>;
54  using ContraintPtrVec = std::vector<ifopt::ConstraintSet::Ptr>;
55  using CostPtrVec = std::vector<ifopt::CostTerm::Ptr>;
56  using EEPos = std::vector<Eigen::Vector3d>;
57  using Vector3d = Eigen::Vector3d;
58 
59  NlpFactory () = default;
60  virtual ~NlpFactory () = default;
61 
66 
71 
75  ContraintPtrVec GetCosts() const;
76 
77 
84 
86 
87 private:
88  // variables
89  std::vector<Nodes::Ptr> MakeBaseVariables() const;
90  std::vector<PhaseNodes::Ptr> MakeEndeffectorVariables() const;
91  std::vector<PhaseNodes::Ptr> MakeForceVariables() const;
92  std::vector<PhaseDurations::Ptr> MakeContactScheduleVariables() const;
93 
94  // constraints
104 
105  // costs
106  CostPtrVec GetCost(const CostName& id, double weight) const;
107  CostPtrVec MakeForcesCost(double weight) const;
108 };
109 
110 } /* namespace towr */
111 
112 #endif /* TOWR_NLP_FACTORY_H_ */
BaseState initial_base_
Definition: nlp_factory.h:78
ContraintPtrVec GetConstraints() const
Definition: nlp_factory.cc:195
ContraintPtrVec GetConstraint(ConstraintName name) const
Definition: nlp_factory.cc:206
CostPtrVec GetCost(const CostName &id, double weight) const
Definition: nlp_factory.cc:334
ContraintPtrVec MakeTotalTimeConstraint() const
Definition: nlp_factory.cc:254
std::vector< ifopt::ConstraintSet::Ptr > ContraintPtrVec
Definition: nlp_factory.h:54
ContraintPtrVec MakeForceConstraint() const
Definition: nlp_factory.cc:281
std::vector< PhaseNodes::Ptr > MakeEndeffectorVariables() const
Definition: nlp_factory.cc:108
Holds pointers to the robot specific kinematics and dynamics.
Definition: robot_model.h:41
VariablePtrVec GetVariableSets()
Definition: nlp_factory.cc:51
virtual ~NlpFactory()=default
NlpFactory()=default
std::vector< Eigen::Vector3d > EEPos
Definition: nlp_factory.h:56
std::vector< PhaseDurations::Ptr > MakeContactScheduleVariables() const
Definition: nlp_factory.cc:177
ContraintPtrVec MakeTerrainConstraint() const
Definition: nlp_factory.cc:268
ContraintPtrVec GetCosts() const
Definition: nlp_factory.cc:323
ContraintPtrVec MakeRangeOfMotionBoxConstraint() const
Definition: nlp_factory.cc:238
std::vector< PhaseNodes::Ptr > MakeForceVariables() const
Definition: nlp_factory.cc:150
std::vector< ifopt::VariableSet::Ptr > VariablePtrVec
Definition: nlp_factory.h:53
Holds pointers to fully constructed splines, that are linked to the optimization variables.
Definition: spline_holder.h:46
std::vector< ifopt::CostTerm::Ptr > CostPtrVec
Definition: nlp_factory.h:55
ContraintPtrVec MakeSwingConstraint() const
Definition: nlp_factory.cc:296
Can represent the 6Degree-of-Freedom floating base of a robot.
Definition: state.h:122
ContraintPtrVec MakeBaseRangeOfMotionConstraint() const
Definition: nlp_factory.cc:223
Parameters params_
Definition: nlp_factory.h:83
Eigen::Vector3d Vector3d
Definition: nlp_factory.h:57
ConstraintName
Definition: parameters.h:38
ContraintPtrVec MakeBaseAccConstraint() const
Definition: nlp_factory.cc:309
Holds the parameters to tune the optimization problem.
Definition: parameters.h:45
CostPtrVec MakeForcesCost(double weight) const
Definition: nlp_factory.cc:343
ContraintPtrVec MakeDynamicConstraint() const
Definition: nlp_factory.cc:229
BaseState final_base_
Definition: nlp_factory.h:79
RobotModel model_
Definition: nlp_factory.h:81
CostName
Definition: parameters.h:40
SplineHolder spline_holder_
Definition: nlp_factory.h:85
std::shared_ptr< HeightMap > Ptr
Definition: height_map.h:55
std::vector< Nodes::Ptr > MakeBaseVariables() const
Definition: nlp_factory.cc:82
HeightMap::Ptr terrain_
Definition: nlp_factory.h:82


towr_core
Author(s): Alexander W. Winkler
autogenerated on Sat Apr 7 2018 02:15:57