Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
5a6a1f6
Added hasConstraint function to QPSolver
rafaelxero Jun 13, 2017
8d0c976
Merge branch 'master' of git://github.com/jrl-umi3218/Tasks into topi…
rafaelxero Jun 13, 2017
7ce838e
Merge branch 'master' of github.com:jrl-umi3218/Tasks into topic/HRG
rafaelxero Oct 31, 2017
e7a6845
Added PassiveMotionConstr
rafaelxero Nov 9, 2017
bbe5f01
Fix type of P and small indentation changes
rafaelxero Dec 6, 2017
0b55b82
Transformed mbcs_calc_ into shared_ptr
rafaelxero Dec 11, 2017
cf252bf
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into to…
rafaelxero Dec 11, 2017
c006d6f
Solved invalid dimensions that led to Eigen::assignCoef Segmentation …
rafaelxero Dec 11, 2017
a4b37c7
Merge branch 'master' of github.com:jrl-umi3218/Tasks into topic/HRG
rafaelxero Dec 12, 2017
ee85830
Merge branch 'topic/HRG' of github.com:rafaelxero/Tasks into topic/HRG
rafaelxero Dec 12, 2017
65627d4
[WIP] Fixed sign of P_, used the new optimized Coriolis, computed Mdo…
rafaelxero Dec 15, 2017
3ad79e0
[WIP] Used dofToVector for alphaVec_ref and alphaVec_hat
rafaelxero Dec 15, 2017
030fa70
Merge branch 'topic/HRG' of github.com:rafaelxero/Tasks into topic/HRG
rafaelxero Dec 19, 2017
3bfe9ea
[WIP] P = K s
rafaelxero Dec 25, 2017
0e2c9fe
Working, but with debugging messages commented out
rafaelxero Dec 27, 2017
dae46eb
Removed commented messages
rafaelxero Dec 27, 2017
0191ac5
Merge branch 'topic/HRG' of github.com:rafaelxero/Tasks into topic/HRG
rafaelxero Dec 27, 2017
195207c
Used fd as shared_ptr, changed name to IntTermMotionConstr and used i…
rafaelxero Mar 6, 2018
63b8366
Changed PassiveMotionConstr to IntglTermMotionConstr and added IntglT…
rafaelxero Mar 9, 2018
f8a5788
Avoid unnecessary copy of mb
gergondet Mar 9, 2018
3914b97
Fix bindings for Motion*Constr taking shared_ptr of FD
gergondet Mar 9, 2018
64ea789
Merge branch 'master' of github.com:jrl-umi3218/Tasks into topic/HRG
rafaelxero Mar 9, 2018
7ef1728
Merge branch 'master' of github.com:jrl-umi3218/Tasks into topic/HRG_FD
rafaelxero Mar 9, 2018
4855af8
Added refVel and refAccel to TrajectoryTask
rafaelxero Mar 13, 2018
9e6e481
Merge branch 'topic/HRG_FD' of https://github.com/rafaelxero/Tasks in…
rafaelxero Mar 13, 2018
7b82a6f
Premultiplied Jac * gammaD by csd.sign and added some debugging prints
rafaelxero Jul 31, 2018
31a9956
Disabled some debugging prints
rafaelxero Aug 1, 2018
fbe70fd
Debugging messages and hasConstraint with const argument
rafaelxero Aug 3, 2018
bfde7a8
Tab
rafaelxero Aug 4, 2018
0034f93
Merge branch 'topic/HRG_FD' of github.com:rafaelxero/Tasks into topic…
rafaelxero Aug 4, 2018
06c18e6
Printed lambda correctly
rafaelxero Aug 6, 2018
8f4c430
Removed debugging comments
rafaelxero Aug 7, 2018
d756de4
Merge branch 'topic/HRG_FD' into topic/HRG
rafaelxero Aug 7, 2018
c848568
Merge branch 'topic/HRG_FD' of github.com:rafaelxero/Tasks into topic…
rafaelxero Aug 8, 2018
529ef17
Merge branch 'topic/HRG_FD' into topic/HRG
rafaelxero Aug 8, 2018
08bbf7d
Overrided ContactData and added stiffness and damping fields to it, n…
rafaelxero Aug 16, 2018
1821329
Added the functionality of specifying different PD gains for each con…
rafaelxero Aug 17, 2018
990410d
Merge branch 'topic/HRG' of https://github.com/rafaelxero/Tasks into …
rafaelxero Aug 17, 2018
543c060
Some debugging messages commented out
rafaelxero Sep 14, 2018
0f9e5ab
Started to code the WrenchTask [WIP]
rafaelxero Sep 19, 2018
5773a62
Some debugging messages
rafaelxero Sep 19, 2018
b43d5bd
Continued with the development of WrenchTask [WIP]
rafaelxero Sep 21, 2018
021ae63
Coding WrenchTask's updateNrVars and update [WIP]
rafaelxero Oct 15, 2018
b21725f
Finished to code the WrenchTask (not tested yet)
rafaelxero Oct 16, 2018
aa65964
Added dimWeight to the WrenchTask and the functionality to specify th…
rafaelxero Oct 17, 2018
59434a0
The WrenchTask is working properly... also commented some debugging m…
rafaelxero Oct 30, 2018
55dc8e5
Changed the WrenchTask to use ForceVecd and finished to code the Admi…
rafaelxero Nov 1, 2018
3ae0aad
Specified different gains for force and moment for the AdmittanceTask
rafaelxero Nov 2, 2018
41721b9
Finished the Admittance Task and added bodyPoint to the Wrench Task
rafaelxero Dec 3, 2018
6a4f9f7
Added PassivityPIDTerm_QPSolver and made the modificaitons related wi…
rafaelxero Dec 3, 2018
703b076
Cleaned up debugging comments
rafaelxero Dec 3, 2018
0b3e335
Completed the admittance task and changed the minimum value for the l…
rafaelxero Feb 18, 2019
a9201a4
Started to develop the Contact Hybrid Constraint [WIP]
rafaelxero Feb 18, 2019
c48e7b6
Started to write a function to get the Motion Constraint, if any [WIP…
rafaelxero Feb 18, 2019
8482148
Merged master into this temporal branch, created from topic/HRG
rafaelxero Feb 18, 2019
f05020c
Debugging comments
rafaelxero Mar 4, 2019
9197703
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into temp
rafaelxero Mar 6, 2019
159d6b6
Removed unused debugging comments
rafaelxero Mar 6, 2019
745ef96
Started to code the YawMomentCompensationTask
rafaelxero Mar 14, 2019
59460f0
NaN Test
rafaelxero Apr 26, 2019
998fd6a
Added a debugging comment for fd_->H() (commented out)
rafaelxero Jul 7, 2019
9f87122
Changed the nantest
rafaelxero Jul 10, 2019
1a560c4
Solved conflicts
rafaelxero Jul 13, 2019
4cab687
Fixed some omissions done while solving conflicts
rafaelxero Jul 14, 2019
0bda39e
Debugging the Segmentation Fault [WIP]
rafaelxero Jul 19, 2019
0005044
Started to develop the CentroidalAngularMomentumTask [WIP]
rafaelxero Aug 15, 2019
04ebb17
Finished to implement CentroidalAngularMomentumTask and started to im…
rafaelxero Aug 18, 2019
62ad853
Finished to implement the ZMPTask
rafaelxero Aug 19, 2019
d88d9d6
Added public to ZMPTask
rafaelxero Aug 21, 2019
782e238
Stored the computed torque before adding the integral term
rafaelxero Aug 22, 2019
b36e528
Started to develop the MotionFrictionConstr [WIP]
rafaelxero Aug 23, 2019
3071123
Corrected little mistake
rafaelxero Aug 23, 2019
607b22a
Centralized the friction
rafaelxero Aug 25, 2019
eac4992
Added ZMPBasedCoMTask and ForceDistributionTask [WIP]
rafaelxero Aug 25, 2019
82b64f2
Debugged errors
rafaelxero Aug 26, 2019
b40f9a7
Complemented the ForceDistributionTask
rafaelxero Aug 27, 2019
cc261d2
Created two versions of the MotionConstr for the feedback term, one w…
rafaelxero Aug 27, 2019
8ce5b61
Reorganized and shortened titles
rafaelxero Aug 27, 2019
fe45aba
Changed tabulations
rafaelxero Aug 27, 2019
b3ee08e
Had forgotten to initialize angMomentum_
rafaelxero Aug 28, 2019
e675449
Added tab
rafaelxero Aug 29, 2019
b9aa028
Added some debugging messages
rafaelxero Aug 30, 2019
8eb8652
Changed place of ZMPBasedCoMTask
rafaelxero Aug 31, 2019
c6026c9
Changed ZMPTask to calculate and retrieve totalForce and totalMomentZMP
rafaelxero Sep 1, 2019
9be9057
Added debugging messages
rafaelxero Sep 2, 2019
2deca6f
Started to implement the NullSpaceAdmittanceTask
rafaelxero Sep 2, 2019
6718571
Continued implementing NullSpaceAdmittanceTask
rafaelxero Sep 3, 2019
73f8793
Implementing the projection in NullSpaceAdmittanceTask
rafaelxero Sep 4, 2019
4d04079
Completed the NulSpaceAdmittanceTask, but pending to debug [WIP]
rafaelxero Sep 4, 2019
957b15a
Finished to implement NullSpaceAdmittanceTask, and right now is indep…
rafaelxero Sep 4, 2019
3e51e3d
Added AdmittanceTaskCommon
rafaelxero Sep 4, 2019
e03e019
Some debugging messages in ZMPTask
rafaelxero Sep 5, 2019
b41bffd
Fixed a wrong initialization
rafaelxero Sep 7, 2019
36343fc
Debugged the NullSpaceAdmittanceTask and now it is working properly
rafaelxero Sep 8, 2019
d159a1c
Added get functions to get the matrices of the solver
rafaelxero Sep 19, 2019
d014a33
Using measured com Z for LIP
rafaelxero Oct 6, 2019
adf9434
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into to…
rafaelxero Oct 11, 2019
6ac30d1
Debugging ZMPTask
rafaelxero Oct 30, 2019
217361d
Still debugging the problem with the absolute coordinates of the MCS
rafaelxero Oct 31, 2019
bd3a68b
Added name fields to the tasks
rafaelxero Nov 4, 2019
9e7cf3d
Changed the implementation of the reception of measured wrenches, and…
rafaelxero Nov 6, 2019
ba3243e
Still debugging the null space admittance tasks
rafaelxero Nov 7, 2019
429a9ea
Added new implementation of the ForceDistributionTask and created a c…
rafaelxero Nov 10, 2019
a2004e8
Started to implement the ZMPWithForceDistributionTask
rafaelxero Nov 11, 2019
6202ece
Finished the implementation of ZMPWithForceDistribution
rafaelxero Nov 12, 2019
9c06ed6
Added the LocalCoPTask
rafaelxero Nov 13, 2019
935713b
Solved issue of the NullSpaceAdmittanceTask when removing a contact
rafaelxero Nov 19, 2019
13f14d7
Use of the desired com height in the ZMPBasedCoMTask
rafaelxero Nov 24, 2019
3ebae68
Merge remote-tracking branch 'origin/master' into topic/HRG
mehdi-benallegue Dec 5, 2019
b38d9a4
Merge pull request #1 from mehdi-benallegue/topic/HRG
rafaelxero Dec 5, 2019
16834e6
Added a getter for calculatedWrench in NullSpaceAdmittanceTask
rafaelxero Dec 9, 2019
a70115e
Commented out the ZMPWithForceDistributionTask
rafaelxero Jan 29, 2020
1b53b41
Solved conflicts
rafaelxero Mar 13, 2020
7df9406
Fixed the force glitches when switching contacts
rafaelxero May 11, 2020
ddd4bf2
Fixed the force distribution ratio glitches when switching contacts
rafaelxero May 12, 2020
ce48618
Fixed force glitches in the admittance tasks, but code is not optimized
rafaelxero May 13, 2020
c2e1895
Merged bodies_ and contactBodies_ of NullSpaceAdmittanceTas
rafaelxero May 13, 2020
8a5a177
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into to…
rafaelxero May 22, 2020
07f3920
Removed the commented out ZMPWithForceDistributionTask
rafaelxero May 22, 2020
c93aa6b
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into to…
rafaelxero Jul 21, 2020
bf10f24
Merge branch 'master' of https://github.com/jrl-umi3218/Tasks into to…
rafaelxero Feb 6, 2021
0f8024e
Had forgotten to update signatures with fd
rafaelxero Feb 6, 2021
78fce78
Added an include for Rafael's code
mehdi-benallegue Oct 23, 2020
25bd1ae
Merge pull request #2 from mehdi-benallegue/topic/HRG
rafaelxero Feb 16, 2021
6b81d3b
Merge branch 'master' into topic/HRG
rafaelxero Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions binding/python/include/qp_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ JointsSelector* UnactiveJoints2Ptr(const std::vector<rbd::MultiBody>& mbs, int r
return new JointsSelector(JointsSelector::UnactiveJoints(mbs, robotIndex, hl, unactiveJointsNames));
}

std::shared_ptr<rbd::ForwardDynamics> FD2ShPtr(rbd::ForwardDynamics & fd)
{
return std::shared_ptr<rbd::ForwardDynamics>(&fd, [](rbd::ForwardDynamics *){});
}

}
}
11 changes: 6 additions & 5 deletions binding/python/tasks/qp/c_qp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from sva.c_sva cimport *
from rbdyn.c_rbdyn cimport *
from sch.c_sch cimport *
cimport tasks.c_tasks as c_tasks
from libcpp.memory cimport shared_ptr
from libcpp.string cimport string
from libcpp.vector cimport vector
from libcpp cimport bool
Expand Down Expand Up @@ -494,7 +495,7 @@ cdef extern from "<Tasks/QPTasks.h>" namespace "tasks::qp":

