UrdfRobot.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. © Siemens AG, 2018
  3. Author: Suzannah Smith (suzannah.smith@siemens.com)
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. <http://www.apache.org/licenses/LICENSE-2.0>.
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. using UnityEngine;
  15. namespace RosSharp.Urdf
  16. {
  17. public enum GeometryTypes { Box, Cylinder, Sphere, Mesh }
  18. public class UrdfRobot : MonoBehaviour
  19. {
  20. public string FilePath;
  21. #region Configure Robot
  22. public void SetCollidersConvex(bool convex)
  23. {
  24. foreach (MeshCollider meshCollider in GetComponentsInChildren<MeshCollider>())
  25. meshCollider.convex = convex;
  26. }
  27. public void SetRigidbodiesIsKinematic(bool isKinematic)
  28. {
  29. foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>())
  30. rb.isKinematic = isKinematic;
  31. }
  32. public void SetUseUrdfInertiaData(bool useUrdfData)
  33. {
  34. foreach (UrdfInertial urdfInertial in GetComponentsInChildren<UrdfInertial>())
  35. urdfInertial.rigidbodyDataSource = useUrdfData ?
  36. UrdfInertial.RigidbodyDataSource.Urdf :
  37. UrdfInertial.RigidbodyDataSource.Unity;
  38. }
  39. public void SetRigidbodiesUseGravity(bool useGravity)
  40. {
  41. foreach (Rigidbody rb in GetComponentsInChildren<Rigidbody>())
  42. rb.useGravity = useGravity;
  43. }
  44. public void GenerateUniqueJointNames()
  45. {
  46. foreach (UrdfJoint urdfJoint in GetComponentsInChildren<UrdfJoint>())
  47. urdfJoint.GenerateUniqueJointName();
  48. }
  49. #endregion
  50. }
  51. }