Пример #1
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.GEOMETRY_ELEMENT_NAME);

            switch (this.Shape)
            {
            case Shapes.Box:
                sb.AddSubElement(this.Box.ToString());
                break;

            case Shapes.Cylinder:
                sb.AddSubElement(this.Cylinder.ToString());
                break;

            case Shapes.Mesh:
                sb.AddSubElement(this.Mesh.ToString());
                break;

            case Shapes.Sphere:
                sb.AddSubElement(this.Sphere.ToString());
                break;

            default:
                throw new System.Exception($"Unrecognized geometry type {Shape} cannot be converted to a string");
            }

            return(sb.ToString());
        }
Пример #2
0
        public void BuildXmlStringNoAttributesOrSubElements()
        {
            string           expected = "<hello/>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #3
0
        public void AddAttributeTwice()
        {
            string           expected = "<hello a=\"2\"/>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            sb.AddAttribute("a", 1).AddAttribute("a", 2);

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #4
0
        public void ResetXmlString()
        {
            string           expected = "<good bye=\"bye\"/>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            sb.Reset("good").AddAttribute("bye", "bye");

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #5
0
        public void BuildXmlStringSubElementsOnly()
        {
            string           expected = "<hello>\r\n<one/>\r\n<two/>\r\n</hello>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            sb.AddSubElement("<one/>").AddSubElement("<two/>");

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #6
0
        public void BuildXmlStringAttributesOnly()
        {
            string           expected = "<hello a=\"b\" c=\"4\"/>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            sb.AddAttribute("a", "b").AddAttribute("c", 4);

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #7
0
        public void BuildXmlString()
        {
            string           expected = "<hello a=\"b\">\r\n<subelement/>\r\n</hello>";
            XmlStringBuilder sb       = new XmlStringBuilder("hello");

            sb.AddAttribute("a", "b").AddSubElement("<subelement/>");

            Assert.AreEqual(expected, sb.ToString());
        }
Пример #8
0
        public void XmlStringBuilder_CreateExportString_SendNullWithStringType_ExpectedEmptyString()
        {
            //arrange
            IExportBuilder xmlbuilder = new XmlStringBuilder();

            //act
            var actual = xmlbuilder.GetExportString<String>(null);

            //assert
            Assert.AreEqual(actual, String.Empty);
        }
Пример #9
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.INERTIAL_ELEMENT_NAME)
                                  .AddSubElement(this.Mass.ToString()).AddSubElement(this.Inertia.ToString());

            if (!this.Origin.Equals(Origin.DEFAULT_ORIGIN))
            {
                sb.AddSubElement(this.Origin.ToString());
            }

            return(sb.ToString());
        }
Пример #10
0
        public void XmlStringBuilder_CreateExportString_SendStaticDataList_EqualsToSpecificStringValue()
        {
            //arrange
            IExportBuilder xmlbuilder = new XmlStringBuilder();
            var serializer = new XmlSerializer(_staticTranslation.GetType());
            var writer = new StringWriter();
            serializer.Serialize(writer, _staticTranslation);

            //act
            var actual = xmlbuilder.GetExportString(_staticTranslation);

            //assert
            Assert.AreEqual(actual, writer.ToString());
        }
Пример #11
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.ROBOT_ELEMENT_NAME)
                                  .AddAttribute(UrdfSchema.NAME_ATTRIBUTE_NAME, this.Name);

            foreach (Link link in this.Links.Values)
            {
                sb.AddSubElement(link.ToString());
            }

            foreach (Joint joint in this.Joints.Values)
            {
                sb.AddSubElement(joint.ToString());
            }

            return(sb.ToString());
        }
Пример #12
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.COLLISION_ELEMENT_NAME)
                                  .AddSubElement(this.Geometry.ToString());

            if (this.Name != null)
            {
                sb.AddAttribute(UrdfSchema.NAME_ATTRIBUTE_NAME, this.Name);
            }

            if (!this.Origin.Equals(Origin.DEFAULT_ORIGIN))
            {
                sb.AddSubElement(this.Origin.ToString());
            }

            return(sb.ToString());
        }
