Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated imu base estimation. #917

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

G-Cervettini
Copy link
Contributor

@G-Cervettini G-Cervettini commented Dec 16, 2024

This PR involves the first stable release of the BaseEstimatorFromFootIMU.
As agreed with @GiulioRomualdi this PR replaces #792 to solve its conflicts.

@G-Cervettini G-Cervettini changed the title Updated imu base estimation. Replaces: https://github.com/ami-iit/bipedal-locomotion-framework/pull/792 Updated imu base estimation. Dec 16, 2024
@@ -12,7 +12,7 @@
#include <BipedalLocomotion/ParametersHandler/IParametersHandler.h>
#include <BipedalLocomotion/System/Advanceable.h>
#include <iDynTree/KinDynComputations.h>
#include <iDynTree/Model.h>
#include <iDynTree/Model/Model.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should revert this change, as this way of including iDynTree headers has been deprecated since version 10.0.0

Comment on lines +47 to +54
bool isLeftStance; /**< true if the left foot is in contact with the ground */
bool isRightStance; /**< true if the right foot is in contact with the ground */
Eigen::VectorXd jointPositions; /**< vector of the robot joint positions */
Eigen::VectorXd jointVelocities; /**< vector of the robot joint velocities */
manif::SE3d desiredFootPose; /**< desired orientation and position of the foot
as per footstep planner output */
manif::SO3d measuredRotation; /**< actual orientation of the foot measured by
on-board IMU */
manif::SE3d offsetStanceFootPose; /**< Optional offset orientation and position of the foot.
E.g. as per footstep planner output */
manif::SO3d measuredRotation_L; /**< actual orientation of the left foot measured by
on-board IMU */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a single notation. Either:

  • isStance_L and measuredRotation_L

or

  • isLeftStance and measuredLeftRotation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this:

isLeftStance and measuredLeftRotation

Comment on lines +14 to +19
Eigen::Vector3d toXYZ(const Eigen::Matrix3d& r)
{
Eigen::Vector3d output;
double& thetaZ = output[0]; // Roll
double& thetaX = output[0]; // Roll
double& thetaY = output[1]; // Pitch
double& thetaX = output[2]; // Yaw
double& thetaZ = output[2]; // Yaw
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How comes that you changed the order of the angles and the computations remain the same? Was it bugged before?

m_cornersInLocalFrame.emplace_back(-m_footWidth / 2, -m_footLength / 2, 0);
m_cornersInLocalFrame.emplace_back(+m_footWidth / 2, -m_footLength / 2, 0);
// Frame associated to the base of the robot (whose pose is estimated)
bool ok = populateParameter(baseEstimatorPtr->getGroup("MODEL_INFO"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider storing the output of baseEstimatorPtr->getGroup("MODEL_INFO") since you are using it multiple times below

Comment on lines +254 to +258
// Eigen::Matrix3d stepRot = m_state.footPose_R.rotation().inverse() * m_state.footPose_L.rotation();
// Eigen::Vector3d stepRotRPY = toXYZ(stepRot);
// manif::SO3d stepRotManif = manif::SO3d(stepRotRPY(0), stepRotRPY(1), stepRotRPY(2));
// manif::SE3d T_walkRot(m_noTras, stepRotManif);
// manif::SE3d temp = T_walkTras * T_walkRot * m_T_walk * m_T_yawDrift;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover? There is also some other commented code below

}
}

m_stanceLinkIndex = m_model.getFrameLink(stanceFootFrameIndex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if both isLeftStance and isRightStance are false? Can it happen? Maybe it is worth printing an error in this case?

Copy link
Member

@GiulioRomualdi GiulioRomualdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other comments

manif::SE3d::Tangent baseVelocity; /**< velocity of the robot root link. */
manif::SE3d footPose_L; /**< pose of the left foot */
manif::SE3d footPose_R; /**< pose of the right foot */
Eigen::Vector3d centerOfMassPosition;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid propagating the CoM position. In the end the base estimator should provide the base state

Comment on lines +37 to +39
std::vector<Eigen::Vector3d> stanceFootShadowCorners;
std::vector<Eigen::Vector3d> stanceFootCorners;
int supportCornerIndex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add comments for this?

Comment on lines +47 to +54
bool isLeftStance; /**< true if the left foot is in contact with the ground */
bool isRightStance; /**< true if the right foot is in contact with the ground */
Eigen::VectorXd jointPositions; /**< vector of the robot joint positions */
Eigen::VectorXd jointVelocities; /**< vector of the robot joint velocities */
manif::SE3d desiredFootPose; /**< desired orientation and position of the foot
as per footstep planner output */
manif::SO3d measuredRotation; /**< actual orientation of the foot measured by
on-board IMU */
manif::SE3d offsetStanceFootPose; /**< Optional offset orientation and position of the foot.
E.g. as per footstep planner output */
manif::SO3d measuredRotation_L; /**< actual orientation of the left foot measured by
on-board IMU */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this:

isLeftStance and measuredLeftRotation

@@ -120,6 +139,8 @@ class BaseEstimatorFromFootIMU
*/
const BaseEstimatorFromFootIMUState& getOutput() const override;

void resetBaseEstimatorFromFootIMU();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add the documentation to this function?

Comment on lines +196 to +198
manif::SE3d m_T_walk;
manif::SE3d m_T_yawDrift;
double m_yawOld;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please comment this quantities?

Comment on lines +324 to +330
// MANUAL CORRECTION: measured Roll, Pitch and Yaw.
// double temp_roll = -m_measuredRPY(1);
// double temp_pitch = -m_measuredRPY(0);
// double temp_yaw = -m_measuredRPY(2);
// m_measuredRPY(0) = temp_roll;
// m_measuredRPY(1) = temp_pitch;
// m_measuredRPY(2) = temp_yaw;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this code if not required

// desired position.
switch (supportCornerIndex)
// checking that the index of the lowest corner is within the range [0, 3].
if (!(0 <= m_state.supportCornerIndex <= 3))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would simplify the if state as

Suggested change
if (!(0 <= m_state.supportCornerIndex <= 3))
if (m_state.supportCornerIndex > 3 || m_state.supportCornerIndex < 0)

Comment on lines +502 to +505
// std::cerr << "L FOOT ROTATION IN: " << toXYZ(m_input.measuredRotation_L.rotation()).transpose() << std::endl;
// std::cerr << "L FOOT ROTATION OUT: " << toXYZ(m_state.footPose_L.rotation()).transpose() << std::endl;
// std::cerr << "R FOOT ROTATION IN: " << toXYZ(m_input.measuredRotation_R.rotation()).transpose() << std::endl;
// std::cerr << "R FOOT ROTATION OUT: " << toXYZ(m_state.footPose_R.rotation()).transpose() << std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// std::cerr << "L FOOT ROTATION IN: " << toXYZ(m_input.measuredRotation_L.rotation()).transpose() << std::endl;
// std::cerr << "L FOOT ROTATION OUT: " << toXYZ(m_state.footPose_L.rotation()).transpose() << std::endl;
// std::cerr << "R FOOT ROTATION IN: " << toXYZ(m_input.measuredRotation_R.rotation()).transpose() << std::endl;
// std::cerr << "R FOOT ROTATION OUT: " << toXYZ(m_state.footPose_R.rotation()).transpose() << std::endl;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants