Exemplo n.º 1
0
    void Update()
    {
        if (keyboardInput == null)
        {
            keyboardInput = input.KeyboardInput;
        }
        if (steerwheelInput == null)
        {
            steerwheelInput = input.SteerWheelInput;
        }

        //Update states
        {
            selfDriving               = Time.time - lastAutoUpdate < 0.5f;
            underKeyboardControl      = (keyboardInput != null && (keyboardInput.SteerInput != 0.0f || keyboardInput.AccelBrakeInput != 0.0f));
            underSteeringWheelControl = input.HasValidSteeringWheelInput();
        }

        Vector3 simLinVel = controller.RB.velocity;
        Vector3 simAngVel = controller.RB.angularVelocity;

        var projectedLinVec = Vector3.Project(simLinVel, transform.forward);

        actualLinVel = projectedLinVec.magnitude * (Vector3.Dot(simLinVel, transform.forward) > 0 ? 1.0f : -1.0f);

        var projectedAngVec = Vector3.Project(simAngVel, transform.up);

        actualAngVel = projectedAngVec.magnitude * (projectedAngVec.y > 0 ? -1.0f : 1.0f);
    }
Exemplo n.º 2
0
    public static void ChangeFocusSteerWheel(SteeringWheelInputController c)
    {
        if (c == null)
        {
            return;
        }

        workingInstance = c;
    }
    void InitWheel()
    {
        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows)
        {
            try
            {
                DirectInputWrapper.Init();
            }
            catch (DllNotFoundException)
            {
                // in case DirectInput wrapper dll file is not found
                Debug.Log("DirectInput wrapper dll file is not found");
                available = false;
                return;
            }

            for (int i = 0; i < DirectInputWrapper.DevicesCount(); i++)
            {
                if (!DirectInputWrapper.HasForceFeedback(i))
                {
                    continue;
                }
                wheelIndex = i;
                available  = true;
                break;
            }

            if (!available)
            {
                Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
                return;
            }
        }
        else
        {
            // WARNING: Input.GetJoystickNames or GetAxis/Buttons will crash if no valid Joystick is connected
            available = Environment.GetEnvironmentVariable("SDL_GAMECONTROLLERCONFIG") != null;
            // if (available)
            // {
            //     foreach (var joy in Input.GetJoystickNames())
            //     {
            //         Debug.Log($"Available joystick: {joy}, Preconfigured = {Input.IsJoystickPreconfigured(joy)}");
            //     }
            // }
        }
    }
Exemplo n.º 4
0
 void Start()
 {
     if (AppController.Instance.UserInput is SteeringWheelInputController)
     {
         logi = AppController.Instance.UserInput as SteeringWheelInputController;
     }
     else
     {
         this.enabled = false;
     }
     rb = GetComponent <Rigidbody>();
 }
 void Start()
 {
     if (AppController.Instance.UserInput is SteeringWheelInputController)
     {
         logi = AppController.Instance.UserInput as SteeringWheelInputController;
         logi.Init();
         //logi.InitSpringForce(saturation, coefficient);
     }
     else
     {
         this.enabled = false;
     }
 }
Exemplo n.º 6
0
    void Start()
    {
        Keyboard = GetComponent <KeyboardInputController>();
        Wheel    = GetComponent <SteeringWheelInputController>();

        Wheel.TriggerPress += ev =>
        {
            if (ev == InputEvent.AUTONOMOUS_MODE_OFF)
            {
                StopControl();
            }
        };
    }
    protected override void Start()
    {
        base.Start();

        debugStyle                  = new GUIStyle();
        debugStyle.fontSize         = 45;
        debugStyle.normal.textColor = Color.white;

        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        DirectInputWrapper.Init();

        bool ff0 = DirectInputWrapper.HasForceFeedback(0);

        if (DirectInputWrapper.DevicesCount() > 1)
        {
            bool ff1 = DirectInputWrapper.HasForceFeedback(1);

            if (ff1 && !ff0)
            {
                wheelIndex = 1;
                pedalIndex = 0;
            }
            else if (ff0 && !ff1)
            {
                wheelIndex = 0;
                pedalIndex = 1;
            }
            else
            {
                //Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
                wheelIndex = 0;
                pedalIndex = 1;
            }
        }

        minBrake  = AppController.Instance.appSettings.minBrake;
        maxBrake  = AppController.Instance.appSettings.maxBrake;
        minGas    = AppController.Instance.appSettings.minGas;
        maxGas    = AppController.Instance.appSettings.maxGas;
        gasAxis   = AppController.Instance.appSettings.gasAxis;
        brakeAxis = AppController.Instance.appSettings.brakeAxis;
        FFBGain   = AppController.Instance.appSettings.FFBMultiplier;
    }
