コード例 #1
0
ファイル: ScenTimer.cs プロジェクト: robotil/ConvoyUnity
    // Use this for initialization
    void Start()
    {
        LeaderController          = Leader.GetComponent <VehiclePathController>();
        LeaderController.enabled  = false;
        FolowerController         = Folower.GetComponent <VehiclePathController>();
        FolowerController.enabled = false;
        string[] args = System.Environment.GetCommandLineArgs();

        for (int i = 0; i < args.Length; i++)
        {
            Debug.Log("ARG " + i + ": " + args [i]);
            if (args [i] == "-scenDuration")
            {
                ScenDuration = float.Parse(args [i + 1]);
            }
            if (args [i] == "-scenReplay")
            {
                string replay = args [i + 1];
                if (replay == "1")
                {
                    showReplay = true;
                }
            }
        }
    }
コード例 #2
0
    void PathSetup()
    {
        LeaderPathController = LeaderVehicle.GetComponent <VehiclePathController>();
        LeaderPathController.PathWPs_PosesAndVels.Clear();

        Vector2 WP = LeaderPose;

        LeaderPathController.PathWPs_PosesAndVels.Add(new Vector3(WP.x, WP.y, 5));

        foreach (var element in file.Descendants("Path").Descendants("WayPoint"))
        {
            float WPdiss = float.Parse(element.Element("wp_i_relative_distance").Value);
            float WPang  = float.Parse(element.Element("wp_i_relative_angle").Value);
            float WPvel  = float.Parse(element.Element("wp_i_velocity").Value);


            Vector2 vecToNextWP = new Vector2(Mathf.Sin(WPang), Mathf.Cos(WPang)) * WPdiss;
            WP = WP + vecToNextWP;
            LeaderPathController.PathWPs_PosesAndVels.Add(new Vector3(WP.x, WP.y, WPvel));

            pathLength += WPdiss;                   // used in shahid positionning
        }
    }
コード例 #3
0
    void FollowerSetup()
    {
        float FollowerDiss = 20;         //When inserted scenario doesn't exist, the distance between the two vehicle is 20 and the
                                         // lock works better  .... it was 30;
        Vector2 diffVec      = new Vector2(Mathf.Sin(LeaderAzimuth), Mathf.Cos(LeaderAzimuth)) * FollowerDiss;
        Vector2 FollowerPose = LeaderPose - diffVec;

        float FollowerAzimuth = LeaderAzimuth;

        //FollowerVehicle = Instantiate(FollowerVehicleRef);
        terrainAttachment FollowerVehiclePos = FollowerVehicle.GetComponent <terrainAttachment>();

        FollowerVehiclePos.moveTo(new Vector3(FollowerPose.x, FollowerPose.y, 0.0f));
        FollowerVehiclePos.transform.eulerAngles = new Vector3(0, FollowerAzimuth * Mathf.Rad2Deg, 0);
        Debug.Log("Follower position:" + FollowerPose.x.ToString() + "," + FollowerPose.y.ToString());
        //FollowerVehicle = oshkosh
        VehiclePathController FollowerPathController = FollowerVehicle.GetComponent <VehiclePathController>();

        FollowerPathController.PathWPs_PosesAndVels.Clear();

        VehicleFollowerPathController PathController = FollowerVehicle.GetComponent <VehicleFollowerPathController>();

        PathController.leaderVehicle = LeaderVehicle.transform;
    }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     PathController         = GetComponent <VehiclePathController>();
     targetPrevPose         = new Vector2(0, 0);
     leaderPointsDisstances = 5;
 }