cdef extern from "<Tasks/QPMotionConstr.h>" namespace "tasks::qp":
cdef cppclass MotionPolyConstr(ConstraintFunction[GenInequality], GenInequality, Constraint):
MotionPolyConstr(const vector[MultiBody]&, int, const c_tasks.PolyTorqueBound&)
MotionPolyConstr(const vector[MultiBody]&, int, const shared_ptr[ForwardDynamics], const c_tasks.PolyTorqueBound&)
# Motion default
void computeTorque(const VectorXd&, const VectorXd&)
VectorXd torque() const
Expand All @@ -504,8 +505,8 @@ cdef extern from "<Tasks/QPMotionConstr.h>" namespace "tasks::qp":
void removeFromSolver(QPSolver &)

cdef cppclass MotionConstr(ConstraintFunction[GenInequality], GenInequality, Constraint):
MotionConstr(const vector[MultiBody]&, int, const c_tasks.TorqueBound&)
MotionConstr(const vector[MultiBody]&, int, const c_tasks.TorqueBound&, const c_tasks.TorqueDBound&, double)
MotionConstr(const vector[MultiBody]&, int, const shared_ptr[ForwardDynamics], const c_tasks.TorqueBound&)
MotionConstr(const vector[MultiBody]&, int, const shared_ptr[ForwardDynamics], const c_tasks.TorqueBound&, const c_tasks.TorqueDBound&, double)
# Motion default
void computeTorque(const VectorXd&, const VectorXd&)
VectorXd torque() const
Expand All @@ -515,8 +516,8 @@ cdef extern from "<Tasks/QPMotionConstr.h>" namespace "tasks::qp":
void removeFromSolver(QPSolver &)

