Example #1
0
        public static UrdfJoint Create(GameObject linkObject)
        {
            UrdfJointPlanar urdfJoint = linkObject.AddComponent <UrdfJointPlanar>();

#if UNITY_2020_1_OR_NEWER
            urdfJoint.unityJoint           = linkObject.GetComponent <ArticulationBody>();
            urdfJoint.unityJoint.jointType = ArticulationJointType.PrismaticJoint;
#else
            urdfJoint.unityJoint = linkObject.AddComponent <ConfigurableJoint>();
            urdfJoint.unityJoint.autoConfigureConnectedAnchor = true;
#endif


#if UNITY_2020_1_OR_NEWER
#else
            ConfigurableJoint configurableJoint = (ConfigurableJoint)urdfJoint.unityJoint;

            // degrees of freedom:
            configurableJoint.xMotion        = ConfigurableJointMotion.Free;
            configurableJoint.yMotion        = ConfigurableJointMotion.Free;
            configurableJoint.zMotion        = ConfigurableJointMotion.Locked;
            configurableJoint.angularXMotion = ConfigurableJointMotion.Locked;
            configurableJoint.angularYMotion = ConfigurableJointMotion.Locked;
            configurableJoint.angularZMotion = ConfigurableJointMotion.Locked;
#endif
            return(urdfJoint);
        }
Example #2
0
        private static UrdfJoint AddCorrectJointType(GameObject linkObject, JointTypes jointType)
        {
            UrdfJoint urdfJoint = null;

            switch (jointType)
            {
            case JointTypes.Fixed:
                urdfJoint = UrdfJointFixed.Create(linkObject);
                break;

            case JointTypes.Continuous:
                urdfJoint = UrdfJointContinuous.Create(linkObject);
                break;

            case JointTypes.Revolute:
                urdfJoint = UrdfJointRevolute.Create(linkObject);
                break;

            case JointTypes.Floating:
                urdfJoint = UrdfJointFloating.Create(linkObject);
                break;

            case JointTypes.Prismatic:
                urdfJoint = UrdfJointPrismatic.Create(linkObject);
                break;

            case JointTypes.Planar:
                urdfJoint = UrdfJointPlanar.Create(linkObject);
                break;
            }


#if UNITY_2020_1_OR_NEWER
#else
            UnityEngine.Joint unityJoint = linkObject.GetComponent <UnityEngine.Joint>();
            unityJoint.connectedBody = linkObject.transform.parent.gameObject.GetComponent <Rigidbody>();
            unityJoint.autoConfigureConnectedAnchor = true;
#endif

            return(urdfJoint);
        }