Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (!bDoLog)
        {
            return;
        }

        timeSinceLastCapture += Time.deltaTime;

        if (timeSinceLastCapture < 1.0f / limitFPS)
        {
            return;
        }

        timeSinceLastCapture -= (1.0f / limitFPS);

        string activity = car.GetActivity();

        if (lidar != null)
        {
            LidarPointArray pa = lidar.GetOutput();

            if (pa != null)
            {
                string json     = JsonUtility.ToJson(pa);
                var    filename = string.Format("/../log/lidar_{0}_{1}.txt", frameCounter.ToString(), activity);
                var    f        = File.CreateText(Application.dataPath + filename);
                f.Write(json);
                f.Close();
            }
        }

        if (optionlB_CamSensor != null)
        {
            SaveCamSensor(camSensor, activity, "_a");
            SaveCamSensor(optionlB_CamSensor, activity, "_b");
        }
        else
        {
            SaveCamSensor(camSensor, activity, "");
        }

        if (maxFramesToLog != -1 && frameCounter >= maxFramesToLog)
        {
            Shutdown();
            this.gameObject.SetActive(false);
        }

        frameCounter = frameCounter + 1;
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        string activity = car.GetActivity();

        if (writer != null)
        {
            writer.WriteLine(string.Format("{0},{1},{2},{3}", frameCounter.ToString(), activity, car.GetSteering().ToString(), car.GetThrottle().ToString()));
        }

        if (lidar != null)
        {
            LidarPointArray pa = lidar.GetOutput();

            if (pa != null)
            {
                string json     = JsonUtility.ToJson(pa);
                var    filename = string.Format("/../log/lidar_{0}_{1}.txt", frameCounter.ToString(), activity);
                var    f        = File.CreateText(Application.dataPath + filename);
                f.Write(json);
                f.Close();
            }
        }

        if (optionlB_CamSensor != null)
        {
            SaveCamSensor(camSensor, activity, "_a");
            SaveCamSensor(optionlB_CamSensor, activity, "_b");
        }
        else
        {
            SaveCamSensor(camSensor, activity, "");
        }

        if (maxFramesToLog != -1 && frameCounter >= maxFramesToLog)
        {
            Shutdown();
            this.gameObject.SetActive(false);
        }

        frameCounter = frameCounter + 1;
    }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (!bDoLog)
        {
            return;
        }

        timeSinceLastCapture += Time.deltaTime;

        if (timeSinceLastCapture < 1.0f / limitFPS)
        {
            return;
        }

        timeSinceLastCapture -= (1.0f / limitFPS);

        string activity = car.GetActivity();

        if (writer != null)
        {
            if (UdacityStyle)
            {
                string image_filename = GetUdacityStyleImageFilename();
                float  steering       = car.GetSteering() / car.GetMaxSteering();
                writer.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6}", image_filename, "none", "none", steering.ToString(), car.GetThrottle().ToString(), "0", "0"));
            }
            else if (DonkeyStyle || SharkStyle)
            {
            }
            else if (DonkeyStyle2)
            {
                DonkeyRecord mjson    = new DonkeyRecord();
                float        steering = car.GetSteering() / car.GetMaxSteering();
                float        throttle = car.GetThrottle();

                //training code like steering clamped between -1, 1
                steering = Mathf.Clamp(steering, -1.0f, 1.0f);

                mjson.Init(string.Format("{0}_cam-image_array_.jpg", frameCounter),
                           throttle, steering, "user");

                string json     = mjson.AsString();
                string filename = string.Format("record_{0}.json", frameCounter);
                var    f        = File.CreateText(Application.dataPath + "/../log/" + filename);
                f.Write(json);
                f.Close();
            }
            else
            {
                writer.WriteLine(string.Format("{0},{1},{2},{3}", frameCounter.ToString(), activity, car.GetSteering().ToString(), car.GetThrottle().ToString()));
            }
        }

        if (lidar != null)
        {
            LidarPointArray pa = lidar.GetOutput();

            if (pa != null)
            {
                string json     = JsonUtility.ToJson(pa);
                var    filename = string.Format("/../log/lidar_{0}_{1}.txt", frameCounter.ToString(), activity);
                var    f        = File.CreateText(Application.dataPath + filename);
                f.Write(json);
                f.Close();
            }
        }

        if (optionlB_CamSensor != null)
        {
            SaveCamSensor(camSensor, activity, "_a");
            SaveCamSensor(optionlB_CamSensor, activity, "_b");
        }
        else
        {
            SaveCamSensor(camSensor, activity, "");
        }

        if (maxFramesToLog != -1 && frameCounter >= maxFramesToLog)
        {
            Shutdown();
            this.gameObject.SetActive(false);
        }

        frameCounter = frameCounter + 1;

        if (logDisplay != null)
        {
            logDisplay.text = "Log:" + frameCounter;
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (!bDoLog)
        {
            return;
        }

        timeSinceLastCapture += Time.deltaTime;

        if (timeSinceLastCapture < 1.0f / limitFPS)
        {
            return;
        }

        timeSinceLastCapture -= (1.0f / limitFPS);

        string activity = car.GetActivity();

        if (writer != null)
        {
            if (PynqStyle)
            {
                string image_filename = GetPynqStyleImageFilename();
                float  steering       = car.GetSteering() / car.GetMaxSteering();
                float  throttle       = car.GetThrottle();
                float  speed          = car.GetVelocity().magnitude / car.GetMaxSpeed();
                //writer.WriteLine(string.Format("{0},{1},{2}", image_filename,steering.ToString(),throttle.ToString()));
                writer.WriteLine(string.Format("{0},{1},{2}", image_filename, steering.ToString(), speed.ToString()));
            }
        }

        if (lidar != null)
        {
            LidarPointArray pa = lidar.GetOutput();

            if (pa != null)
            {
                string json     = JsonUtility.ToJson(pa);
                var    filename = string.Format("lidar_{0}_{1}.txt", frameCounter.ToString(), activity);
                var    f        = File.CreateText(GetLogPath() + filename);
                f.Write(json);
                f.Close();
            }
        }

        if (optionlB_CamSensor != null)
        {
            SaveCamSensor(camSensor, activity, "_a");
            SaveCamSensor(optionlB_CamSensor, activity, "_b");
        }
        else
        {
            SaveCamSensor(camSensor, activity, "");
        }

        if (maxFramesToLog != -1 && frameCounter >= maxFramesToLog)
        {
            Shutdown();
            this.gameObject.SetActive(false);
        }
        if (storeNum != null)
        {
            storeNum.text = string.Format("Now/Total: {0}/{1}", frameCounter, maxFramesToLog);
        }
        frameCounter = frameCounter + 1;

        if (logDisplay != null)
        {
            logDisplay.text = "Log:" + frameCounter;
        }
    }