Exemplo n.º 8
0
 void OnDestroy()
 {
     //destroy if single one, otherwise transfer control
     if (inited == this)
     {
         inited = null;
         var other = FindObjectOfType <SteeringWheelInputController>();
         if (other != null)
         {
             other.Init();
         }
         else
         {
             if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows)
             {
                 DirectInputWrapper.Close();
             }
         }
     }
 }
    protected override void Start()
    {
        base.Start();

        debugStyle                  = new GUIStyle();
        debugStyle.fontSize         = 45;
        debugStyle.normal.textColor = Color.white;

        if (inited == null)
        {
            inited = this;
        }
        else
        {
            return;
        }

        DirectInputWrapper.Init();

        MasterSteeringWheel = false;
        masterIndex         = reportMasterWheel("FANATEC CSL Elite Wheel Base");
        if (masterIndex > -1)
        {
            MasterSteeringWheel = true;
        }


        bool ff0 = DirectInputWrapper.HasForceFeedback(0); /// Thios part mworks for now as the main inputs are always 0 or 1 we need code here though tat jumps over the master wheel shpould it be present

        if (DirectInputWrapper.DevicesCount() > 1)         // steering one and two should be padles and participant steering wheel
        {
            bool ff1 = DirectInputWrapper.HasForceFeedback(1);

            if (ff1 && !ff0)
            {
                wheelIndex = 1;
                pedalIndex = 0;
            }
            else if (ff0 && !ff1)
            {
                wheelIndex = 0;
                pedalIndex = 1;
            }
            else
            {
                Debug.Log("STEERINGWHEEL: Multiple devices and couldn't find steering wheel device index");
            }
        }


        if (MasterSteeringWheel)
        {
            minBrake = AppController.Instance.appSettings.minBrakeFanatec;
            maxBrake = AppController.Instance.appSettings.maxBrakeFanatec;
            minGas   = AppController.Instance.appSettings.minGasFanatec;
            maxGas   = AppController.Instance.appSettings.maxGasFanatec;
        }
        else
        {
            minBrake = AppController.Instance.appSettings.minBrake;
            maxBrake = AppController.Instance.appSettings.maxBrake;
            minGas   = AppController.Instance.appSettings.minGas;
            maxGas   = AppController.Instance.appSettings.maxGas;
        }

        gasAxis   = AppController.Instance.appSettings.gasAxis;
        brakeAxis = AppController.Instance.appSettings.brakeAxis;
        // FWheel = AppController.Instance.appSettings.FantacWheel;
        FFBGain = AppController.Instance.appSettings.FFBMultiplier;
    }