cdef cppclass MotionSpringConstr(ConstraintFunction[GenInequality], GenInequality, Constraint):
MotionSpringConstr(const vector[MultiBody]&, int, const c_tasks.TorqueBound&, const vector[SpringJoint]&)
MotionSpringConstr(const vector[MultiBody]&, int, const c_tasks.TorqueBound&, const c_tasks.TorqueDBound&, double, const vector[SpringJoint]&)
MotionSpringConstr(const vector[MultiBody]&, int, const shared_ptr[ForwardDynamics], const c_tasks.TorqueBound&, const vector[SpringJoint]&)
MotionSpringConstr(const vector[MultiBody]&, int, const shared_ptr[ForwardDynamics], const c_tasks.TorqueBound&, const c_tasks.TorqueDBound&, double, const vector[SpringJoint]&)
# Motion default
void computeTorque(const VectorXd&, const VectorXd&)
VectorXd torque() const
Expand Down
1 change: 1 addition & 0 deletions binding/python/tasks/qp/c_qp_private.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ from libcpp.vector cimport vector
cdef extern from "qp_wrapper.hpp" namespace "tasks::qp":
JointsSelector* ActiveJoints2Ptr(const vector[MultiBody]&, int, HighLevelTask*, const vector[string])
JointsSelector* UnactiveJoints2Ptr(const vector[MultiBody]&, int, HighLevelTask*, const vector[string])
shared_ptr[ForwardDynamics] FD2ShPtr(ForwardDynamics & fd)
4 changes: 4 additions & 0 deletions binding/python/tasks/qp/qp.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

cimport c_qp
cimport rbdyn.rbdyn as rbdyn

from libcpp.vector cimport vector
from libcpp cimport bool as cppbool
Expand Down Expand Up @@ -154,18 +155,21 @@ cdef class GripperTorqueTask(Task):
cdef class MotionConstr(GenInequality):
cdef c_qp.MotionConstr * impl
cdef cppbool __own_impl
cdef rbdyn.ForwardDynamics fd_instance

cdef MotionConstr MotionConstrFromPtr(c_qp.MotionConstr *)

cdef class MotionPolyConstr(GenInequality):
cdef c_qp.MotionPolyConstr * impl
cdef cppbool __own_impl
cdef rbdyn.ForwardDynamics fd_instance

cdef MotionPolyConstr MotionPolyConstrFromPtr(c_qp.MotionPolyConstr *)

cdef class MotionSpringConstr(GenInequality):
cdef c_qp.MotionSpringConstr * impl
cdef cppbool __own_impl
cdef rbdyn.ForwardDynamics fd_instance

cdef MotionSpringConstr MotionSpringConstrFromPtr(c_qp.MotionSpringConstr *)

Expand Down
20 changes: 12 additions & 8 deletions binding/python/tasks/qp/qp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1614,13 +1614,15 @@ cdef class MotionConstr(GenInequality):
def __dealloc__(self):
if self.__own_impl:
del self.impl
def __cinit__(self, MultiBodyVector mbs, int robotIndex, tasks.TorqueBound tb, tasks.TorqueDBound tdb = None, dt = None, skip_alloc = False):
def __cinit__(self, MultiBodyVector mbs, int robotIndex, ForwardDynamics fd, tasks.TorqueBound tb, tasks.TorqueDBound tdb = None, dt = None, skip_alloc = False):
self.__own_impl = True
if not skip_alloc:
# Keep FD alive
self.fd_instance = fd
if tdb is None:
self.impl = new c_qp.MotionConstr(deref(mbs.v), robotIndex, tb.impl)
self.impl = new c_qp.MotionConstr(deref(mbs.v), robotIndex, c_qp_private.FD2ShPtr(fd.impl), tb.impl)
else:
self.impl = new c_qp.MotionConstr(deref(mbs.v), robotIndex, tb.impl, tdb.impl, dt)
self.impl = new c_qp.MotionConstr(deref(mbs.v), robotIndex, c_qp_private.FD2ShPtr(fd.impl), tb.impl, tdb.impl, dt)
self.cf_base = self.impl
self.genineq_base = self.impl
self.constraint_base = self.impl
Expand Down Expand Up @@ -1656,10 +1658,11 @@ cdef class MotionPolyConstr(GenInequality):
def __dealloc__(self):
if self.__own_impl:
del self.impl
def __cinit__(self, MultiBodyVector mbs, int robotIndex, tasks.PolyTorqueBound tb, skip_alloc = False):
def __cinit__(self, MultiBodyVector mbs, int robotIndex, ForwardDynamics fd, tasks.PolyTorqueBound tb, skip_alloc = False):
self.__own_impl = True
if not skip_alloc:
self.impl = new c_qp.MotionPolyConstr(deref(mbs.v), robotIndex, tb.impl)
self.fd_instance = fd
self.impl = new c_qp.MotionPolyConstr(deref(mbs.v), robotIndex, c_qp_private.FD2ShPtr(fd.impl), tb.impl)
self.cf_base = self.impl
self.genineq_base = self.impl
self.constraint_base = self.impl
Expand Down Expand Up @@ -1695,13 +1698,14 @@ cdef class MotionSpringConstr(GenInequality):
def __dealloc__(self):
if self.__own_impl:
del self.impl
def __cinit__(self, MultiBodyVector mbs, int robotIndex, tasks.TorqueBound tb, sjs, tasks.TorqueDBound tdb = None, dt = None, skip_alloc = False):
def __cinit__(self, MultiBodyVector mbs, int robotIndex, ForwardDynamics fd, tasks.TorqueBound tb, sjs, tasks.TorqueDBound tdb = None, dt = None, skip_alloc = False):
self.__own_impl = True
if not skip_alloc:
self.fd_instance = fd
if tdb is None:
self.impl = new c_qp.MotionSpringConstr(deref(mbs.v), robotIndex, tb.impl, SpringJointVector(sjs).v)
self.impl = new c_qp.MotionSpringConstr(deref(mbs.v), robotIndex, c_qp_private.FD2ShPtr(fd.impl), tb.impl, SpringJointVector(sjs).v)
else:
self.impl = new c_qp.MotionSpringConstr(deref(mbs.v), robotIndex, tb.impl, tdb.impl, dt, SpringJointVector(sjs).v)
self.impl = new c_qp.MotionSpringConstr(deref(mbs.v), robotIndex, c_qp_private.FD2ShPtr(fd.impl), tb.impl, tdb.impl, dt, SpringJointVector(sjs).v)
self.cf_base = self.impl
self.genineq_base = self.impl
self.constraint_base = self.impl
Expand Down
14 changes: 12 additions & 2 deletions binding/python/tests/TestQPMultiRobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ def test(self):
mb1, mbc1Init = arms.makeZXZArm()
rbdyn.forwardKinematics(mb1, mbc1Init)
rbdyn.forwardVelocity(mb1, mbc1Init)
self.fd1 = rbdyn.ForwardDynamics(mb1)
self.fd1.computeH(mb1, mbc1Init)
self.fd1.computeC(mb1, mbc1Init)

