public static void Create(GameObject linkObject, Link.Inertial inertial = null) { UrdfInertial urdfInertial = linkObject.AddComponent <UrdfInertial>(); Rigidbody _rigidbody = urdfInertial.GetComponent <Rigidbody>(); if (inertial != null) { _rigidbody.mass = (float)inertial.mass; if (inertial.origin != null) { _rigidbody.centerOfMass = UrdfOrigin.GetPositionFromUrdf(inertial.origin); } urdfInertial.ImportInertiaData(inertial.inertia); urdfInertial.UseUrdfData = true; } urdfInertial.DisplayInertiaGizmo = false; //Save original rigidbody data from URDF urdfInertial.CenterOfMass = _rigidbody.centerOfMass; urdfInertial.InertiaTensor = _rigidbody.inertiaTensor; urdfInertial.InertiaTensorRotation = _rigidbody.inertiaTensorRotation; }
public static void Create(GameObject linkObject, Link.Inertial inertial = null) { UrdfInertial urdfInertial = linkObject.AddComponent <UrdfInertial>(); #if UNITY_2020_1_OR_NEWER ArticulationBody robotLink = urdfInertial.GetComponent <ArticulationBody>(); #else Rigidbody robotLink = urdfInertial.GetComponent <Rigidbody>(); #endif if (inertial != null) { robotLink.mass = (float)inertial.mass; if (inertial.origin != null) { robotLink.centerOfMass = UrdfOrigin.GetPositionFromUrdf(inertial.origin); } else { robotLink.centerOfMass = Vector3.zero; } urdfInertial.ImportInertiaData(inertial); urdfInertial.useUrdfData = true; } urdfInertial.displayInertiaGizmo = false; }
public static void Create(GameObject linkObject, Link.Inertial inertial) { UrdfInertial urdfInertial = linkObject.AddComponent <UrdfInertial>(); urdfInertial.UrdfMass = (float)inertial.mass; if (inertial.origin != null) { urdfInertial.UrdfCenterOfMass = UrdfOrigin.GetPositionFromUrdf(inertial.origin); } urdfInertial.ImportInertiaData(inertial.inertia); urdfInertial.Initialize(); urdfInertial.isCreated = true; }