Exemplo n.º 10
0
    public void SpawnVehicle(Vector3 position, Quaternion rotation, RosBridgeConnector connector, VehicleConfig staticConfig, float height = 0.0f)
    {
        var agentImage = Instantiate(AgentUI, AgentList);

        agentImage.transform.FindDeepChild("Address").GetComponent <Text>().text = connector.PrettyAddress;
        var button = agentImage.GetComponent <Button>();

        button.onClick.AddListener(() =>
        {
            UserInterfaceSetup.ChangeFocusUI(connector);
            SteeringWheelInputController.ChangeFocusSteerWheel(connector.Agent.GetComponentInChildren <SteeringWheelInputController>());
        });

        var agentSetup = connector.agentType;

        GameObject bot = Instantiate(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject : agentSetup.gameObject, position, rotation); // TODO better system

        AnalyticsManager.Instance?.EgoStartEvent(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject.name : agentSetup.gameObject.name);

        var uiObject = Instantiate(UserInterfaceAgent);

        uiObject.GetComponent <RfbClient>().Address = connector.Address;
        var ui = uiObject.transform;

        ui.GetComponent <UserInterfaceSetup>().agent = bot;

        if (bot.name.Contains("duckiebot"))
        {
            HelpScreenUpdate helpScreen = uiObject.GetComponent <HelpScreenUpdate>();
            helpScreen.Help       = helpScreen.DuckieHelp;
            helpScreen.agentsText = helpScreen.duckieText;
        }

        // offset for multiple vehicle UI
        RectTransform rect = uiObject.GetComponent <UserInterfaceSetup>().MainPanel;

        if (rect != null)
        {
            rect.offsetMax = new Vector2(0, rect.offsetMax.y - height);
        }
        connector.UiObject     = uiObject;
        connector.UiButton     = agentImage;
        connector.BridgeStatus = uiObject.GetComponent <UserInterfaceSetup>().BridgeStatus;

        bot.GetComponent <AgentSetup>().Setup(ui.GetComponent <UserInterfaceSetup>(), connector, staticConfig);

        bot.GetComponent <AgentSetup>().FollowCamera.gameObject.SetActive(false);
        button.image.sprite = bot.GetComponent <AgentSetup>().agentUISprite;

        //uiObject.enabled = i == 0;
        var colors = button.colors;

        //colors.normalColor = i == 0 ? new Color(1, 1, 1) : new Color(0.8f, 0.8f, 0.8f);
        button.colors = colors;

        var name = new GameObject();

        name.transform.parent               = AgentListCanvas.transform.FindDeepChild("Panel").transform;
        connector.UiName                    = name.AddComponent <Text>();
        connector.UiName.font               = Resources.GetBuiltinResource <Font>("Arial.ttf");
        connector.UiName.text               = connector.PrettyAddress;
        connector.UiName.fontSize           = 16;
        connector.UiName.fontStyle          = FontStyle.Bold;
        connector.UiName.horizontalOverflow = HorizontalWrapMode.Overflow;
        connector.UiName.verticalOverflow   = VerticalWrapMode.Overflow;

        connector.Agent = bot;
    }
Exemplo n.º 11
0
    private void InitScene()
    {
        if (ROSAgentManager.Instance.currentMode == StartModeTypes.Dev)
        {
            return;
        }

        AgentListCanvas = Instantiate(UserInterfaceAgentList);
        AgentList       = AgentListCanvas.transform.FindDeepChild("Content"); // TODO needs to change !!! asap

        float height = 0;

        if (ROSAgentManager.Instance.activeAgents.Count > 1)
        {
            height = AgentListCanvas.transform.FindDeepChild("AgentList").GetComponent <RectTransform>().rect.height; // TODO needs to change !!! asap
        }
        else
        {
            AgentListCanvas.enabled = false;
        }

        // TODO: update spawn position from static config
        Vector3    defaultSpawnPosition = new Vector3(1.0f, 0.018f, 0.7f);
        Quaternion defaultSpawnRotation = Quaternion.identity;

        var spawnInfos    = FindObjectsOfType <SpawnInfo>();
        var spawnInfoList = spawnInfos.ToList();

        spawnInfoList.Reverse();

        RosBridgeConnector first = null;

        for (int i = 0; i < ROSAgentManager.Instance.activeAgents.Count; i++)
        {
            var connector = ROSAgentManager.Instance.activeAgents[i];

            var agentSetup = connector.agentType;
            var spawnPos   = defaultSpawnPosition;
            var spawnRot   = defaultSpawnRotation;
            if (spawnInfoList.Count > 0)
            {
                spawnPos = spawnInfoList[spawnInfoList.Count - 1].transform.position;
                spawnRot = spawnInfoList[spawnInfoList.Count - 1].transform.rotation;
                spawnInfoList.RemoveAt(spawnInfoList.Count - 1);
            }
            spawnPos -= new Vector3(0.25f * i, 0, 0);

            if (FindObjectOfType <StaticConfigManager>() != null &&
                StaticConfigManager.Instance.staticConfig.initialized &&
                ROSAgentManager.Instance.currentMode == StartModeTypes.StaticConfig)
            {
                var staticConfig = StaticConfigManager.Instance.staticConfig.vehicles[i];

                var gps = agentSetup.gameObject.transform.GetComponentInChildren <GpsDevice>();

                var pos = staticConfig.position;
                if (pos.e != 0.0f || pos.n != 0.0f)
                {
                    spawnPos   = gps.GetPosition(pos.e, pos.n);
                    spawnPos.y = pos.h;
                    var rot = staticConfig.orientation;
                    spawnRot = Quaternion.Euler(rot.r, rot.y, rot.p);
                }
                SpawnVehicle(spawnPos, spawnRot, connector, staticConfig, height);
            }
            else
            {
                SpawnVehicle(spawnPos, spawnRot, connector, null, height);
            }

            if (first == null)
            {
                first = connector;
            }
        }

        if (first != null)
        {
            first.Agent.GetComponent <AgentSetup>().FollowCamera.gameObject.SetActive(true);
            UserInterfaceSetup.ChangeFocusUI(first);
            SteeringWheelInputController.ChangeFocusSteerWheel(first.Agent.GetComponentInChildren <SteeringWheelInputController>());
            ROSAgentManager.Instance?.SetCurrentActiveAgent(first);
        }

        InitGlobalShadowSettings(); // TODO better way for small maps
    }
