Resize keyframes also at the start of compilation.

Previously, it was assumed that attaching was the last operation performed on the mjSpec, so keyframes resulted in the incorrect size. In order to prevent information loss, we now only allow the resize function to expand the keyframe array, since attach should never remove a degree of freedom.

PiperOrigin-RevId: 804917828
Change-Id: Icfacd207ced1c6aac600d514f8d9065ceff2d347
This commit is contained in:
Alessio Quaglino
2025-09-09 08:15:34 -07:00
committed by Copybara-Service
parent 3b738ebb67
commit 9d5063799f
6 changed files with 83 additions and 22 deletions
+5 -2
View File
@@ -432,8 +432,8 @@ class mjCModel : public mjCModel_, private mjSpec {
// convert pending keyframes info to actual keyframes
void ResolveKeyframes(const mjModel* m);
// resize a keyframe, filling in missing values
void ResizeKeyframe(mjCKey* key, const mjtNum* qpos0_, const mjtNum* bpos, const mjtNum* bquat);
// expand a keyframe, filling in missing values
void ExpandKeyframe(mjCKey* key, const mjtNum* qpos0_, const mjtNum* bpos, const mjtNum* bquat);
// compute qpos0
void ComputeReference();
@@ -463,6 +463,9 @@ class mjCModel : public mjCModel_, private mjSpec {
// delete all plugins created by the subtree
void DeleteSubtreePlugin(mjCBody* subtree);
// expand all keyframes in the model
void ExpandAllKeyframes();
mjListKeyMap ids; // map from object names to ids
mjCError errInfo; // last error info
std::vector<mjKeyInfo> key_pending_; // attached keyframes