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

Topic/contact 6 d closed loop redo #1345

Draft
wants to merge 29 commits into
base: devel
Choose a base branch
from

Conversation

james-p-foster
Copy link
Contributor

@james-p-foster james-p-foster commented Feb 13, 2025

This PR builds off of the LAAS PR. (Let me know if it's more prudent to set that branch as the base for this PR to see the changes I've made).

  • Introduced a notion of a list of forces by repurposing ForceDataAbstract. Now, a vector of ForceDataAbstract is stored in InteractionDataAbstract, which is a new base class for ContactDataAbstract and ImpulseDataAbstract.
  • Added a notion of a list of forces in by adding an nf (number of forces) argument to InteractionDataAbstract. This is exposed in ContactDataAbstract, so the kinematic loop can set it to 2, but for all impulses it is hard-coded to 1.
  • Pullet a lot of common fields in the contact models and impulse models into the top level ForceDataAbstract.

TODO / Questions:

  • I'm not sure how the contact-invdyn changes should work.
  • I haven't done any deprecating yet, just done all the logic changes in place to get it working.
  • I'm pretty sure that the test_contacts_loop.cpp added in the LAAS PR aren't as thorough as they can be. How can we make these tests meaningful?

LudovicDeMatteis and others added 28 commits October 8, 2024 09:16
This corrects the desired contact acceleration, by accouting for drift
in position and velocity
Remove bindings for old data and change operation order for dvel_dq
@hrp2-14
Copy link

hrp2-14 commented Feb 13, 2025

Hi ! This project doesn't usually accept pull requests on the main branch.
If this wasn't intentionnal, you can change the base branch of this PR to devel
(No need to close it for that). Best, a bot.

@cmastalli
Copy link
Member

Hi @james-p-foster ! Please update the PR and change the target branch to devel.

@hrp2-14
Copy link

hrp2-14 commented Feb 13, 2025

Hi ! This project doesn't usually accept pull requests on the main branch.
If this wasn't intentionnal, you can change the base branch of this PR to devel
(No need to close it for that). Best, a bot.

@james-p-foster james-p-foster changed the base branch from master to devel February 13, 2025 22:25
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These bindings probably won't work with the changes I've made.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know how the logic should be changed to handle multiple forces in inverse dynamics. At the moment, I've preserved functionality with the non-loop models by accessing the first force_data

std::vector<pinocchio::FrameIndex>
id_; //!< Reference frame id of the contact
std::vector<pinocchio::SE3> placements_; //!< Placement of contact relative to parent
// TODO(jfoster): only allowing one type per contact model
pinocchio::ReferenceFrame type_; //!< Type of contact
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now have vectors for frame ids and placements, but I kept to just one type, else it caused a mess

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the vector of force datas, you can condense quite a lot of the logic. There are still some coupling terms between the two forces that have to remain however

case pinocchio::ReferenceFrame::LOCAL_WORLD_ALIGNED:
pinocchio.dtau_dq += d_i->dtau_dq;
break;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I probably need to add this logic back in, don't know how it got deleted

virtual ~InteractionDataAbstractTpl() {}

std::size_t nf;
std::vector<ForceDataAbstractTpl<Scalar>> force_datas;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We keep a vector of force datas to represent multiple forces, e.g. from a kinematic loop

const boost::shared_ptr<Base>& model)
: Base(model->get_state(), model->get_type(), model->get_nc(),
const boost::shared_ptr<Base>& model, const int nf)
: Base(model->get_state(), model->get_type(), nf, model->get_nc(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could probably call model->get_nf() internally without the extra constructor arg

if (d3d != NULL) {
found_contact = true;
contact = it->second;
if (it->second->nf == 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This if means we only consider contact models with nf == 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should probably loop over all elements of force_datas instead of just the first element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are we sure the test against num diff is working as intended here? Don't we have to use some pinocchio constraints to enforce the four bar?

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

Successfully merging this pull request may close these issues.

4 participants