Exemplo n.º 12
0
    private void InitScene()
    {
        if (ROSAgentManager.Instance.currentMode == StartModeTypes.Dev)
        {
            return;
        }

        var agentListCanvas = Instantiate(UserInterfaceAgentList);
        var agentList       = agentListCanvas.transform.FindDeepChild("Content"); // TODO needs to change !!! asap

        float height = 0;

        if (ROSAgentManager.Instance.activeAgents.Count > 1)
        {
            height = agentListCanvas.transform.FindDeepChild("AgentList").GetComponent <RectTransform>().rect.height; // TODO needs to change !!! asap
        }
        else
        {
            agentListCanvas.enabled = false;
        }

        // TODO: update spawn position from static config
        Vector3    defaultSpawnPosition = new Vector3(1.0f, 0.018f, 0.7f);
        Quaternion defaultSpawnRotation = Quaternion.identity;

        var spawnInfos    = FindObjectsOfType <SpawnInfo>();
        var spawnInfoList = spawnInfos.ToList();

        spawnInfoList.Reverse();

        for (int i = 0; i < ROSAgentManager.Instance.activeAgents.Count; i++)
        {
            var agentImage = Instantiate(AgentUI, agentList);
            agentImage.transform.FindDeepChild("Address").GetComponent <Text>().text = ROSAgentManager.Instance.activeAgents[i].PrettyAddress;
            var ilocal = i;
            var button = agentImage.GetComponent <Button>();
            button.onClick.AddListener(() =>
            {
                UserInterfaceSetup.ChangeFocusUI(ROSAgentManager.Instance.activeAgents[ilocal]);
                SteeringWheelInputController.ChangeFocusSteerWheel(ROSAgentManager.Instance.activeAgents[ilocal].Agent.GetComponentInChildren <SteeringWheelInputController>());
            });

            var agentSetup = ROSAgentManager.Instance.activeAgents[i].agentType;
            var spawnPos   = defaultSpawnPosition;
            var spawnRot   = defaultSpawnRotation;
            if (spawnInfoList.Count > 0)
            {
                spawnPos = spawnInfoList[spawnInfoList.Count - 1].transform.position;
                spawnRot = spawnInfoList[spawnInfoList.Count - 1].transform.rotation;
                spawnInfoList.RemoveAt(spawnInfoList.Count - 1);
            }

            GameObject bot = new GameObject();

            if (FindObjectOfType <StaticConfigManager>() != null)
            {
                if (StaticConfigManager.Instance.staticConfig.initialized && ROSAgentManager.Instance.currentMode == StartModeTypes.StaticConfig)
                {
                    var gps = agentSetup.gameObject.transform.GetComponentInChildren <GpsDevice>();

                    var pos = StaticConfigManager.Instance.staticConfig.vehicles[i].position;
                    if (pos.e != 0.0 || pos.n != 0.0)
                    {
                        spawnPos   = gps.GetPosition(pos.e, pos.n);
                        spawnPos.y = pos.h;
                        var rot = StaticConfigManager.Instance.staticConfig.vehicles[i].orientation;
                        spawnRot = Quaternion.Euler(rot.r, rot.y, rot.p);
                    }
                    bot = Instantiate(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject : agentSetup.gameObject, spawnPos, spawnRot);
                }
            }
            else
            {
                bot = Instantiate(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject : agentSetup.gameObject, spawnPos - new Vector3(0.25f * i, 0, 0), spawnRot); // TODO better system
            }

            AnalyticsManager.Instance?.EgoStartEvent(agentSetup == null ? ROSAgentManager.Instance.agentPrefabs[0].gameObject.name : agentSetup.gameObject.name);

            var bridgeConnector = ROSAgentManager.Instance.activeAgents[i];

            var uiObject = Instantiate(UserInterfaceAgent);
            uiObject.GetComponent <RfbClient>().Address = ROSAgentManager.Instance.activeAgents[i].Address;
            var ui = uiObject.transform;
            ui.GetComponent <UserInterfaceSetup>().agent = bot;

            if (bot.name.Contains("duckiebot"))
            {
                HelpScreenUpdate helpScreen = uiObject.GetComponent <HelpScreenUpdate>();
                helpScreen.Help       = helpScreen.DuckieHelp;
                helpScreen.agentsText = helpScreen.duckieText;
            }

            // offset for multiple vehicle UI
            RectTransform rect = uiObject.GetComponent <UserInterfaceSetup>().MainPanel;
            if (rect != null)
            {
                rect.offsetMax = new Vector2(0, rect.offsetMax.y - height);
            }
            bridgeConnector.UiObject     = uiObject;
            bridgeConnector.UiButton     = agentImage;
            bridgeConnector.BridgeStatus = uiObject.GetComponent <UserInterfaceSetup>().BridgeStatus;

            var isVehicleConfig = false;
            if (FindObjectOfType <StaticConfigManager>() != null)
            {
                isVehicleConfig = StaticConfigManager.Instance.staticConfig.initialized && ROSAgentManager.Instance.currentMode == StartModeTypes.StaticConfig;
            }

            bot.GetComponent <AgentSetup>().Setup(ui.GetComponent <UserInterfaceSetup>(), bridgeConnector, isVehicleConfig ? StaticConfigManager.Instance.staticConfig.vehicles[i] : null);

            bot.GetComponent <AgentSetup>().FollowCamera.gameObject.SetActive(i == 0);
            button.image.sprite = bot.GetComponent <AgentSetup>().agentUISprite;

            uiObject.enabled = i == 0;
            var colors = button.colors;
            colors.normalColor = i == 0 ? new Color(1, 1, 1) : new Color(0.8f, 0.8f, 0.8f);
            button.colors      = colors;

            var name = new GameObject($"agent_{i}_name");
            name.transform.parent                     = agentListCanvas.transform.FindDeepChild("Panel").transform;
            bridgeConnector.UiName                    = name.AddComponent <Text>();
            bridgeConnector.UiName.font               = Resources.GetBuiltinResource <Font>("Arial.ttf");
            bridgeConnector.UiName.text               = ROSAgentManager.Instance.activeAgents[i].PrettyAddress;
            bridgeConnector.UiName.fontSize           = 16;
            bridgeConnector.UiName.fontStyle          = FontStyle.Bold;
            bridgeConnector.UiName.horizontalOverflow = HorizontalWrapMode.Overflow;
            bridgeConnector.UiName.verticalOverflow   = VerticalWrapMode.Overflow;

            bridgeConnector.Agent = bot;
        }

        UserInterfaceSetup.ChangeFocusUI(ROSAgentManager.Instance.activeAgents[0]);
        SteeringWheelInputController.ChangeFocusSteerWheel(ROSAgentManager.Instance.activeAgents[0].Agent.GetComponentInChildren <SteeringWheelInputController>());
        ROSAgentManager.Instance?.SetCurrentActiveAgent(ROSAgentManager.Instance.activeAgents[0]);

        //destroy spawn information after use
        foreach (var spawnInfo in spawnInfos)
        {
            Destroy(spawnInfo.gameObject);
        }

        InitGlobalShadowSettings(); // TODO better way for small maps
    }