mb2, mbc2Init = arms.makeZXZArm(False)
if not LEGACY:
Expand All @@ -164,6 +167,9 @@ def test(self):
mbc2Init.q[0] = [mb2InitOri.w(), mb2InitOri.x(), mb2InitOri.y(), mb2InitOri.z(), mb2InitPos.x(), mb2InitPos.y() + 1, mb2InitPos.z()]
rbdyn.forwardKinematics(mb2, mbc2Init)
rbdyn.forwardVelocity(mb2, mbc2Init)
self.fd2 = rbdyn.ForwardDynamics(mb2)
self.fd2.computeH(mb2, mbc2Init)
self.fd2.computeC(mb2, mbc2Init)

if not LEGACY:
X_0_b1 = sva.PTransformd(mbc1Init.bodyPosW[-1])
Expand Down Expand Up @@ -228,8 +234,8 @@ def test(self):
torqueMax1 = [[], [Inf], [Inf], [Inf]]
torqueMin2 = [[0,0,0,0,0,0], [-Inf], [-Inf], [-Inf]]
torqueMax2 = [[0,0,0,0,0,0], [Inf], [Inf], [Inf]]
motion1 = tasks.qp.MotionConstr(mbs, 0, tasks.TorqueBound(torqueMin1, torqueMax1))
motion2 = tasks.qp.MotionConstr(mbs, 1, tasks.TorqueBound(torqueMin2, torqueMax2))
motion1 = tasks.qp.MotionConstr(mbs, 0, self.fd1, tasks.TorqueBound(torqueMin1, torqueMax1))
motion2 = tasks.qp.MotionConstr(mbs, 1, self.fd2, tasks.TorqueBound(torqueMin2, torqueMax2))
plCstr = tasks.qp.PositiveLambda()

