Skip to content

Commit 5b01ea6

Browse files
GiulioRomualdiergocub
authored andcommitted
Use teh torso orientation velocity to generate a desired angular momentum
1 parent e3a4b2d commit 5b01ea6

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

src/WalkingModule/app/robots/ergoCubGazeboV1_1/dcm_walking/common/plannerParams.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ saturationFactors (0.7, 0.7)
2121

2222
##Bounds
2323
#Step length
24-
maxStepLength 0.34
24+
maxStepLength 0.31
2525
minStepLength 0.01
2626
maxLengthBackwardFactor 1.0
2727
#Width
@@ -32,7 +32,7 @@ maxAngleVariation 18.0
3232
minAngleVariation 5.0
3333
#Timings
3434
maxStepDuration 1.31
35-
minStepDuration 0.5
35+
minStepDuration 0.7
3636

3737
##Nominal Values
3838
#Width

src/WalkingModule/include/WalkingControllers/WalkingModule/Module.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ namespace WalkingControllers
184184
bool solveBLFIK(const iDynTree::Position& desiredCoMPosition,
185185
const iDynTree::Vector3& desiredCoMVelocity,
186186
const iDynTree::Rotation& desiredNeckOrientation,
187+
const iDynTree::SpatialMomentum& desiredCentroidalMomentum,
187188
iDynTree::VectorDynSize &output);
188189

