Ejemplo n.º 1
0
        public void initialize(Junction startingPosition, List <Road> roads, TrafficLightManager tlm, Transform trjParent)
        {
            gameObject.layer    = LayerMask.NameToLayer("carLayer");
            isChangingLanes     = false;
            isTurning           = false;
            model               = this.gameObject;
            trafficLightManager = tlm;

            setIdentity();

            trajectory = UnityEngine.Object.Instantiate((Resources.Load("Prefab/DummyObjects/DummyTrajectory") as GameObject).GetComponent <Trajectory>(), trjParent);
            trajectory.createTrajectory(startingPosition, roads, id);

            if (model.GetComponent <MeshCollider>() != null)
            {
                width  = Mathf.Abs(model.GetComponent <MeshCollider>().bounds.min.x - model.GetComponent <MeshCollider>().bounds.max.x);
                length = Mathf.Abs(model.GetComponent <MeshCollider>().bounds.min.z - model.GetComponent <MeshCollider>().bounds.max.z);
                height = Mathf.Abs(model.GetComponent <MeshCollider>().bounds.min.y - model.GetComponent <MeshCollider>().bounds.max.y);
            }
            else if (model.GetComponent <BoxCollider>() != null)
            {
                width  = model.GetComponent <BoxCollider>().size.x;
                height = model.GetComponent <BoxCollider>().size.y;
                length = model.GetComponent <BoxCollider>().size.z;
            }

            raycastOffset = new Vector3(width / 2 - 0.1f, 0, 0);
            alive         = true;
            preferedLane  = null;
            frontCollider = transform.Find("FrontCollider").transform;

            //setInitialPose(height/2);
            setInitialPose(0.2f);
            initializeDecisionCount();
        }
Ejemplo n.º 2
0
 public void Start()
 {
     if (loadData)
     {
         saveData = false;
     }
     cars  = new List <GameObject>();
     world = GameObject.Find("World").GetComponent <World>();
     trafficLightManager = GameObject.Find("TrafficLightManager").GetComponent <TrafficLightManager>();
     createCount         = -1;
     dataIndex           = 0;
     trajectoryParent    = GameObject.Find("CarTrajectory").transform;
     carScenarioManager  = GetComponent <CarScenarioManager>();
     if (fullDataLogging)
     {
         dataCapturer = GetComponent <DataCapturer>();
         dataCapturer.initialize(Application.dataPath + "/../../Testset/ExperimentLog/", "totalFrame.csv");
     }
 }
Ejemplo n.º 3
0
        public void startDriving()
        {
            if (carPool == null)
            {
                carPool = GameObject.Find("CarPool").GetComponent <CarPool>();
            }

            /* pedestrian pool - not implemented yet
             * if (pedPool == null)
             *  pedPool = GameObject.Find("PedPool").GetComponent<PedPool>();
             */
            if (trafficLightManager == null)
            {
                trafficLightManager = GameObject.Find("TrafficLightManager").GetComponent <TrafficLightManager>();
            }

            // to be fixed : this should be handled in diff
            carPool.initialize();
            //pedPool.initialize();
            trafficLightManager.initialize();
        }