-
Notifications
You must be signed in to change notification settings - Fork 48
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
[RTR] Multi Biorbd Model #625
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @EveCharbie)
bioptim/interfaces/biomodel.py
line 17 at r1 (raw file):
"""Get the gravity vector""" def set_gravity(self, new_gravity, model_index: int = 0):
Change those for not implemented when required
Code quote:
y, model_index: int = 0
bioptim/interfaces/biorbd_model.py
line 4 at r1 (raw file):
from ..misc.utils import check_version from .multi_biorbd_model import MultiBiorbdModel
Keep them in a single file
Code quote:
from ..misc.utils import check_version
from .multi_biorbd_model import MultiBiorbdModel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 14 files reviewed, 2 unresolved discussions (waiting on @pariterre)
bioptim/interfaces/biomodel.py
line 17 at r1 (raw file):
Previously, pariterre (Pariterre) wrote…
Change those for not implemented when required
Done.
bioptim/interfaces/biorbd_model.py
line 4 at r1 (raw file):
Previously, pariterre (Pariterre) wrote…
Keep them in a single file
Done.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #625 +/- ##
==========================================
+ Coverage 81.70% 81.90% +0.19%
==========================================
Files 108 109 +1
Lines 11924 12133 +209
==========================================
+ Hits 9743 9937 +194
- Misses 2181 2196 +15
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@pariterre I think we are good to go :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @EveCharbie)
bioptim/interfaces/biorbd_model.py
line 479 at r2 (raw file):
raise ValueError("Wrong index") # raise NotImplementedError("rigid_contact_acceleration is not implemented yet for multi models") # @pariterre I think we should remove it if we know it is broken! return self.model.rigidContactAcceleration(q, qdot, qddot, 0, True).to_mx()[index_direction]
Can we not just change this "0" for "index"? If this fails (for instance Segmentation Fault), I would vote for removing this method altogether
Code quote:
0
tests/test_biorbd_multi_model.py
line 82 at r2 (raw file):
models.set_gravity(np.array([0, 0, -3])) model_gravity_modified = Function("Gravity", [], [models.gravity])()["o0"] # segment_index = models.segment_index("Seg1")
This should expect a raise
with pytest.raise(RuntimeError, match="error message"):
segment_index = models.segment_index("Seg1")
Those below as well!
Code quote:
# segment_index = models.segment_index("Seg1")
tests/test_global_torque_driven_ocp.py
line 583 at r2 (raw file):
return # TODO: when it is not broken anymore, the following results should be good sol = ocp.solve()
What was the reason to remove those?
Code quote:
np.testing.assert_almost_equal(g, np.zeros((40, 1)), decimal=6)
# Check some of the results
states, controls, states_no_intermediate = sol.states, sol.controls, sol.states_no_intermediate
# initial and final position
np.testing.assert_almost_equal(states[0]["q"][:, 0], np.array([-3.14159265, 0.0]), decimal=6)
np.testing.assert_almost_equal(states[0]["q"][:, -1], np.array([3.04159296, 0.0]), decimal=3)
np.testing.assert_almost_equal(states[1]["q"][:, 0], np.array([-3.14159265, 0.0]), decimal=6)
np.testing.assert_almost_equal(states[1]["q"][:, -1], np.array([3.04159271, 0.0]), decimal=6)
# initial and final velocities
np.testing.assert_almost_equal(states[0]["qdot"][:, 0], np.array([11.47768245, 26.16790572]), decimal=6)
np.testing.assert_almost_equal(states[0]["qdot"][:, -1], np.array([11.52232512, 26.06343438]), decimal=6)
np.testing.assert_almost_equal(states[1]["qdot"][:, 0], np.array([10.54030594, 28.30202101]), decimal=6)
np.testing.assert_almost_equal(states[1]["qdot"][:, -1], np.array([10.594124, 28.17553337]), decimal=6)
# initial and final controls
np.testing.assert_almost_equal(controls[0]["tau"][:, 0], np.array([0.01906557]), decimal=6)
np.testing.assert_almost_equal(controls[0]["tau"][:, -2], np.array([-0.00619146]), decimal=6)
np.testing.assert_equal(controls[1], {})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @pariterre)
bioptim/interfaces/biorbd_model.py
line 479 at r2 (raw file):
Previously, pariterre (Pariterre) wrote…
Can we not just change this "0" for "index"? If this fails (for instance Segmentation Fault), I would vote for removing this method altogether
Fatal Python error: Segmentation fault
But it is used in the DAE_INVERSE_DYNAMICS with contact.
Do we let it as is ?
tests/test_biorbd_multi_model.py
line 82 at r2 (raw file):
Previously, pariterre (Pariterre) wrote…
This should expect a raise
with pytest.raise(RuntimeError, match="error message"): segment_index = models.segment_index("Seg1")Those below as well!
Done.
tests/test_global_torque_driven_ocp.py
line 583 at r2 (raw file):
Previously, pariterre (Pariterre) wrote…
What was the reason to remove those?
Was not tested anyway, but yeah I can put it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Ipuch)
bioptim/interfaces/biorbd_model.py
line 479 at r2 (raw file):
Previously, EveCharbie (Eve Charbonneau) wrote…
Fatal Python error: Segmentation fault
But it is used in the DAE_INVERSE_DYNAMICS with contact.
Do we let it as is ?
@Ipuch
Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 13 of 14 files reviewed, 1 unresolved discussion (waiting on @pariterre)
bioptim/interfaces/biorbd_model.py
line 479 at r2 (raw file):
Previously, pariterre (Pariterre) wrote…
@Ipuch
Is this expected?
This is expected as there is only one contact in the model. But yes, we should specify the index instead of 0. And remove the TODO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 13 of 14 files reviewed, 2 unresolved discussions (waiting on @EveCharbie and @pariterre)
bioptim/interfaces/biorbd_model.py
line 337 at r2 (raw file):
out = vertcat( out, model.InverseDynamics(
for i, model in enumerate(self.models):
q = q[self.models.index(variable: str = "q", model_index: int = i)]
...
So don't have to track q, qdot and qddot, Disccussed with benjamin. Variable is expected to receive "q", "qdot", "qddot", "markers", "contact", etc...
Need to be applied everywhere you felt the need of tracking. plus this function should be useful for the objective or constraint definition.
Suggestion:
seDynamics(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Ipuch)
bioptim/interfaces/biorbd_model.py
line 337 at r2 (raw file):
self.models.index(variable: str = "q", model_index: int = i)
self.variable_index(variable: str, model_index: int) -> slice
for instance: return slice(init_index, final_index)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Ipuch and @pariterre)
bioptim/interfaces/biorbd_model.py
line 337 at r2 (raw file):
Previously, pariterre (Pariterre) wrote…
self.models.index(variable: str = "q", model_index: int = i)
self.variable_index(variable: str, model_index: int) -> slice
for instance: return slice(init_index, final_index)
Done.
bioptim/interfaces/biorbd_model.py
line 479 at r2 (raw file):
Previously, Ipuch (Pierre Puchaud) wrote…
This is expected as there is only one contact in the model. But yes, we should specify the index instead of 0. And remove the TODO.
Done.
@pariterre I think it is ready to merge :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Ipuch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @EveCharbie)
All Submissions:
New Feature Submissions:
black . -l120 --exclude "external/*"
)?Changes to Core Features:
This change is