motion1.addToSolver(solver)
Expand Down Expand Up @@ -264,6 +270,10 @@ def test(self):
rbdyn.eulerIntegration(mbs[i], mbcs[i], 0.001)
rbdyn.forwardKinematics(mbs[i], mbcs[i])
rbdyn.forwardVelocity(mbs[i], mbcs[i])
self.fd1.computeH(mbs[0], mbcs[0])
self.fd1.computeC(mbs[0], mbcs[0])
self.fd2.computeH(mbs[1], mbcs[1])
self.fd2.computeC(mbs[1], mbcs[1])

# Check that the link hold
if not LEGACY:
Expand Down
25 changes: 20 additions & 5 deletions binding/python/tests/TestQPSolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def setUp(self):
rbdyn.forwardVelocity(mb, self.mbcInit)
rbdyn.forwardKinematics(mbEnv, mbcEnv)
rbdyn.forwardVelocity(mbEnv, mbcEnv)
self.fd = rbdyn.ForwardDynamics(mb)
self.fd.computeH(mb, self.mbcInit)
self.fd.computeC(mb, self.mbcInit)

if not LEGACY:
self.mbcs = rbdyn.MultiBodyConfigVector([self.mbcInit, mbcEnv])
Expand Down Expand Up @@ -201,6 +204,8 @@ def run_solver(self):
rbdyn.eulerIntegration(self.mbs[0], self.mbcs[0], 0.001)
rbdyn.forwardKinematics(self.mbs[0], self.mbcs[0])
rbdyn.forwardVelocity(self.mbs[0], self.mbcs[0])
self.fd.computeH(self.mbs[0], self.mbcs[0])
self.fd.computeC(self.mbs[0], self.mbcs[0])

def check_equality_constr(self, ConstrClass, *args):
self.contVec = [tasks.qp.UnilateralContact(0, 1, "b3", "b0", [eigen.Vector3d.Zero()], eigen.Matrix3d.Identity(), sva.PTransformd.Identity(), 3, math.tan(math.pi/4))]
Expand Down Expand Up @@ -255,7 +260,7 @@ def test_motion_constr(self):
Inf = float("inf")
torqueMin = [[], [-Inf], [-Inf], [-Inf]]
torqueMax = [[], [Inf], [Inf], [Inf]]
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, tasks.TorqueBound(torqueMin, torqueMax))
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, self.fd, tasks.TorqueBound(torqueMin, torqueMax))
plCstr = tasks.qp.PositiveLambda()