Exemplo n.º 13
0
 void Start()
 {
     vehicleInputContrl = GetComponent <VehicleInputController>();
     steerwheel         = GetComponent <SteeringWheelInputController>();
     rb = GetComponent <Rigidbody>();
 }
Exemplo n.º 14
0
    void SceneLoadFinished(AsyncOperation op)
    {
        if (!Application.isEditor)
        {
            allLoadedBundles.ForEach(b => b.Unload(false));
            allLoadedBundles.Clear();
        }

        var robotListCanvas = Instantiate(UserInterfaceRobotList);
        var robotList       = robotListCanvas.transform.FindDeepChild("Content");

        float height = 0;

        if (Robots.Robots.Count > 1)
        {
            height = robotListCanvas.transform.FindDeepChild("RobotList").GetComponent <RectTransform>().rect.height;
        }
        else
        {
            robotListCanvas.enabled = false;
        }

        // TODO: update spawn position from static config
        Vector3    defaultSpawnPosition = new Vector3(1.0f, 0.018f, 0.7f);
        Quaternion defaultSpawnRotation = Quaternion.identity;

        var spawnInfos    = FindObjectsOfType <SpawnInfo>();
        var spawnInfoList = spawnInfos.ToList();

        spawnInfoList.Reverse();

        //avoid first frame collision
        //var sceneRobots = FindObjectsOfType<RobotSetup>();
        //foreach (var robot in sceneRobots)
        //{
        //    var cols = robot.GetComponentsInChildren<Collider>();
        //    foreach (var col in cols)
        //    {
        //        col.enabled = false;
        //    }
        //}

        for (int i = 0; i < Robots.Robots.Count; i++)
        {
            var robotImage = Instantiate(DuckiebotRobot, robotList);
            robotImage.transform.FindDeepChild("Address").GetComponent <Text>().text = Robots.Robots[i].PrettyAddress;
            var ilocal = i;
            var button = robotImage.GetComponent <Button>();
            button.onClick.AddListener(() =>
            {
                UserInterfaceSetup.ChangeFocusUI(Robots.Robots[ilocal], Robots);
                SteeringWheelInputController.ChangeFocusSteerWheel(Robots.Robots[ilocal].Robot.GetComponentInChildren <SteeringWheelInputController>());
            });

            var robotSetup = Robots.Robots[i].robotType;
            var spawnPos   = defaultSpawnPosition;
            var spawnRot   = defaultSpawnRotation;
            if (spawnInfoList.Count > 0)
            {
                spawnPos = spawnInfoList[spawnInfoList.Count - 1].transform.position;
                spawnRot = spawnInfoList[spawnInfoList.Count - 1].transform.rotation;
                spawnInfoList.RemoveAt(spawnInfoList.Count - 1);
            }

            GameObject bot = new GameObject();

            if (staticConfig.initialized)
            {
                var gps = robotSetup.gameObject.transform.GetComponentInChildren <GpsDevice>();

                var pos = staticConfig.vehicles[i].position;
                if (pos.e != 0.0 || pos.n != 0.0)
                {
                    spawnPos   = gps.GetPosition(pos.e, pos.n);
                    spawnPos.y = pos.h;
                    var rot = staticConfig.vehicles[i].orientation;
                    spawnRot = Quaternion.Euler(rot.r, rot.y, rot.p);
                }
                bot = Instantiate(robotSetup == null ? Robots.robotCandidates[0].gameObject : robotSetup.gameObject, spawnPos, spawnRot);
            }
            else
            {
                bot = Instantiate(robotSetup == null ? Robots.robotCandidates[0].gameObject : robotSetup.gameObject, spawnPos - new Vector3(0.25f * i, 0, 0), spawnRot); // TODO better system
            }

            AnalyticsManager.Instance?.EgoStartEvent(robotSetup == null ? Robots.robotCandidates[0].gameObject.name : robotSetup.gameObject.name);

            var bridgeConnector = Robots.Robots[i];

            var uiObject = Instantiate(UserInterface);
            uiObject.GetComponent <RfbClient>().Address = Robots.Robots[i].Address;
            var ui = uiObject.transform;

            if (bot.name.Contains("duckiebot"))
            {
                HelpScreenUpdate helpScreen = uiObject.GetComponent <HelpScreenUpdate>();
                helpScreen.Help       = helpScreen.DuckieHelp;
                helpScreen.RobotsText = helpScreen.DuckieRobotsText;
            }

            // offset for multiple vehicle UI
            RectTransform rect = uiObject.GetComponent <UserInterfaceSetup>().MainPanel;
            if (rect != null)
            {
                rect.offsetMax = new Vector2(0, rect.offsetMax.y - height);
            }
            bridgeConnector.UiObject     = uiObject;
            bridgeConnector.UiButton     = robotImage;
            bridgeConnector.BridgeStatus = uiObject.GetComponent <UserInterfaceSetup>().BridgeStatus;
            ui.GetComponent <HelpScreenUpdate>().Robots = Robots;

            bot.GetComponent <RobotSetup>().Setup(ui.GetComponent <UserInterfaceSetup>(), bridgeConnector, staticConfig.initialized ? staticConfig.vehicles[i] : null);

            bot.GetComponent <RobotSetup>().FollowCamera.gameObject.SetActive(i == 0);
            button.image.sprite = bot.GetComponent <RobotSetup>().robotUISprite;

            uiObject.enabled = i == 0;
            var colors = button.colors;
            colors.normalColor = i == 0 ? new Color(1, 1, 1) : new Color(0.8f, 0.8f, 0.8f);
            button.colors      = colors;

            var name = new GameObject($"robot_{i}_name");
            name.transform.parent                     = robotListCanvas.transform.FindDeepChild("Panel").transform;
            bridgeConnector.UiName                    = name.AddComponent <Text>();
            bridgeConnector.UiName.font               = Resources.GetBuiltinResource <Font>("Arial.ttf");
            bridgeConnector.UiName.text               = Robots.Robots[i].PrettyAddress;
            bridgeConnector.UiName.fontSize           = 16;
            bridgeConnector.UiName.fontStyle          = FontStyle.Bold;
            bridgeConnector.UiName.horizontalOverflow = HorizontalWrapMode.Overflow;
            bridgeConnector.UiName.verticalOverflow   = VerticalWrapMode.Overflow;

            bridgeConnector.Robot = bot;

            SimulatorManager.Instance?.AddActiveRobot(bot);
        }

        // hack for dev
        SimulatorManager.Instance.SpawnDashUI();

        UserInterfaceSetup.ChangeFocusUI(Robots.Robots[0], Robots);
        SteeringWheelInputController.ChangeFocusSteerWheel(Robots.Robots[0].Robot.GetComponentInChildren <SteeringWheelInputController>());
        SimulatorManager.Instance.SetCurrentActiveRobot(Robots.Robots[0].Robot);

        //destroy spawn information after use
        foreach (var spawnInfo in spawnInfos)
        {
            Destroy(spawnInfo.gameObject);
        }

        //Configure shadow settings due to huge difference between different cars
        bool useRealSizeSetting = false;

        for (int i = 0; i < Robots.Robots.Count; i++)
        {
            var robotSetup = Robots.Robots[i].robotType;

            if (robotSetup.GetComponentInChildren <SimpleCarController>() == null)
            {
                useRealSizeSetting = true;
                break;
            }
        }
        if (useRealSizeSetting)
        {
            RealSizeGlobalShadowSettings();
        }

        UserInterfaceSetup.FocusUI.Invoke("CheckStaticConfigTraffic", 0.5f);
    }