Пример #13
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.MESH_ELEMENT_NAME)
                                  .AddAttribute(UrdfSchema.FILE_NAME_ATTRIBUTE_NAME, this.FileName);

            if (this.Scale != DEFAULT_SCALE)
            {
                sb.AddAttribute(UrdfSchema.SCALE_ATTRIBUTE_NAME, this.Scale);
            }

            if (this.Size != null)
            {
                sb.AddAttribute(UrdfSchema.SIZE_ATTRIBUTE_NAME, this.Size);
            }

            return(sb.ToString());
        }
Пример #14
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.MATERIAL_ELEMENT_NAME)
                                  .AddAttribute(UrdfSchema.NAME_ATTRIBUTE_NAME, this.Name);

            if (this.Color != null)
            {
                sb.AddSubElement(this.Color.ToString());
            }

            if (this.Texture != null)
            {
                sb.AddSubElement(this.Texture.ToString());
            }

            return(sb.ToString());
        }
Пример #15
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.JOINT_ELEMENT_NAME)
                                  .AddAttribute(UrdfSchema.NAME_ATTRIBUTE_NAME, this.Name)
                                  .AddAttribute(UrdfSchema.JOINT_TYPE_ATTRIBUTE_NAME, this.Type.ToString().ToLower())
                                  .AddSubElement(new XmlStringBuilder(UrdfSchema.PARENT_ELEMENT_NAME).AddAttribute(UrdfSchema.LINK_ATTRIBUTE_NAME, this.Parent.Name).ToString())
                                  .AddSubElement(new XmlStringBuilder(UrdfSchema.CHILD_ELEMENT_NAME).AddAttribute(UrdfSchema.LINK_ATTRIBUTE_NAME, this.Child.Name).ToString());

            if (!this.Origin.Equals(Origin.DEFAULT_ORIGIN))
            {
                sb.AddSubElement(this.Origin.ToString());
            }

            if (!this.Axis.Equals(Axis.DEFAULT_AXIS))
            {
                sb.AddSubElement(this.Axis.ToString());
            }

            if (this.Calibration != null)
            {
                sb.AddSubElement(this.Calibration.ToString());
            }

            if (this.Dynamics != null)
            {
                sb.AddSubElement(this.Dynamics.ToString());
            }

            if (this.Limit != null)
            {
                sb.AddSubElement(this.Limit.ToString());
            }

            if (this.Mimic != null)
            {
                sb.AddSubElement(this.Mimic.ToString());
            }

            if (this.SafetyController != null)
            {
                sb.AddSubElement(this.SafetyController.ToString());
            }

            return(sb.ToString());
        }
Пример #16
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            if (this.Equals(Origin.DEFAULT_ORIGIN))
            {
                return(string.Empty);
            }

            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.ORIGIN_ELEMENT_NAME);

            if (!this.Xyz.Equals(new XyzAttribute()))
            {
                sb.AddAttribute(UrdfSchema.XYZ_ATTRIBUTE_NAME, this.Xyz);
            }

            if (!this.Rpy.Equals(new RpyAttribute()))
            {
                sb.AddAttribute(UrdfSchema.RPY_ATTRIBUTE_NAME, this.Rpy);
            }

            return(sb.ToString());
        }
Пример #17
0
        /// <summary>
        /// Returns the URDF XML string representation of this model object.
        /// </summary>
        /// <returns>The URDF XML string representation of this model object</returns>
        public override string ToString()
        {
            XmlStringBuilder sb = new XmlStringBuilder(UrdfSchema.LINK_ELEMENT_NAME)
                                  .AddAttribute(UrdfSchema.NAME_ATTRIBUTE_NAME, this.Name);

            foreach (Visual visual in this.Visual)
            {
                sb.AddSubElement(visual.ToString());
            }

            foreach (Collision collision in this.Collision)
            {
                sb.AddSubElement(collision.ToString());
            }

            if (this.Inertial != null)
            {
                sb.AddSubElement(this.Inertial.ToString());
            }

            return(sb.ToString());
        }