189190
/**

src/WalkingModule/src/Module.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ bool WalkingModule::configure(yarp::os::ResourceFinder &rf)
371371
return false;
372372
}
373373

374+
m_vectorsCollectionServer.populateMetadata("angular_momentum::measured", {"x", "y", "z"});
375+
m_vectorsCollectionServer.populateMetadata("angular_momentum::desired", {"x", "y", "z"});
376+
374377
m_vectorsCollectionServer.populateMetadata("dcm::position::measured", {"x", "y"});
375378
m_vectorsCollectionServer.populateMetadata("dcm::position::desired", {"x", "y"});
376379
m_vectorsCollectionServer.populateMetadata("dcm::velocity::desired", {"x", "y"});
@@ -502,6 +505,7 @@ bool WalkingModule::close()
502505
bool WalkingModule::solveBLFIK(const iDynTree::Position &desiredCoMPosition,
503506
const iDynTree::Vector3 &desiredCoMVelocity,
504507
const iDynTree::Rotation &desiredNeckOrientation,
508+
const iDynTree::SpatialMomentum &centroidalMomentumDesired,
505509
iDynTree::VectorDynSize &output)
506510
{
507511
const std::string phase = m_isStancePhase.front() ? "stance" : "walking";
@@ -516,6 +520,8 @@ bool WalkingModule::solveBLFIK(const iDynTree::Position &desiredCoMPosition,
516520
ok = ok && m_BLFIKSolver->setRetargetingJointSetPoint(m_retargetingClient->jointPositions(),
517521
m_retargetingClient->jointVelocities());
518522

523+
ok = ok && m_BLFIKSolver->setAngularMomentumSetPoint(centroidalMomentumDesired.getAngularVec3());
524+
519525
if (m_useRootLinkForHeight)
520526
{
521527
ok = ok && m_BLFIKSolver->setRootSetPoint(desiredCoMPosition, desiredCoMVelocity);
@@ -902,6 +908,10 @@ bool WalkingModule::updateModule()
902908
yawRotation = yawRotation.inverse();
903909
modifiedInertial = yawRotation * m_inertial_R_worldFrame;
904910

911+
// compute the desired torso velocity
912+
auto torsoVelocity = m_BLFIKSolver->getDesiredTorsoVelocity();
913+
auto centroidalMomentumDesired = m_FKSolver->getKinDyn()->getCentroidalRobotLockedInertia() * torsoVelocity;
914+
905915
if (m_useQPIK)
906916
{
907917
// integrate dq because velocity control mode seems not available
@@ -919,6 +929,7 @@ bool WalkingModule::updateModule()
919929
if (!solveBLFIK(desiredCoMPosition,
920930
desiredCoMVelocity,
921931
yawRotation,
932+
centroidalMomentumDesired,
922933
m_dqDesired))
923934
{
924935
yError() << "[WalkingModule::updateModule] Unable to solve the QP problem with "
@@ -1023,6 +1034,8 @@ bool WalkingModule::updateModule()
10231034
CoMVelocityDesired[1] = m_stableDCMModel->getCoMVelocity().data()[1];
10241035
CoMVelocityDesired[2] = m_retargetingClient->comHeightVelocity();
10251036

1037+
m_vectorsCollectionServer.prepareData();
1038+
m_vectorsCollectionServer.clearData();
10261039
m_vectorsCollectionServer.populateData("com::velocity::desired", CoMVelocityDesired);
10271040

10281041
// Left foot position
@@ -1083,6 +1096,9 @@ bool WalkingModule::updateModule()
10831096
const double isLeftFootFixed = m_isLeftFixedFrame.front() ? 1.0 : 0.0;
10841097
m_vectorsCollectionServer.populateData("stance_foot::is_left", std::array<double, 1>{isLeftFootFixed});
10851098

1099+
m_vectorsCollectionServer.populateData("angular_momentum::measured", m_FKSolver->getKinDyn()->getCentroidalTotalMomentum().getAngularVec3());
1100+
m_vectorsCollectionServer.populateData("angular_momentum::desired", centroidalMomentumDesired.getAngularVec3());
1101+
10861102
m_vectorsCollectionServer.sendData();
10871103
}
10881104

src/WholeBodyControllers/include/WalkingControllers/WholeBodyControllers/BLFIK.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ class BLFIK
4949
bool setCoMSetPoint(const iDynTree::Position& position, const iDynTree::Vector3& velocity);
5050
bool setRootSetPoint(const iDynTree::Position& position, const iDynTree::Vector3& velocity);
5151
bool setTorsoSetPoint(const iDynTree::Rotation& rotation);
52+
bool setAngularMomentumSetPoint(const iDynTree::Vector3& angularMomentum);
5253
const iDynTree::VectorDynSize& getDesiredJointVelocity() const;
5354

55+
iDynTree::Twist getDesiredTorsoVelocity() const;
56+
5457
private:
5558
std::shared_ptr<BipedalLocomotion::ContinuousDynamicalSystem::MultiStateWeightProvider>
5659
m_torsoWeight;

src/WholeBodyControllers/src/BLFIK.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@ bool BLFIK::initialize(
142142

143143
ok = ok && m_qpIK.finalize(m_variableHandler);
144144

145-
m_angularMomentumTask->setSetPoint(Eigen::Vector3d::Zero());
146-
147-
148145
BipedalLocomotion::log()->info("[BLFIK::initialize] {}", m_qpIK.toString());
149146

150147
m_jointVelocity.resize(kinDyn->getNrOfDegreesOfFreedom());
@@ -221,6 +218,11 @@ bool BLFIK::setRegularizationJointSetPoint(const iDynTree::VectorDynSize& jointP
221218
return m_jointRegularizationTask->setSetPoint(iDynTree::toEigen(jointPosition));
222219
}
223220

221+
bool BLFIK::setAngularMomentumSetPoint(const iDynTree::Vector3& angularMomentum)
222+
{
223+
return m_angularMomentumTask->setSetPoint(iDynTree::toEigen(angularMomentum));
224+
}
225+
224226
bool BLFIK::setCoMSetPoint(const iDynTree::Position& position, const iDynTree::Vector3& velocity)
225227
{
226228
return m_comTask->setSetPoint(iDynTree::toEigen(position), iDynTree::toEigen(velocity));
@@ -244,3 +246,11 @@ const iDynTree::VectorDynSize& BLFIK::getDesiredJointVelocity() const
244246
{
245247
return m_jointVelocity;
246248
}
249+
250+
iDynTree::Twist BLFIK::getDesiredTorsoVelocity() const
251+
{
252+
iDynTree::Twist tmp;
253+
tmp.zero();
254+
iDynTree::toEigen(tmp.getAngularVec3()) = m_torsoTask->getB();
255+
return tmp;
256+
}

0 commit comments

Comments
 (0)