formulation.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018 CNRS, NYU, MPI Tübingen
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_HQPOutput_hpp__
19 #define __tsid_python_HQPOutput_hpp__
20 
22 
23 #include <pinocchio/bindings/python/utils/deprecation.hpp>
24 
40 
41 namespace tsid {
42 namespace python {
43 namespace bp = boost::python;
44 
45 template <typename T>
47  : public boost::python::def_visitor<InvDynPythonVisitor<T> > {
48  template <class PyClass>
49 
50  void visit(PyClass& cl) const {
51  cl.def(bp::init<std::string, robots::RobotWrapper&, bool>(
52  (bp::args("name", "robot", "verbose"))))
53  .def("data", &InvDynPythonVisitor::data)
54  .add_property("nVar", &T::nVar)
55  .add_property("nEq", &T::nEq)
56  .add_property("nIn", &T::nIn)
57 
58  .def("addMotionTask", &InvDynPythonVisitor::addMotionTask_SE3,
59  bp::args("task", "weight", "priorityLevel", "transition duration"))
60  .def("addMotionTask", &InvDynPythonVisitor::addMotionTask_COM,
61  bp::args("task", "weight", "priorityLevel", "transition duration"))
62  .def("addMotionTask", &InvDynPythonVisitor::addMotionTask_Joint,
63  bp::args("task", "weight", "priorityLevel", "transition duration"))
65  bp::args("task", "weight", "priorityLevel", "transition duration"))
66  .def("addMotionTask",
68  bp::args("task", "weight", "priorityLevel", "transition duration"))
69  .def("addMotionTask", &InvDynPythonVisitor::addMotionTask_AM,
70  bp::args("task", "weight", "priorityLevel", "transition duration"))
71  .def("addMotionTask",
73  bp::args("task", "weight", "priorityLevel", "transition duration"))
74  .def("addForceTask", &InvDynPythonVisitor::addForceTask_COP,
75  bp::args("task", "weight", "priorityLevel", "transition duration"))
76  .def("addActuationTask", &InvDynPythonVisitor::addActuationTask_Bounds,
77  bp::args("task", "weight", "priorityLevel", "transition duration"))
78  .def("updateTaskWeight", &InvDynPythonVisitor::updateTaskWeight,
79  bp::args("task_name", "weight"))
80  .def("updateRigidContactWeights",
82  bp::args("contact_name", "force_regularization_weight"))
83  .def("updateRigidContactWeights",
85  bp::args("contact_name", "force_regularization_weight",
86  "motion_weight"))
87  .def("addRigidContact",
89  bp::args("contact"),
91  "Method addRigidContact(ContactBase) is deprecated. You "
92  "should use addRigidContact(ContactBase, double) instead"))
93  .def("addRigidContact", &InvDynPythonVisitor::addRigidContact6d,
94  bp::args("contact", "force_reg_weight"))
95  .def("addRigidContact",
97  bp::args("contact", "force_reg_weight", "motion_weight",
98  "priority_level"))
99  .def("addRigidContact", &InvDynPythonVisitor::addRigidContactPoint,
100  bp::args("contact", "force_reg_weight"))
101  .def("addRigidContact",
103  bp::args("contact", "force_reg_weight", "motion_weight",
104  "priority_level"))
105  .def("addRigidContact",
107  bp::args("contact", "force_reg_weight"))
108  .def("addRigidContact",
111  bp::args("contact", "force_reg_weight", "motion_weight",
112  "priority_level"))
113  .def("removeTask", &InvDynPythonVisitor::removeTask,
114  bp::args("task_name", "duration"))
115  .def("removeRigidContact", &InvDynPythonVisitor::removeRigidContact,
116  bp::args("contact_name", "duration"))
117  .def("removeFromHqpData", &InvDynPythonVisitor::removeFromHqpData,
118  bp::args("constraint_name"))
119  .def("computeProblemData", &InvDynPythonVisitor::computeProblemData,
120  bp::args("time", "q", "v"))
121 
122  .def("getActuatorForces", &InvDynPythonVisitor::getActuatorForces,
123  bp::args("HQPOutput"))
124  .def("getAccelerations", &InvDynPythonVisitor::getAccelerations,
125  bp::args("HQPOutput"))
126  .def("getContactForces", &InvDynPythonVisitor::getContactForces,
127  bp::args("HQPOutput"))
128  .def("checkContact", &InvDynPythonVisitor::checkContact,
129  bp::args("name", "HQPOutput"))
130  .def("getContactForce", &InvDynPythonVisitor::getContactForce,
131  bp::args("name", "HQPOutput"))
132  .def("addMeasuredForce", &InvDynPythonVisitor::addMeasuredForce,
133  bp::args("measured_force"));
134  }
135  static pinocchio::Data data(T& self) {
136  pinocchio::Data data = self.data();
137  return data;
138  }
139  static bool addMotionTask_SE3(T& self, tasks::TaskSE3Equality& task,
140  double weight, unsigned int priorityLevel,
141  double transition_duration) {
142  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
143  }
144  static bool addMotionTask_COM(T& self, tasks::TaskComEquality& task,
145  double weight, unsigned int priorityLevel,
146  double transition_duration) {
147  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
148  }
149  static bool addMotionTask_Joint(T& self, tasks::TaskJointPosture& task,
150  double weight, unsigned int priorityLevel,
151  double transition_duration) {
152  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
153  }
155  double weight,
156  unsigned int priorityLevel,
157  double transition_duration) {
158  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
159  }
161  T& self, tasks::TaskJointPosVelAccBounds& task, double weight,
162  unsigned int priorityLevel, double transition_duration) {
163  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
164  }
165  static bool addMotionTask_AM(T& self, tasks::TaskAMEquality& task,
166  double weight, unsigned int priorityLevel,
167  double transition_duration) {
168  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
169  }
171  T& self, tasks::TaskTwoFramesEquality& task, double weight,
172  unsigned int priorityLevel, double transition_duration) {
173  return self.addMotionTask(task, weight, priorityLevel, transition_duration);
174  }
175  static bool addForceTask_COP(T& self, tasks::TaskCopEquality& task,
176  double weight, unsigned int priorityLevel,
177  double transition_duration) {
178  return self.addForceTask(task, weight, priorityLevel, transition_duration);
179  }
181  double weight, unsigned int priorityLevel,
182  double transition_duration) {
183  return self.addActuationTask(task, weight, priorityLevel,
184  transition_duration);
185  }
186  static bool updateTaskWeight(T& self, const std::string& task_name,
187  double weight) {
188  return self.updateTaskWeight(task_name, weight);
189  }
190  static bool updateRigidContactWeights(T& self,
191  const std::string& contact_name,
192  double force_regularization_weight) {
193  return self.updateRigidContactWeights(contact_name,
194  force_regularization_weight);
195  }
197  T& self, const std::string& contact_name,
198  double force_regularization_weight, double motion_weight) {
199  return self.updateRigidContactWeights(
200  contact_name, force_regularization_weight, motion_weight);
201  }
202  static bool addRigidContact6dDeprecated(T& self,
204  return self.addRigidContact(contact, 1e-5);
205  }
207  double force_regularization_weight) {
208  return self.addRigidContact(contact, force_regularization_weight);
209  }
211  T& self, contacts::Contact6d& contact, double force_regularization_weight,
212  double motion_weight, const bool priority_level) {
213  return self.addRigidContact(contact, force_regularization_weight,
214  motion_weight, priority_level);
215  }
217  double force_regularization_weight) {
218  return self.addRigidContact(contact, force_regularization_weight);
219  }
222  double force_regularization_weight, double motion_weight,
223  const bool priority_level) {
224  return self.addRigidContact(contact, force_regularization_weight,
225  motion_weight, priority_level);
226  }
229  double force_regularization_weight) {
230  return self.addRigidContact(contact, force_regularization_weight);
231  }
234  double force_regularization_weight, double motion_weight,
235  const bool priority_level) {
236  return self.addRigidContact(contact, force_regularization_weight,
237  motion_weight, priority_level);
238  }
239  static bool removeTask(T& self, const std::string& task_name,
240  double transition_duration) {
241  return self.removeTask(task_name, transition_duration);
242  }
243  static bool removeRigidContact(T& self, const std::string& contactName,
244  double transition_duration) {
245  return self.removeRigidContact(contactName, transition_duration);
246  }
247  static bool removeFromHqpData(T& self, const std::string& constraintName) {
248  return self.removeFromHqpData(constraintName);
249  }
250  static HQPDatas computeProblemData(T& self, double time,
251  const Eigen::VectorXd& q,
252  const Eigen::VectorXd& v) {
253  HQPDatas Hqp;
254  Hqp.set(self.computeProblemData(time, q, v));
255  return Hqp;
256  }
257  static Eigen::VectorXd getActuatorForces(T& self,
258  const solvers::HQPOutput& sol) {
259  return self.getActuatorForces(sol);
260  }
261  static Eigen::VectorXd getAccelerations(T& self,
262  const solvers::HQPOutput& sol) {
263  return self.getAccelerations(sol);
264  }
265  static Eigen::VectorXd getContactForces(T& self,
266  const solvers::HQPOutput& sol) {
267  return self.getContactForces(sol);
268  }
269  static bool checkContact(T& self, const std::string& name,
270  const solvers::HQPOutput& sol) {
271  tsid::math::Vector f = self.getContactForces(name, sol);
272  if (f.size() > 0) return true;
273  return false;
274  }
275  static Eigen::VectorXd getContactForce(T& self, const std::string& name,
276  const solvers::HQPOutput& sol) {
277  return self.getContactForces(name, sol);
278  }
279  static bool addMeasuredForce(T& self,
280  contacts::Measured6Dwrench& measured_force) {
281  return self.addMeasuredForce(measured_force);
282  }
283 
284  static void expose(const std::string& class_name) {
285  std::string doc = "InvDyn info.";
286  bp::class_<T>(class_name.c_str(), doc.c_str(), bp::no_init)
287  .def(InvDynPythonVisitor<T>());
288  }
289 };
290 } // namespace python
291 } // namespace tsid
292 
293 #endif // ifndef __tsid_python_HQPOutput_hpp__
tsid::python::InvDynPythonVisitor::visit
void visit(PyClass &cl) const
Definition: formulation.hpp:50
tsid::python::InvDynPythonVisitor::addMeasuredForce
static bool addMeasuredForce(T &self, contacts::Measured6Dwrench &measured_force)
Definition: formulation.hpp:279
demo_quadruped.v
v
Definition: demo_quadruped.py:80
sol
sol
tsid::python::InvDynPythonVisitor::addForceTask_COP
static bool addForceTask_COP(T &self, tasks::TaskCopEquality &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:175
HQPData.hpp
boost::python
tsid::python::InvDynPythonVisitor::addRigidContactTwoFramePositionsWithPriorityLevel
static bool addRigidContactTwoFramePositionsWithPriorityLevel(T &self, contacts::ContactTwoFramePositions &contact, double force_regularization_weight, double motion_weight, const bool priority_level)
Definition: formulation.hpp:232
tsid::contacts::Measured6Dwrench
Definition: contacts/measured-6d-wrench.hpp:27
class_name
str class_name(str s)
pinocchio::DataTpl
task-cop-equality.hpp
contact-point.hpp
tsid::python::InvDynPythonVisitor::addRigidContact6dDeprecated
static bool addRigidContact6dDeprecated(T &self, contacts::Contact6d &contact)
Definition: formulation.hpp:202
tsid::tasks::TaskJointPosture
Definition: tasks/task-joint-posture.hpp:29
task-joint-bounds.hpp
tsid::tasks::TaskActuationBounds
Definition: tasks/task-actuation-bounds.hpp:28
task-com-equality.hpp
tsid::python::InvDynPythonVisitor::getAccelerations
static Eigen::VectorXd getAccelerations(T &self, const solvers::HQPOutput &sol)
Definition: formulation.hpp:261
pinocchio::python::deprecated_function
f
f
tsid::python::InvDynPythonVisitor::addMotionTask_JointPosVelAccBounds
static bool addMotionTask_JointPosVelAccBounds(T &self, tasks::TaskJointPosVelAccBounds &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:160
tsid::python::InvDynPythonVisitor::updateTaskWeight
static bool updateTaskWeight(T &self, const std::string &task_name, double weight)
Definition: formulation.hpp:186
task-joint-posVelAcc-bounds.hpp
tsid::python::InvDynPythonVisitor::addMotionTask_TwoFramesEquality
static bool addMotionTask_TwoFramesEquality(T &self, tasks::TaskTwoFramesEquality &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:170
tsid::python::InvDynPythonVisitor::addRigidContact6dWithPriorityLevel
static bool addRigidContact6dWithPriorityLevel(T &self, contacts::Contact6d &contact, double force_regularization_weight, double motion_weight, const bool priority_level)
Definition: formulation.hpp:210
tsid::python::InvDynPythonVisitor::addRigidContactPointWithPriorityLevel
static bool addRigidContactPointWithPriorityLevel(T &self, contacts::ContactPoint &contact, double force_regularization_weight, double motion_weight, const bool priority_level)
Definition: formulation.hpp:220
tsid::python::InvDynPythonVisitor::computeProblemData
static HQPDatas computeProblemData(T &self, double time, const Eigen::VectorXd &q, const Eigen::VectorXd &v)
Definition: formulation.hpp:250
test_Contact.contact
contact
Definition: test_Contact.py:37
task-two-frames-equality.hpp
demo_quadruped.q
q
Definition: demo_quadruped.py:74
tsid::python::InvDynPythonVisitor::addMotionTask_SE3
static bool addMotionTask_SE3(T &self, tasks::TaskSE3Equality &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:139
tsid::python::InvDynPythonVisitor::addMotionTask_JointBounds
static bool addMotionTask_JointBounds(T &self, tasks::TaskJointBounds &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:154
task-joint-posture.hpp
tsid::contacts::ContactTwoFramePositions
Definition: contacts/contact-two-frame-positions.hpp:29
tsid::contacts::Contact6d
Definition: contacts/contact-6d.hpp:29
tsid::solvers::HQPOutput
Definition: solver-HQP-output.hpp:29
tsid::tasks::TaskJointBounds
Definition: tasks/task-joint-bounds.hpp:27
python
tsid::tasks::TaskComEquality
Definition: tasks/task-com-equality.hpp:29
tsid::tasks::TaskCopEquality
Definition: tasks/task-cop-equality.hpp:30
tsid::python::InvDynPythonVisitor::expose
static void expose(const std::string &class_name)
Definition: formulation.hpp:284
tsid::python::InvDynPythonVisitor::updateRigidContactWeightsWithMotionWeight
static bool updateRigidContactWeightsWithMotionWeight(T &self, const std::string &contact_name, double force_regularization_weight, double motion_weight)
Definition: formulation.hpp:196
tsid::tasks::TaskAMEquality
Definition: task-angular-momentum-equality.hpp:32
tsid::python::InvDynPythonVisitor
Definition: formulation.hpp:46
tsid::python::InvDynPythonVisitor::addActuationTask_Bounds
static bool addActuationTask_Bounds(T &self, tasks::TaskActuationBounds &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:180
task-se3-equality.hpp
inverse-dynamics-formulation-acc-force.hpp
measured-6d-wrench.hpp
setup.name
name
Definition: setup.in.py:179
contact-two-frame-positions.hpp
tsid::python::InvDynPythonVisitor::getContactForce
static Eigen::VectorXd getContactForce(T &self, const std::string &name, const solvers::HQPOutput &sol)
Definition: formulation.hpp:275
tsid::tasks::TaskJointPosVelAccBounds
Definition: tasks/task-joint-posVelAcc-bounds.hpp:36
tsid::math::Vector
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Vector
Definition: math/fwd.hpp:35
demo_quadruped.time
time
Definition: demo_quadruped.py:213
tsid::python::InvDynPythonVisitor::updateRigidContactWeights
static bool updateRigidContactWeights(T &self, const std::string &contact_name, double force_regularization_weight)
Definition: formulation.hpp:190
tsid::python::InvDynPythonVisitor::addRigidContact6d
static bool addRigidContact6d(T &self, contacts::Contact6d &contact, double force_regularization_weight)
Definition: formulation.hpp:206
task-angular-momentum-equality.hpp
tsid::python::InvDynPythonVisitor::removeTask
static bool removeTask(T &self, const std::string &task_name, double transition_duration)
Definition: formulation.hpp:239
tsid::python::HQPDatas
Definition: container.hpp:80
tsid::python::InvDynPythonVisitor::checkContact
static bool checkContact(T &self, const std::string &name, const solvers::HQPOutput &sol)
Definition: formulation.hpp:269
tsid::python::InvDynPythonVisitor::addMotionTask_AM
static bool addMotionTask_AM(T &self, tasks::TaskAMEquality &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:165
task-actuation-bounds.hpp
tsid::python::HQPDatas::set
bool set(const HQPData &data)
Definition: container.hpp:117
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
contact-6d.hpp
tsid::python::InvDynPythonVisitor::data
static pinocchio::Data data(T &self)
Definition: formulation.hpp:135
cl
cl
tsid::python::InvDynPythonVisitor::addMotionTask_COM
static bool addMotionTask_COM(T &self, tasks::TaskComEquality &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:144
tsid::python::InvDynPythonVisitor::addRigidContactTwoFramePositions
static bool addRigidContactTwoFramePositions(T &self, contacts::ContactTwoFramePositions &contact, double force_regularization_weight)
Definition: formulation.hpp:227
fwd.hpp
tsid::python::InvDynPythonVisitor::removeFromHqpData
static bool removeFromHqpData(T &self, const std::string &constraintName)
Definition: formulation.hpp:247
tsid::python::InvDynPythonVisitor::removeRigidContact
static bool removeRigidContact(T &self, const std::string &contactName, double transition_duration)
Definition: formulation.hpp:243
tsid::contacts::ContactPoint
Definition: contacts/contact-point.hpp:28
tsid::tasks::TaskSE3Equality
Definition: tasks/task-se3-equality.hpp:31
tsid::python::InvDynPythonVisitor::getActuatorForces
static Eigen::VectorXd getActuatorForces(T &self, const solvers::HQPOutput &sol)
Definition: formulation.hpp:257
tsid::python::InvDynPythonVisitor::addRigidContactPoint
static bool addRigidContactPoint(T &self, contacts::ContactPoint &contact, double force_regularization_weight)
Definition: formulation.hpp:216
tsid::python::InvDynPythonVisitor::addMotionTask_Joint
static bool addMotionTask_Joint(T &self, tasks::TaskJointPosture &task, double weight, unsigned int priorityLevel, double transition_duration)
Definition: formulation.hpp:149
tsid::python::InvDynPythonVisitor::getContactForces
static Eigen::VectorXd getContactForces(T &self, const solvers::HQPOutput &sol)
Definition: formulation.hpp:265
tsid::tasks::TaskTwoFramesEquality
Definition: tasks/task-two-frames-equality.hpp:31


tsid
Author(s): Andrea Del Prete, Justin Carpentier
autogenerated on Thu Apr 3 2025 02:47:15