Add keyframe support to attach.

Limitations:
- Supports attaching a single keyframe. If multiple keyframes are present in the child, only the first one will be attached.
- Does not support time, ctrl, mpos, mquat.
- If mjs_detachBody is used, all keyframes are removed.
PiperOrigin-RevId: 662517666
Change-Id: If6e3839471e1884afc14e1a75e7ce1957c2f3581
This commit is contained in:
Alessio Quaglino
2024-08-13 07:59:00 -07:00
committed by Copybara-Service
parent 98cd49d529
commit 19aa68c2b2
6 changed files with 233 additions and 29 deletions
+11 -1
View File
@@ -215,6 +215,10 @@ class mjCBase : public mjCBase_ {
virtual ~mjCBase() = default; // destructor
// reset keyframe references for allowing self-attach
virtual void ForgetKeyframes() {}
virtual void ForgetKeyframes() const {}
protected:
mjCBase(); // constructor
mjCBase(const mjCBase& other); // copy constructor
@@ -315,6 +319,9 @@ class mjCBody : public mjCBody_, private mjsBody {
// get next child of given type
mjsElement* NextChild(mjsElement* child, mjtObj type = mjOBJ_UNKNOWN);
// reset keyframe references for allowing self-attach
void ForgetKeyframes() const;
private:
mjCBody(const mjCBody& other, mjCModel* _model); // copy constructor
mjCBody& operator=(const mjCBody& other); // copy assignment
@@ -1384,7 +1391,7 @@ class mjCActuator_ : public mjCBase {
// variable used for temporarily storing the state of the actuator
int actadr_; // address of dof in data->act
int actnum_; // number of dofs in data->act
int actdim_; // number of dofs in data->act
std::vector<mjtNum> act; // act at the previous step
// variable-size data
@@ -1431,6 +1438,9 @@ class mjCActuator : public mjCActuator_, private mjsActuator {
void ResolveReferences(const mjCModel* m);
void NameSpace(const mjCModel* m);
// reset keyframe references for allowing self-attach
void ForgetKeyframes();
mjCBase* ptarget; // transmission target
};