task-angular-momentum-equality.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2017 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 
22 
23 namespace tsid {
24 namespace tasks {
25 using namespace math;
26 using namespace trajectories;
27 using namespace pinocchio;
28 
30  : TaskMotion(name, robot), m_constraint(name, 3, robot.nv()) {
31  m_Kp.setZero(3);
32  m_Kd.setZero(3);
33  m_L_error.setZero(3);
34  m_dL_error.setZero(3);
35  m_L.setZero(3);
36  m_dL.setZero(3);
37  m_dL_des.setZero(3);
38  m_ref.resize(3);
39 }
40 
41 int TaskAMEquality::dim() const {
42  // return self._mask.sum ()
43  return 3;
44 }
45 
46 const Vector3& TaskAMEquality::Kp() { return m_Kp; }
47 
48 const Vector3& TaskAMEquality::Kd() { return m_Kd; }
49 
52  "The size of the Kp vector needs to equal 3");
53  m_Kp = Kp;
54 }
55 
58  "The size of the Kd vector needs to equal 3");
59  m_Kd = Kd;
60 }
61 
63 
65 
67  return m_dL_des;
68 }
69 
71  return m_constraint.matrix() * dv - m_drift;
72 }
73 
75 
76 const Vector3& TaskAMEquality::momentum() const { return m_L; }
77 const Vector& TaskAMEquality::momentum_ref() const { return m_ref.getValue(); }
78 
80  return m_ref.getDerivative();
81 }
82 
84  return m_constraint;
85 }
86 
89  // Compute errors
90  // Get momentum jacobian
92  m_L = J_am.bottomRows(3) * v;
94 
95  m_dL_des = -m_Kp.cwiseProduct(m_L_error) + m_ref.getDerivative();
96 
97 #ifndef NDEBUG
98 // std::cout<<m_name<<" errors: "<<m_L_error.norm()<<" "
99 // <<m_dL_error.norm()<<std::endl;
100 #endif
101 
103  m_constraint.setMatrix(J_am.bottomRows(3));
105 
106  return m_constraint;
107 }
108 
109 } // namespace tasks
110 } // namespace tsid
tsid::tasks::TaskAMEquality::dmomentum_ref
const Vector & dmomentum_ref() const
Definition: task-angular-momentum-equality.cpp:79
tsid::tasks::TaskAMEquality::getReference
const TrajectorySample & getReference() const override
Definition: task-angular-momentum-equality.cpp:64
demo_quadruped.v
v
Definition: demo_quadruped.py:80
tsid::trajectories::TrajectorySample::resize
void resize(unsigned int size)
Definition: trajectories/trajectory-base.hpp:58
tsid::trajectories::TrajectorySample::getDerivative
const math::Vector & getDerivative() const
Definition: trajectories/trajectory-base.hpp:44
tsid::trajectories::TrajectorySample
Definition: trajectories/trajectory-base.hpp:33
pinocchio::DataTpl
tsid::tasks::TaskAMEquality::m_constraint
ConstraintEquality m_constraint
Definition: task-angular-momentum-equality.hpp:77
tsid::tasks::TaskAMEquality::m_ref
TrajectorySample m_ref
Definition: task-angular-momentum-equality.hpp:76
PINOCCHIO_CHECK_INPUT_ARGUMENT
#define PINOCCHIO_CHECK_INPUT_ARGUMENT(...)
tsid::tasks::TaskAMEquality::getDesiredMomentumDerivative
const Vector3 & getDesiredMomentumDerivative() const
Definition: task-angular-momentum-equality.cpp:66
dv
dv
tsid::tasks::TaskAMEquality::momentum
const Vector3 & momentum() const
Definition: task-angular-momentum-equality.cpp:76
tsid::math::ConstraintBase
Abstract class representing a linear equality/inequality constraint. Equality constraints are represe...
Definition: constraint-base.hpp:35
tsid::tasks::TaskAMEquality::momentum_ref
const Vector & momentum_ref() const
Definition: task-angular-momentum-equality.cpp:77
tsid::tasks::TaskAMEquality::m_drift
Vector3 m_drift
Definition: task-angular-momentum-equality.hpp:74
tsid::tasks::TaskAMEquality::m_L_error
Vector3 m_L_error
Definition: task-angular-momentum-equality.hpp:71
tsid::tasks::TaskAMEquality::compute
const ConstraintBase & compute(double t, ConstRefVector q, ConstRefVector v, Data &data) override
Definition: task-angular-momentum-equality.cpp:87
ref
list ref
setup.data
data
Definition: setup.in.py:48
tsid::tasks::TaskAMEquality::m_dL_error
Vector3 m_dL_error
Definition: task-angular-momentum-equality.hpp:71
tsid::robots::RobotWrapper::angularMomentumTimeVariation
Vector3 angularMomentumTimeVariation(const Data &data) const
Definition: src/robots/robot-wrapper.cpp:350
tsid::tasks::TaskAMEquality::m_L
Vector3 m_L
Definition: task-angular-momentum-equality.hpp:75
demo_quadruped.robot
robot
Definition: demo_quadruped.py:51
test_Contact.Kp
Kp
Definition: test_Contact.py:44
tsid::tasks::TaskAMEquality::getdMomentum
Vector3 getdMomentum(ConstRefVector dv) const
Definition: task-angular-momentum-equality.cpp:70
tsid::tasks::TaskAMEquality::Vector
math::Vector Vector
Definition: task-angular-momentum-equality.hpp:38
tsid::tasks::TaskAMEquality::TaskAMEquality
TaskAMEquality(const std::string &name, RobotWrapper &robot)
Definition: task-angular-momentum-equality.cpp:29
tsid::tasks::TaskAMEquality::getConstraint
const ConstraintBase & getConstraint() const override
Definition: task-angular-momentum-equality.cpp:83
tsid::math::ConstraintEquality::setVector
bool setVector(ConstRefVector b) override
Definition: src/math/constraint-equality.cpp:75
ex_4_conf.nv
int nv
Definition: ex_4_conf.py:23
tsid::tasks::TaskAMEquality::m_Kd
Vector3 m_Kd
Definition: task-angular-momentum-equality.hpp:70
tsid::tasks::TaskAMEquality::Kp
const Vector3 & Kp()
Definition: task-angular-momentum-equality.cpp:46
tsid::math::ConstraintBase::matrix
virtual const Matrix & matrix() const
Definition: constraint-base.cpp:35
test_Tasks.J_am
J_am
Definition: test_Tasks.py:257
tsid::tasks::TaskAMEquality::momentum_error
const Vector3 & momentum_error() const
Definition: task-angular-momentum-equality.cpp:74
robot-wrapper.hpp
tsid::tasks::TaskAMEquality::m_Kp
Vector3 m_Kp
Definition: task-angular-momentum-equality.hpp:69
tsid::trajectories::TrajectorySample::getValue
TSID_DISABLE_WARNING_PUSH const TSID_DISABLE_WARNING_DEPRECATED math::Vector & getValue() const
Definition: trajectories/trajectory-base.hpp:43
tsid::tasks::TaskAMEquality::Matrix6x
pinocchio::Data::Matrix6x Matrix6x
Definition: task-angular-momentum-equality.hpp:41
setup.name
name
Definition: setup.in.py:179
tsid::tasks::TaskMotion
Definition: task-motion.hpp:26
tsid::tasks::TaskAMEquality::Kd
const Vector3 & Kd()
Definition: task-angular-momentum-equality.cpp:48
tsid::robots::RobotWrapper::momentumJacobian
const Data::Matrix6x & momentumJacobian(const Data &data) const
Definition: src/robots/robot-wrapper.cpp:346
tsid::tasks::TaskAMEquality::setReference
void setReference(const TrajectorySample &ref)
Definition: task-angular-momentum-equality.cpp:62
task-angular-momentum-equality.hpp
joint-configuration.hpp
tsid
Definition: bindings/python/constraint/constraint-bound.cpp:21
tsid::tasks::TaskAMEquality::m_dL
Vector3 m_dL
Definition: task-angular-momentum-equality.hpp:75
tsid::robots::RobotWrapper
Wrapper for a robot based on pinocchio.
Definition: robots/robot-wrapper.hpp:37
test_Contact.Kd
int Kd
Definition: test_Contact.py:45
tsid::tasks::TaskBase::m_robot
RobotWrapper & m_robot
Reference on the robot model.
Definition: task-base.hpp:64
tsid::tasks::TaskAMEquality::Vector3
math::Vector3 Vector3
Definition: task-angular-momentum-equality.hpp:39
centroidal.hpp
tsid::tasks::TaskBase::ConstRefVector
math::ConstRefVector ConstRefVector
Definition: task-base.hpp:39
tsid::tasks::TaskAMEquality::dim
int dim() const override
Return the dimension of the task. \info should be overloaded in the child class.
Definition: task-angular-momentum-equality.cpp:41
tsid::math::ConstraintBase::setMatrix
virtual bool setMatrix(ConstRefMatrix A)
Definition: constraint-base.cpp:39
tsid::tasks::TaskAMEquality::m_dL_des
Vector3 m_dL_des
Definition: task-angular-momentum-equality.hpp:72
pinocchio


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