Add time to attached keyframes.

PiperOrigin-RevId: 662886533
Change-Id: If9118a226250d2e806d184c9715c7e6a1390fd95
This commit is contained in:
Alessio Quaglino
2024-08-14 05:46:36 -07:00
committed by Copybara-Service
parent 7be4df7e03
commit 5927b3d4d9
3 changed files with 13 additions and 10 deletions
+2
View File
@@ -2952,6 +2952,7 @@ void mjCModel::StoreKeyframes() {
for (auto key : keys_) {
mjKeyInfo info;
info.name = prefix + key->name + suffix;
info.time = key->spec.time;
info.qpos = !key->spec_qpos_.empty();
info.qvel = !key->spec_qvel_.empty();
info.act = !key->spec_act_.empty();
@@ -3529,6 +3530,7 @@ void mjCModel::ResolveKeyframes(const mjModel* m) {
for (const auto& info : key_pending_) {
mjCKey* key = (mjCKey*)FindObject(mjOBJ_KEY, info.name);
key->name = info.name;
key->spec.time = info.time;
if (info.qpos) key->spec_qpos_.assign(nq, 0);
if (info.qvel) key->spec_qvel_.assign(nv, 0);
if (info.act) key->spec_act_.assign(na, 0);
+1
View File
@@ -36,6 +36,7 @@ typedef std::array<mjKeyMap, mjNOBJECT> mjListKeyMap;
typedef struct mjKeyInfo_ {
std::string name;
double time;
bool qpos;
bool qvel;
bool act;
+10 -10
View File
@@ -430,8 +430,8 @@ static constexpr char xml_child[] = R"(
</contact>
<keyframe>
<key name="two" qpos="2" act="2 2" ctrl="2 2"/>
<key name="three" qpos="3" act="3 3" ctrl="3 3"/>
<key name="two" time="2" qpos="2" act="2 2" ctrl="2 2"/>
<key name="three" time="3" qpos="3" act="3 3" ctrl="3 3"/>
</keyframe>
</mujoco>)";
@@ -501,10 +501,10 @@ TEST_F(MujocoTest, AttachSame) {
</contact>
<keyframe>
<key name="two" qpos="2 0" act="2 2 0 0" ctrl="2 2 0 0"/>
<key name="three" qpos="3 0" act="3 3 0 0" ctrl="3 3 0 0"/>
<key name="attached-two-1" qpos="0 2" act="0 0 2 2" ctrl="0 0 2 2"/>
<key name="attached-three-1" qpos="0 3" act="0 0 3 3" ctrl="0 0 3 3"/>
<key name="two" time="2" qpos="2 0" act="2 2 0 0" ctrl="2 2 0 0"/>
<key name="three" time="3" qpos="3 0" act="3 3 0 0" ctrl="3 3 0 0"/>
<key name="attached-two-1" time="2" qpos="0 2" act="0 0 2 2" ctrl="0 0 2 2"/>
<key name="attached-three-1" time="3" qpos="0 3" act="0 0 3 3" ctrl="0 0 3 3"/>
</keyframe>
</mujoco>)";
@@ -621,8 +621,8 @@ TEST_F(MujocoTest, AttachDifferent) {
</contact>
<keyframe>
<key name="attached-two-1" qpos="0 0 0 1 0 0 0 2" act="2 2" ctrl="2 2"/>
<key name="attached-three-1" qpos="0 0 0 1 0 0 0 3" act="3 3" ctrl="3 3"/>
<key name="attached-two-1" time="2" qpos="0 0 0 1 0 0 0 2" act="2 2" ctrl="2 2"/>
<key name="attached-three-1" time="3" qpos="0 0 0 1 0 0 0 3" act="3 3" ctrl="3 3"/>
</keyframe>
</mujoco>)";
@@ -743,8 +743,8 @@ TEST_F(MujocoTest, AttachFrame) {
</contact>
<keyframe>
<key name="attached-two-1" qpos="0 0 0 1 0 0 0 2" act="2 2" ctrl="2 2"/>
<key name="attached-three-1" qpos="0 0 0 1 0 0 0 3" act="3 3" ctrl="3 3"/>
<key name="attached-two-1" time="2" qpos="0 0 0 1 0 0 0 2" act="2 2" ctrl="2 2"/>
<key name="attached-three-1" time="3" qpos="0 0 0 1 0 0 0 3" act="3 3" ctrl="3 3"/>
</keyframe>
</mujoco>)";