motionCstr.addToSolver(self.solver)
Expand Down Expand Up @@ -301,7 +306,7 @@ def test_motion_constr_w_contact(self):
Inf = float("inf")
torqueMin = [[], [-Inf], [-Inf], [-Inf]]
torqueMax = [[], [Inf], [Inf], [Inf]]
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, tasks.TorqueBound(torqueMin, torqueMax))
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, self.fd, tasks.TorqueBound(torqueMin, torqueMax))
plCstr = tasks.qp.PositiveLambda()

motionCstr.addToSolver(self.solver)
Expand Down Expand Up @@ -473,6 +478,9 @@ def setUp(self):

rbdyn.forwardKinematics(mb, self.mbcInit)
rbdyn.forwardVelocity(mb, self.mbcInit)
self.fd = rbdyn.ForwardDynamics(mb)
self.fd.computeH(mb, self.mbcInit)
self.fd.computeC(mb, self.mbcInit)

if not LEGACY:
self.mbcs = rbdyn.MultiBodyConfigVector([self.mbcInit])
Expand All @@ -499,7 +507,7 @@ def tearDown(self):
def test_motion_constr(self):
lBound = [[], [-30], [-30], [-30]]
uBound = [[], [30], [30], [30]]
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, tasks.TorqueBound(lBound, uBound))
motionCstr = tasks.qp.MotionConstr(self.mbs, 0, self.fd, tasks.TorqueBound(lBound, uBound))

self.solver.addGenInequalityConstraint(motionCstr)
self.assertEqual(self.solver.nrGenInequalityConstraints(), 1)
Expand All @@ -522,6 +530,8 @@ def test_motion_constr(self):
rbdyn.eulerIntegration(self.mbs[0], self.mbcs[0], 0.001)
rbdyn.forwardKinematics(self.mbs[0], self.mbcs[0])
rbdyn.forwardVelocity(self.mbs[0], self.mbcs[0])
self.fd.computeH(self.mbs[0], self.mbcs[0])
self.fd.computeC(self.mbs[0], self.mbcs[0])
motionCstr.computeTorque(self.solver.alphaDVec(), self.solver.lambdaVec())
motionCstr.torque(self.mbs, self.mbcs)
if not LEGACY:
Expand Down Expand Up @@ -579,7 +589,7 @@ def test_motion_poly_constr(self):
null = eigen.VectorXd()
lBoundPoly = [[null], [lpoly], [lpoly], [lpoly]]
uBoundPoly = [[null], [upoly], [upoly], [upoly]]
motionPolyCstr = tasks.qp.MotionPolyConstr(self.mbs, 0, tasks.PolyTorqueBound(lBoundPoly, uBoundPoly))
motionPolyCstr = tasks.qp.MotionPolyConstr(self.mbs, 0, self.fd, tasks.PolyTorqueBound(lBoundPoly, uBoundPoly))

motionPolyCstr.addToSolver(self.solver)
self.assertEqual(self.solver.nrGenInequalityConstraints(), 1)
Expand Down Expand Up @@ -803,6 +813,9 @@ def test(self):
rbdyn.forwardVelocity(mb, mbcInit)
rbdyn.forwardKinematics(mbEnv, mbcEnv)
rbdyn.forwardVelocity(mbEnv, mbcEnv)
self.fd = rbdyn.ForwardDynamics(mb)
self.fd.computeH(mb, mbcInit)
self.fd.computeC(mb, mbcInit)

if not LEGACY:
mbs = rbdyn.MultiBodyVector([mb, mbEnv])
Expand All @@ -816,7 +829,7 @@ def test(self):
Inf = float("inf")
torqueMin = [[0, 0, 0, 0, 0, 0], [-Inf], [-Inf], [-Inf]]
torqueMax = [[0, 0, 0, 0, 0, 0], [Inf], [Inf], [Inf]]
motionCstr = tasks.qp.MotionConstr(mbs, 0, tasks.TorqueBound(torqueMin, torqueMax))
motionCstr = tasks.qp.MotionConstr(mbs, 0, self.fd, tasks.TorqueBound(torqueMin, torqueMax))
plCstr = tasks.qp.PositiveLambda()
contCstrAcc = tasks.qp.ContactAccConstr()

