Clarify error messages when Unity fails to step the scene.

PiperOrigin-RevId: 527486144
Change-Id: I4e889977e035e13557c114e875ea0ba32da79002
This commit is contained in:
Tom Erez
2023-04-26 23:29:19 -07:00
committed by Copybara-Service
parent e3cdc410d6
commit 139328f86e
+10 -13
View File
@@ -178,12 +178,12 @@ public class MjScene : MonoBehaviour {
XmlDocument mjcf, IEnumerable<MjComponent> components) { XmlDocument mjcf, IEnumerable<MjComponent> components) {
Model = MjEngineTool.LoadModelFromString(mjcf.OuterXml); Model = MjEngineTool.LoadModelFromString(mjcf.OuterXml);
if (Model == null) { if (Model == null) {
throw new NullReferenceException("Failed to create Mujoco runtime model."); throw new NullReferenceException("Model loading failed, see other errors for root cause.");
} else { } else {
Data = MujocoLib.mj_makeData(Model); Data = MujocoLib.mj_makeData(Model);
} }
if (Data == null) { if (Data == null) {
throw new NullReferenceException("Failed to create Mujoco runtime data."); throw new NullReferenceException("Model loaded but mj_makeData failed.");
} }
// Bind the components to their Mujoco counterparts. // Bind the components to their Mujoco counterparts.
@@ -472,18 +472,15 @@ public class MjScene : MonoBehaviour {
Debug.LogWarning("Failed to save Xml to a file: " + ex.ToString(), this); Debug.LogWarning("Failed to save Xml to a file: " + ex.ToString(), this);
} }
} }
} }
public class MjStepArgs : EventArgs public class MjStepArgs : EventArgs
{ {
public unsafe MjStepArgs(MujocoLib.mjModel_* model, MujocoLib.mjData_* data){ public unsafe MjStepArgs(MujocoLib.mjModel_* model, MujocoLib.mjData_* data){
this.model = model; this.model = model;
this.data = data; this.data = data;
}
public readonly unsafe MujocoLib.mjModel_* model;
public readonly unsafe MujocoLib.mjData_* data;
} }
public readonly unsafe MujocoLib.mjModel_* model;
public readonly unsafe MujocoLib.mjData_* data;
}
} }