예제 #1
0
        public void SetPublishJointStates(bool publish)
        {
            if (publish)
            {
                JointStatePublisher jointStatePublisher = transform.AddComponentIfNotExists <JointStatePublisher>();
                jointStatePublisher.JointStateReaders = new List <JointStateReader>();

                foreach (UrdfJoint urdfJoint in UrdfRobot.GetComponentsInChildren <UrdfJoint>())
                {
                    if (urdfJoint.JointType != UrdfJoint.JointTypes.Fixed)
                    {
                        jointStatePublisher.JointStateReaders.Add(urdfJoint.transform.AddComponentIfNotExists <JointStateReader>());
                    }
                }
            }
            else
            {
                GetComponent <JointStatePublisher>()?.JointStateReaders.Clear();

                foreach (JointStateReader reader in UrdfRobot.GetComponentsInChildren <JointStateReader>())
                {
                    reader.transform.DestroyImmediateIfExists <JointStateReader>();
                }
            }
        }
예제 #2
0
        public void Patch()
        {
            RemoveExistingComponents();

            PatchRigidbodies(EnableRigidbodiesGravity, SetRigidbodiesKinematic);
            PatchMeshColliders(SetMeshCollidersConvex);

            if (AddJointStateReaders)
            {
                JointStatePublisher jointStatePublisher = AddComponentIfNotExists <JointStatePublisher>();
                jointStatePublisher.JointStateReaders = AddJointStateReaderComponents();
            }

            if (AddJointStateWriters)
            {
                JointStateSubscriber jointStateSubscriber = AddComponentIfNotExists <JointStateSubscriber>();
                AddJointStateWriterComponents(out jointStateSubscriber.JointNames, out jointStateSubscriber.JointStateWriters);
            }
        }