public void ImportJointData_SpecificLimit_Succeeds()
        {
            var joint = new Joint(
                name: "custom_joint", type: "planar", parent: "base", child: "link",
                limit: new Joint.Limit(4, 5, 6, 7),
                dynamics: new Joint.Dynamics(8, 9));

            GameObject baseObject = new GameObject("base");
            GameObject linkObject = new GameObject("link");

            linkObject.transform.parent = baseObject.transform;

            UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed);
            TestUrdfJointPlanar urdfJoint        = linkObject.AddComponent <TestUrdfJointPlanar>();
            ArticulationBody    articulationBody = linkObject.GetComponent <ArticulationBody>();

            urdfJoint.TestImportJointData(joint);

            Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockX);
            Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockY);
            Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockZ);

            Assert.AreEqual(4, articulationBody.xDrive.lowerLimit);
            Assert.AreEqual(4, articulationBody.yDrive.lowerLimit);
            Assert.AreEqual(4, articulationBody.zDrive.lowerLimit);
            Assert.AreEqual(5, articulationBody.xDrive.upperLimit);
            Assert.AreEqual(5, articulationBody.yDrive.upperLimit);
            Assert.AreEqual(5, articulationBody.zDrive.upperLimit);
            Assert.AreEqual(6, articulationBody.xDrive.forceLimit);
            Assert.AreEqual(6, articulationBody.yDrive.forceLimit);
            Assert.AreEqual(6, articulationBody.zDrive.forceLimit);
            Assert.AreEqual(7, articulationBody.maxLinearVelocity);

            Object.DestroyImmediate(baseObject);
        }
        public void IsJointAxisDefined_IsFalse()
        {
            GameObject          linkObject = new GameObject("link");
            TestUrdfJointPlanar joint      = linkObject.AddComponent <TestUrdfJointPlanar>();

            Assert.IsFalse(joint.TestIsJointAxisDefined);

            Object.DestroyImmediate(linkObject);
        }
        public void ExportLimitData_Succeeds()
        {
            GameObject          linkObject       = new GameObject("link");
            TestUrdfJointPlanar joint            = linkObject.AddComponent <TestUrdfJointPlanar>();
            ArticulationBody    articulationBody = linkObject.GetComponent <ArticulationBody>();

            articulationBody.yDrive = new ArticulationDrive()
            {
                lowerLimit = 1,
                upperLimit = 2,
            };
            Joint.Limit limit = joint.TestExportLimitData;

            Assert.AreEqual(1, limit.lower);
            Assert.AreEqual(2, limit.upper);
            Assert.AreEqual(joint.EffortLimit, limit.effort);
            Assert.AreEqual(joint.VelocityLimit, limit.velocity);

            Object.DestroyImmediate(linkObject);
        }
        public void ExportSpecificJointData_Succeeds()
        {
            GameObject          linkObject = new GameObject("link");
            TestUrdfJointPlanar urdfJoint  = linkObject.AddComponent <TestUrdfJointPlanar>();

            urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f));
            urdfJoint.Dynamics(new Joint.Dynamics(4, 5));

            var joint = new Joint(
                name: "custom_joint", type: "planar", parent: "base", child: "link");

            urdfJoint.TestExportSpecificJointData(joint);

            UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]);
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]);
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]);
            Assert.AreEqual(4, joint.dynamics.damping);
            Assert.AreEqual(5, joint.dynamics.friction);

            Object.DestroyImmediate(linkObject);
        }
        public void ImportJointData_DefaultAxis_Succeeds(Joint.Axis axis, Quaternion expectedAnchorRotation)
        {
            var joint = new Joint(
                name: "custom_joint", type: "continuous", parent: "base", child: "link",
                axis: axis);

            GameObject baseObject = new GameObject("base");
            GameObject linkObject = new GameObject("link");

            linkObject.transform.parent = baseObject.transform;

            UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed);
            TestUrdfJointPlanar urdfJoint        = linkObject.AddComponent <TestUrdfJointPlanar>();
            ArticulationBody    articulationBody = linkObject.GetComponent <ArticulationBody>();

            urdfJoint.TestImportJointData(joint);

            UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.w, articulationBody.anchorRotation.w);
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.x, articulationBody.anchorRotation.x);
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.y, articulationBody.anchorRotation.y);
            UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.z, articulationBody.anchorRotation.z);

            Object.DestroyImmediate(baseObject);
        }