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

dircon segfault adding post impact velocity constrain when no impact #218

Open
ShaneRozenLevy opened this issue Jan 4, 2021 · 3 comments

Comments

@ShaneRozenLevy
Copy link
Contributor

I recently encountered a very strange bug in dircon.cc. When adding the impact constraint when their is not impact (pre_impact_velocity == post_impact_velocity) the code will segfault (Line 252). This does not seem to happen for every robot (planar walker is fine), but it does effect both Spirit and Cassie.

I found that changing line 249/250 from:
auto pre_impact_velocity = state_vars(i_mode - 1, pre_impact_index) .tail(plant_.num_velocities());
to:
auto pre_impact_state = state_vars(i_mode - 1, pre_impact_index);
auto pre_impact_velocity = pre_impact_state.tail(plant_.num_velocities());

Fixes the issue. I don't understand why this fixes the issue because at a glance the code should do the same thing.

Here is a branch where examples/Spirit:run_spirit_jump fails due to this bug: https://github.com/KodlabPenn/dairlib/tree/dircon_segfault_post_impact_vel_demo

@yangwill
Copy link
Contributor

yangwill commented Jan 4, 2021

Haven't looked too deeply yet, but I think it's possible that the auto keyword is responsible.

@yangwill
Copy link
Contributor

yangwill commented Jan 4, 2021

Declaring pre_impact_velocity as auto makes it type Eigen::Block and declaring it as a VectorXDecisionVariable makes it type Eigen::PlainObjectBase. The Eigen::Block declaration seems to cause issues in the drake symbolic formula.

@mposa
Copy link
Contributor

mposa commented Jan 4, 2021

Yes--coming to the same conclusion here as well. I'll open a quick PR.

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

No branches or pull requests

3 participants