tsid 1.9.0
Efficient Task Space Inverse Dynamics for Multi-body Systems based on Pinocchio
Loading...
Searching...
No Matches
container.hpp
Go to the documentation of this file.
1//
2// Copyright (c) 2018 CNRS
3//
4// This file is part of tsid
5// tsid is free software: you can redistribute it
6// and/or modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation, either version
8// 3 of the License, or (at your option) any later version.
9// tsid is distributed in the hope that it will be
10// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
11// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Lesser Public License for more details. You should have
13// received a copy of the GNU Lesser General Public License along with
14// tsid If not, see
15// <http://www.gnu.org/licenses/>.
16//
17
18#ifndef __tsid_python_util_container_hpp__
19#define __tsid_python_util_container_hpp__
20
22
27
28using namespace std;
29namespace tsid {
30namespace python {
33
35 public:
38
39 inline void print() {
40 stringstream ss;
41 for (ConstraintLevel::const_iterator iit = m_std_const.begin();
42 iit != m_std_const.end(); iit++) {
43 auto c = iit->second;
44 ss << " - " << c->name() << ": w=" << iit->first << ", ";
45 if (c->isEquality())
46 ss << "equality, ";
47 else if (c->isInequality())
48 ss << "inequality, ";
49 else
50 ss << "bound, ";
51 ss << c->rows() << "x" << c->cols() << endl;
52 }
53 cout << ss.str() << endl;
54 }
55 inline ConstraintLevel& get() { return m_std_const; }
56
57 inline void append_eq(double num,
58 std::shared_ptr<math::ConstraintEquality> i) {
59 m_std_const.push_back(
60 solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num,
61 i));
62 }
63 inline void append_ineq(double num,
64 std::shared_ptr<math::ConstraintInequality> i) {
65 m_std_const.push_back(
66 solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num,
67 i));
68 }
69 inline void append_bound(double num,
70 std::shared_ptr<math::ConstraintBound> i) {
71 m_std_const.push_back(
72 solvers::make_pair<double, std::shared_ptr<math::ConstraintBase> >(num,
73 i));
74 }
75
76 private:
77 ConstraintLevel m_std_const;
78};
79
80class HQPDatas {
81 public:
84
85 inline void resize(size_t i) { m_std_hqp.resize(i); }
86
87 inline void print() const {
88 stringstream ss;
89 unsigned int priority = 0;
90 for (HQPData::const_iterator it = m_std_hqp.begin(); it != m_std_hqp.end();
91 it++) {
92 ss << "Level " << priority << endl;
93 for (ConstraintLevel::const_iterator iit = it->begin(); iit != it->end();
94 iit++) {
95 auto c = iit->second;
96 ss << " - " << c->name() << ": w=" << iit->first << ", ";
97 if (c->isEquality())
98 ss << "equality, ";
99 else if (c->isInequality())
100 ss << "inequality, ";
101 else
102 ss << "bound, ";
103 ss << c->rows() << "x" << c->cols() << endl;
104 }
105 priority++;
106 }
107 cout << ss.str() << endl;
108 }
109 // inline void append (ConstraintLevel cons){
110 // m_std_hqp.push_back(cons);
111 // }
112 inline void append_helper(ConstraintLevels* cons) {
113 m_std_hqp.push_back(cons->get());
114 }
115
116 inline HQPData& get() { return m_std_hqp; }
117 inline bool set(const HQPData& data) {
118 m_std_hqp = data;
119 return true;
120 }
121
122 private:
123 HQPData m_std_hqp;
124};
125} // namespace python
126} // namespace tsid
127
128#endif // ifndef __tsid_python_util_container_hpp__
Definition container.hpp:34
void print()
Definition container.hpp:39
~ConstraintLevels()
Definition container.hpp:37
ConstraintLevel & get()
Definition container.hpp:55
ConstraintLevels()
Definition container.hpp:36
void append_bound(double num, std::shared_ptr< math::ConstraintBound > i)
Definition container.hpp:69
void append_eq(double num, std::shared_ptr< math::ConstraintEquality > i)
Definition container.hpp:57
void append_ineq(double num, std::shared_ptr< math::ConstraintInequality > i)
Definition container.hpp:63
bool set(const HQPData &data)
Definition container.hpp:117
void append_helper(ConstraintLevels *cons)
Definition container.hpp:112
HQPDatas()
Definition container.hpp:82
~HQPDatas()
Definition container.hpp:83
HQPData & get()
Definition container.hpp:116
void print() const
Definition container.hpp:87
void resize(size_t i)
Definition container.hpp:85
Definition constraint-bound.hpp:26
solvers::HQPData HQPData
Definition container.hpp:32
solvers::ConstraintLevel ConstraintLevel
Definition container.hpp:31
pinocchio::container::aligned_vector< ConstraintLevel > HQPData
Definition fwd.hpp:99
aligned_pair< T1, T2 > make_pair(const T1 &t1, const T2 &t2)
Definition fwd.hpp:89
pinocchio::container::aligned_vector< aligned_pair< double, std::shared_ptr< math::ConstraintBase > > > ConstraintLevel
Definition fwd.hpp:95
Definition constraint-bound.hpp:25