static PointSampleGlobal ConstructPointSampleFromOpenDriveCoordinates(Vector2 position, float heading)
        {
            var poseUnity = OpenDriveMapElementFactory.FromOpenDriveGlobalToUnity(
                math.radians(heading), position.x, position.y);

            return(new PointSampleGlobal(poseUnity));
        }
        // Because all of these tests were written assuming open drive coordinates, but our geometry is in
        // Unity coordinates, rather than re-write all the test cases, we just convert from OpenDRIVE to Unity here
        static Geometry ConstructGeometryFromOpenDriveCoordinates(
            GeometryKind geometryKind, float headingDegrees, float length, float sAbsolute, float x, float z,
            ArcData arcData     = default, SpiralData spiralData         = default,
            Poly3Data poly3Data = default, ParamPoly3Data paramPoly3Data = default)
        {
            var pose = OpenDriveMapElementFactory.FromOpenDriveGlobalToUnity(math.radians(headingDegrees), x, z);

            return(ConstructGeometry(geometryKind, pose, length, sAbsolute,
                                     arcData, spiralData, poly3Data, paramPoly3Data));
        }
        public void TestFromOpenDriveToUnity(float headingIn, float xIn, float yIn, RigidTransform poseExpected)
        {
            var poseActual        = OpenDriveMapElementFactory.FromOpenDriveGlobalToUnity(headingIn, xIn, yIn);
            var posDelta          = poseActual.pos - poseExpected.pos;
            var magnitudePosDelta = math.sqrt(math.dot(posDelta, posDelta));

            Assert.IsTrue(Mathf.Approximately(0.0f, magnitudePosDelta));
            var rotationProduct = math.dot(poseExpected.rot, poseActual.rot);

            Assert.IsTrue(Mathf.Approximately(1f, math.abs(rotationProduct)));
        }
        // Because all of these tests were written assuming open drive coordinates, but our geometry is in
        // Unity coordinates, rather than re-write all the test cases, we just convert from OpenDRIVE to Unity here
        static Geometry ConstructGeometryFromOpenDriveCoordinates(
            float headingDegrees, float length, float sAbsolute, float x, float z,
            GeometryKind geometryKind, ArcData arcData = default, SpiralData spiralData = default,
            Poly3Data poly3Data = default, ParamPoly3Data paramPoly3Data = default)
        {
            var pose = OpenDriveMapElementFactory.FromOpenDriveGlobalToUnity(math.radians(headingDegrees), x, z);

            return(new Geometry()
            {
                length = length,
                sRoad = sAbsolute,
                startPose = pose,
                geometryKind = geometryKind,
                arcData = arcData,
                spiralData = spiralData,
                poly3Data = poly3Data,
                paramPoly3Data = paramPoly3Data
            });
        }
Beispiel #5
0
        private RoadNetworkDescription LoadTestFile(string name)
        {
            // XXX: How do we remove the need to construct an importer here? We need to be able to serialize a
            // RoadNetworkDescription object without keeping the accompanying xodr file
            var testFilePath = "";

            foreach (var assetPath in AssetDatabase.GetAllAssetPaths())
            {
                if (assetPath.Contains("Test") && assetPath.Contains("XodrFiles") &&
                    assetPath.Contains(name))
                {
                    testFilePath = assetPath;
                    break;
                }
            }
            Assert.AreNotEqual("", testFilePath, $"Failed to find {name} test file.");
            var factory = new OpenDriveMapElementFactory();

            Assert.IsTrue(factory.TryCreateRoadNetworkDescription(XDocument.Load(testFilePath), out var roadNetwork),
                          $"Failed to create test road network from {testFilePath}");
            return(roadNetwork);
        }
 public void SetUp()
 {
     _factory = new OpenDriveMapElementFactory();
 }