Expand Down Expand Up @@ -858,6 +871,8 @@ def test(self):
rbdyn.eulerIntegration(mbs[0], mbcs[0], 0.001)
rbdyn.forwardKinematics(mbs[0], mbcs[0])
rbdyn.forwardVelocity(mbs[0], mbcs[0])
self.fd.computeH(mbs[0], mbcs[0])
self.fd.computeC(mbs[0], mbcs[0])

plCstr.removeFromSolver(solver)
contCstrAcc.removeFromSolver(solver)
Expand Down
28 changes: 26 additions & 2 deletions src/GenQPUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace qp
{

// Value add to the diagonal to ensure positive matrix
static const double DIAG_CONSTANT = 1e-4;
static const double DIAG_CONSTANT = 1e-4;

/**
* Fill the \f$ Q \f$ matrix and the \f$ c \f$ vector based on the
Expand Down Expand Up @@ -112,6 +112,8 @@ inline int fillEq(const std::vector<Equality *> & eq,
Eigen::VectorXd & AL,
Eigen::VectorXd & AU)
{
// std::cout << "Rafa, in GenQPUtils::fillEq, nrALines = ";

for(std::size_t i = 0; i < eq.size(); ++i)
{
// ineq constraint can return a matrix with more line
Expand All @@ -120,13 +122,19 @@ inline int fillEq(const std::vector<Equality *> & eq,
const Eigen::MatrixXd & Ai = eq[i]->AEq();
const Eigen::VectorXd & bi = eq[i]->bEq();

// std::cout << "(" << eq[i]->nameEq() << ") "; // Added by Rafa

A.block(nrALines, 0, nrConstr, nrVars) = Ai.block(0, 0, nrConstr, nrVars);
AL.segment(nrALines, nrConstr) = bi.head(nrConstr);
AU.segment(nrALines, nrConstr) = bi.head(nrConstr);

nrALines += nrConstr;

// std::cout << nrALines << " "; // Added by Rafa
}

// std::cout << std::endl; // Added by Rafa

return nrALines;
}

Expand All @@ -141,6 +149,8 @@ inline int fillInEq(const std::vector<Inequality *> & inEq,
Eigen::VectorXd & AL,
Eigen::VectorXd & AU)
{
// std::cout << "Rafa, in GenQPUtils::fillInEq, nrALines = ";

for(std::size_t i = 0; i < inEq.size(); ++i)
{
// ineq constraint can return a matrix with more line
Expand All @@ -149,13 +159,19 @@ inline int fillInEq(const std::vector<Inequality *> & inEq,
const Eigen::MatrixXd & Ai = inEq[i]->AInEq();
const Eigen::VectorXd & bi = inEq[i]->bInEq();

// std::cout << "(" << inEq[i]->nameInEq() << ") "; // Added by Rafa

A.block(nrALines, 0, nrConstr, nrVars) = Ai.block(0, 0, nrConstr, nrVars);
AL.segment(nrALines, nrConstr).fill(-std::numeric_limits<double>::infinity());
AU.segment(nrALines, nrConstr) = bi.head(nrConstr);

nrALines += nrConstr;

// std::cout << nrALines << " "; // Added by Rafa
}

// std::cout << std::endl; // Added by Rafa

return nrALines;
}

Expand All @@ -170,6 +186,8 @@ inline int fillGenInEq(const std::vector<GenInequality *> & genInEq,
Eigen::VectorXd & AL,
Eigen::VectorXd & AU)
{
// std::cout << "Rafa, in GenQPUtils::fillGenInEq, nrALines = ";

for(std::size_t i = 0; i < genInEq.size(); ++i)
{
// ineq constraint can return a matrix with more line
Expand All @@ -179,13 +197,19 @@ inline int fillGenInEq(const std::vector<GenInequality *> & genInEq,
const Eigen::VectorXd & ALi = genInEq[i]->LowerGenInEq();
const Eigen::VectorXd & AUi = genInEq[i]->UpperGenInEq();

// std::cout << "(" << genInEq[i]->nameGenInEq() << ") "; // Added by Rafa

A.block(nrALines, 0, nrConstr, nrVars) = Ai.block(0, 0, nrConstr, nrVars);
AL.segment(nrALines, nrConstr) = ALi.head(nrConstr);
AU.segment(nrALines, nrConstr) = AUi.head(nrConstr);

nrALines += nrConstr;
}

// std::cout << nrALines << " "; // Added by Rafa
}

// std::cout << std::endl; // Added by Rafa

return nrALines;
}

Expand Down
Loading