Add policies for global attribute conflict resolution upon attach
For example when loading parent_merge.xml: ``` WARNING: Attach conflict when attaching 'child' to 'parent_merge', policy is 'merge' timestep: parent has 0.005, child has 0.002, taking the minimum iterations: parent has 50, child has 100, taking the maximum flag 'Damper': added from child ``` When loading parent_error.xml: ``` XML Error: Attach conflict when attaching 'child' to 'parent_error', policy is 'error' timestep: parent has 0.005, child has 0.002 iterations: parent has 50, child has 100 Element 'attach', line 10 ``` PiperOrigin-RevId: 933620810 Change-Id: Ib477863b5ef763474d27fb4be5a4148be1d5d500
This commit is contained in:
committed by
Copybara-Service
parent
30357c38a3
commit
410c73168c
@@ -2331,6 +2331,12 @@ struct MjsCompiler {
|
||||
void set_alignfree(int value) {
|
||||
ptr_->alignfree = value;
|
||||
}
|
||||
int conflict() const {
|
||||
return ptr_->conflict;
|
||||
}
|
||||
void set_conflict(int value) {
|
||||
ptr_->conflict = value;
|
||||
}
|
||||
mjString meshdir() const {
|
||||
return (ptr_ && ptr_->meshdir) ? *(ptr_->meshdir) : "";
|
||||
}
|
||||
@@ -11312,6 +11318,10 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) {
|
||||
enum_<mjtCone>("mjtCone")
|
||||
.value("mjCONE_PYRAMIDAL", mjCONE_PYRAMIDAL)
|
||||
.value("mjCONE_ELLIPTIC", mjCONE_ELLIPTIC);
|
||||
enum_<mjtConflict>("mjtConflict")
|
||||
.value("mjCONFLICT_WARNING", mjCONFLICT_WARNING)
|
||||
.value("mjCONFLICT_MERGE", mjCONFLICT_MERGE)
|
||||
.value("mjCONFLICT_ERROR", mjCONFLICT_ERROR);
|
||||
enum_<mjtConstraint>("mjtConstraint")
|
||||
.value("mjCNSTR_EQUALITY", mjCNSTR_EQUALITY)
|
||||
.value("mjCNSTR_FRICTION_DOF", mjCNSTR_FRICTION_DOF)
|
||||
@@ -12993,6 +13003,7 @@ EMSCRIPTEN_BINDINGS(mujoco_bindings) {
|
||||
.property("balanceinertia", &MjsCompiler::balanceinertia, &MjsCompiler::set_balanceinertia, reference())
|
||||
.property("boundinertia", &MjsCompiler::boundinertia, &MjsCompiler::set_boundinertia, reference())
|
||||
.property("boundmass", &MjsCompiler::boundmass, &MjsCompiler::set_boundmass, reference())
|
||||
.property("conflict", &MjsCompiler::conflict, &MjsCompiler::set_conflict, reference())
|
||||
.property("degree", &MjsCompiler::degree, &MjsCompiler::set_degree, reference())
|
||||
.property("discardvisual", &MjsCompiler::discardvisual, &MjsCompiler::set_discardvisual, reference())
|
||||
.property("eulerseq", &MjsCompiler::eulerseq)
|
||||
|
||||
@@ -1803,6 +1803,36 @@ describe('MuJoCo WASM Bindings', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should compile a spec and emit warnings', () => {
|
||||
const xml = `
|
||||
<mujoco>
|
||||
<worldbody>
|
||||
<flexcomp name="test" type="grid" count="4 4 1" spacing=".2 .2 .2"
|
||||
dim="2" radius=".1"/>
|
||||
</worldbody>
|
||||
</mujoco>`;
|
||||
let spec = null;
|
||||
let model = null;
|
||||
const warnSpy = spyOn(console, 'warn');
|
||||
try {
|
||||
spec = mujoco.parseXMLString(xml);
|
||||
expect(spec).not.toBeNull();
|
||||
|
||||
model = mujoco.mj_compile(spec);
|
||||
expect(model).not.toBeNull();
|
||||
expect(warnSpy).toHaveBeenCalled();
|
||||
const warningCall = warnSpy.calls.mostRecent();
|
||||
expect(warningCall.args[0]).toContain("no equality constraints or passive forces");
|
||||
} finally {
|
||||
if (spec) {
|
||||
spec.delete();
|
||||
}
|
||||
if (model) {
|
||||
model.delete();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('should compile a spec from XML string with no assets', () => {
|
||||
let spec = null;
|
||||
let model = null;
|
||||
|
||||
Reference in New Issue
Block a user