Add mj_copyBack for copying real-valued arrays from mjModel back to mjSpec.
Also add `SaveAndReadXML` function to test fixture using `mjSpec` as input. PiperOrigin-RevId: 765393821 Change-Id: Ic257addd2fc89678fc11b226c168c077626cc51e
This commit is contained in:
committed by
Copybara-Service
parent
072c872deb
commit
84ad22a590
@@ -375,6 +375,14 @@ int mjs_setDeepCopy(mjSpec* s, int deepcopy) {
|
||||
|
||||
|
||||
|
||||
// copy real-valued arrays from model to spec, returns 1 on success
|
||||
int mj_copyBack(mjSpec* s, const mjModel* m) {
|
||||
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||
return model->CopyBack(m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// delete object, return 0 on success
|
||||
int mjs_delete(mjsElement* element) {
|
||||
mjCModel* model;
|
||||
|
||||
@@ -66,6 +66,9 @@ MJAPI int mjs_activatePlugin(mjSpec* s, const char* name);
|
||||
// Turn deep copy on or off attach. Returns 0 on success.
|
||||
MJAPI int mjs_setDeepCopy(mjSpec* s, int deepcopy);
|
||||
|
||||
// Copy real-valued arrays from model to spec, returns 1 on success.
|
||||
MJAPI int mj_copyBack(mjSpec* s, const mjModel* m);
|
||||
|
||||
|
||||
//---------------------------------- Attachment ----------------------------------------------------
|
||||
|
||||
|
||||
@@ -4759,6 +4759,11 @@ bool mjCModel::CopyBack(const mjModel* m) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spec.element->signature != m->signature) {
|
||||
errInfo = mjCError(0, "incompatible signatures in CopyBack");
|
||||
return false;
|
||||
}
|
||||
|
||||
// option and visual
|
||||
option = m->opt;
|
||||
visual = m->vis;
|
||||
|
||||
Reference in New Issue
Block a user