Ejemplo n.º 1
0
 // This function sets the controllers for a newly created LabBot object
 // Used when a robot is created from file
 public void Initialize()
 {
     wheelController          = gameObject.AddComponent <WheelMotorController>();
     psdController            = gameObject.AddComponent <PSDController>();
     servoController          = gameObject.AddComponent <ServoController>();
     eyeCamController         = gameObject.AddComponent <EyeCameraController>();
     wheelController.wheels   = new List <Wheel>();
     psdController.sensors    = new List <PSDSensor>();
     servoController.servos   = new List <Servo>();
     eyeCamController.cameras = new List <EyeCamera>();
 }
    // Use this for initialization
    void Awake()
    {
        if (robot is ICameras)
        {
            if ((cameraToDisplay = (robot as ICameras).GetCameraComponent(0)) != null)
            {
                cameraTarget.texture = cameraToDisplay.rendTex;
            }
            else
            {
                Debug.Log("Failed to get camera component");
            }
        }

        lockButtonImage.sprite = lockedImage;
        robotNumber.text       = "ID # " + robot.objectID.ToString();
        robotName.text         = robot.name;
        trailButtonImage.color = robot.trail.enabled ? Color.white : Color.grey;

        if (robot is IVWDrive)
        {
            toggleVWAccurate.isOn = (robot as IVWDrive).VWAccurate;
        }

        if (robot is IPSDSensors)
        {
            if ((psdController = robot.GetComponent <PSDController>()) == null)
            {
                Debug.Log("No PSD Controller");
            }
            if ((robot as IPSDSensors).UseGlobalError)
            {
                psdMeanError.text   = PSDController.globalMean.ToString("N2");
                psdStdDevError.text = PSDController.globalStdDev.ToString("N2");
            }
            else
            {
                psdMeanError.text   = (robot as IPSDSensors).MeanError.ToString("N2");
                psdStdDevError.text = (robot as IPSDSensors).StdDevError.ToString("N2");
            }
            useGlobalError = (robot as IPSDSensors).UseGlobalError;
        }

        visualiseToggle.isOn = SimManager.instance.defaultVis;
        SaltPepperNoiseToggle(false);
        GaussianNoiseToggle(false);
        PSDErrorEnabled(false);

        SimManager.instance.OnPause  += OnSimPaused;
        SimManager.instance.OnResume += OnSimResumed;
    }