コード例 #1
0
        public IEnumerator Sample()
        {
            // Start the Coroutine to Capture Data Every Second.
            // Persist that Information to a CSV and Perist the Camera Frame
            yield return(new WaitForSeconds(0.0666666666666667f));

            if (m_saveLocation != "")
            {
                CarSample sample = new CarSample();

                sample.timeStamp     = System.DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff");
                sample.steeringAngle = m_SteerAngle / m_MaximumSteerAngle;
                sample.throttle      = AccelInput;
                sample.brake         = BrakeInput;
                sample.speed         = CurrentSpeed;
                sample.position      = transform.position;
                sample.rotation      = transform.rotation;

                carSamples.Enqueue(sample);

                sample = null;
                //may or may not be needed
            }

            // Only reschedule if the button hasn't toggled
            if (IsRecording)
            {
                StartCoroutine(Sample());
            }
        }
コード例 #2
0
        //Changed the WriteSamplesToDisk to a IEnumerator method that plays back recording along with percent status from UISystem script
        //instead of showing frozen screen until all data is recorded
        public IEnumerator WriteSamplesToDisk()
        {
            yield return(new WaitForSeconds(0.000f));            //retrieve as fast as we can but still allow communication of main thread to screen and UISystem

            if (carSamples.Count > 0)
            {
                //pull off a sample from the que
                CarSample sample = carSamples.Dequeue();

                //pysically moving the car to get the right camera position
                transform.position = sample.position;
                transform.rotation = sample.rotation;

                string sampleTimestamp = sample.timeStamp;
                // Capture and Persist Image
                string centerPath = WriteImage(CenterCamera, "center", sampleTimestamp);

                string leftPath  = "";
                string rightPath = "";

                //TODO: getting to like java-like arrays and lists
                leftPath += WriteImage(LeftCamera0, ("left_0"), sampleTimestamp) + "|";
                leftPath += WriteImage(LeftCamera1, ("left_1"), sampleTimestamp) + "|";
                leftPath += WriteImage(LeftCamera2, ("left_2"), sampleTimestamp) + "|";
                leftPath += WriteImage(LeftCamera3, ("left_3"), sampleTimestamp);

                rightPath += WriteImage(RightCamera0, ("right_0"), sampleTimestamp) + "|";
                rightPath += WriteImage(RightCamera2, ("right_2"), sampleTimestamp) + "|";
                rightPath += WriteImage(RightCamera1, ("right_1"), sampleTimestamp) + "|";
                rightPath += WriteImage(RightCamera3, ("right_3"), sampleTimestamp);

                string row = string.Format("{0},{1},{2},{3},{4},{5},{6}\n", centerPath, leftPath, rightPath, sample.steeringAngle, sample.throttle, sample.brake, sample.speed);
                File.AppendAllText(Path.Combine(m_saveLocation, CSVFileName), row);
            }
            if (carSamples.Count > 0)
            {
                //request if there are more samples to pull
                StartCoroutine(WriteSamplesToDisk());
            }
            else
            {
                //all samples have been pulled
                StopCoroutine(WriteSamplesToDisk());
                isSaving = false;

                //need to reset the car back to its position before ending recording, otherwise sometimes the car ended up in strange areas
                transform.position   = saved_position;
                transform.rotation   = saved_rotation;
                m_Rigidbody.velocity = new Vector3(0f, -10f, 0f);
                Move(0f, 0f, 0f, 0f);
            }
        }
コード例 #3
0
        //Changed the WriteSamplesToDisk to a IEnumerator method that plays back recording along with percent status from UISystem script
        //instead of showing frozen screen until all data is recorded
        public IEnumerator WriteSamplesToDisk()
        {
            yield return(new WaitForSeconds(0.000f));            //retrieve as fast as we can but still allow communication of main thread to screen and UISystem

            if (carSamples.Count > 0)
            {
                //pull off a sample from the que
                CarSample sample = carSamples.Dequeue();                    // 提取一个采样值

                // pysically moving the car to get the right camera position
                // 进行移动
                transform.position = sample.position;
                transform.rotation = sample.rotation;

                // Capture and Persist Image
                // 提取后保存参数
                string centerPath = WriteImage(CenterCamera, "center", sample.timeStamp);
                // string leftPath = WriteImage (LeftCamera, "left", sample.timeStamp);
                // string rightPath = WriteImage (RightCamera, "right", sample.timeStamp);

                // 添加点云采样
                string lidarPath = WriteLidarData(sample.timeStamp);


                string row = string.Format("{0},{1},{2},{3},{4},{5}\n", centerPath, lidarPath, sample.steeringAngle, sample.throttle, sample.brake, sample.speed);
                File.AppendAllText(Path.Combine(m_saveLocation, CSVFileName), row);
            }
            if (carSamples.Count > 0)
            {
                //request if there are more samples to pull
                // 如果有更多的采样值的情况下,继续提取
                StartCoroutine(WriteSamplesToDisk());
            }
            else
            {
                //all samples have been pulled
                StopCoroutine(WriteSamplesToDisk());
                isSaving = false;

                //need to reset the car back to its position before ending recording, otherwise sometimes the car ended up in strange areas
                transform.position   = saved_position;
                transform.rotation   = saved_rotation;
                m_Rigidbody.velocity = new Vector3(0f, -10f, 0f);
                Move(0f, 0f, 0f, 0f);
            }
        }
コード例 #4
0
        public IEnumerator Sample()
        {
            // Start the Coroutine to Capture Data Every Second.
            // Persist that Information to a CSV and Perist the Camera Frame
            yield return(new WaitForSeconds(0.0666666666666667f));

            if (m_saveLocation != "")
            {
                CarSample sample = new CarSample();

                sample.timeStamp       = System.DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff");
                sample.steeringAngle   = m_SteerAngle / m_MaximumSteerAngle;
                sample.throttle        = AccelInput;
                sample.brake           = BrakeInput;
                sample.speed           = CurrentSpeed;
                sample.position        = transform.position;
                sample.rotation        = transform.rotation;
                sample.frontcenterPath = WriteImage(FrontCenterCamera, "Frontcenter", sample.timeStamp);
                sample.frontleftPath   = WriteImage(FrontLeftCamera, "Frontleft", sample.timeStamp);
                sample.frontrightPath  = WriteImage(FrontRightCamera, "Frontright", sample.timeStamp);
                String[] statestring = this.GetComponent <CarRecord>().state;
                for (int i = 0; i < sample.sensor.Length; i++)
                {
                    sample.sensor[i] = float.Parse(statestring[i], CultureInfo.InvariantCulture.NumberFormat);
                }
                sample.rpm = float.Parse(statestring[34], CultureInfo.InvariantCulture.NumberFormat);

                carSamples.Enqueue(sample);

                sample = null;

                //may or may not be needed
            }

            // Only reschedule if the button hasn't toggled
            if (IsRecording)
            {
                StartCoroutine(Sample());
            }
        }
コード例 #5
0
        //Changed the WriteSamplesToDisk to a IEnumerator method that plays back recording along with percent status from UISystem script
        //instead of showing frozen screen until all data is recorded
        public IEnumerator WriteSamplesToDisk()
        {
            yield return(new WaitForSeconds(0.000f));            //retrieve as fast as we can but still allow communication of main thread to screen and UISystem

            if (carSamples.Count > 0)
            {
                //pull off a sample from the que
                CarSample sample = carSamples.Dequeue();

                //pysically moving the car to get the right camera position
                transform.position = sample.position;
                transform.rotation = sample.rotation;

                string row = string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22}" +
                                           ",{23},{24},{25},{26},{27},{28},{29},{30},{31},{32},{33},{34},{35},{36},{37}\n",
                                           sample.frontcenterPath, sample.frontleftPath,
                                           sample.frontrightPath, sample.steeringAngle, sample.throttle, sample.brake, sample.speed, sample.rpm, sample.sensor[0], sample.sensor[1], sample.sensor[2], sample.sensor[3],
                                           sample.sensor[4], sample.sensor[5], sample.sensor[6], sample.sensor[7], sample.sensor[8], sample.sensor[9], sample.sensor[10], sample.sensor[11], sample.sensor[12],
                                           sample.sensor[13], sample.sensor[14], sample.sensor[15], sample.sensor[16], sample.sensor[17], sample.sensor[18], sample.sensor[19], sample.sensor[20], sample.sensor[21],
                                           sample.sensor[22], sample.sensor[23], sample.sensor[24], sample.sensor[25], sample.sensor[26], sample.sensor[27], sample.sensor[28], sample.sensor[29]);
                File.AppendAllText(Path.Combine(m_saveLocation, CSVFileName), row);
            }
            if (carSamples.Count > 0)
            {
                //request if there are more samples to pull
                StartCoroutine(WriteSamplesToDisk());
            }
            else
            {
                //all samples have been pulled
                StopCoroutine(WriteSamplesToDisk());
                isSaving = false;

                //need to reset the car back to its position before ending recording, otherwise sometimes the car ended up in strange areas
                transform.position   = saved_position;
                transform.rotation   = saved_rotation;
                m_Rigidbody.velocity = new Vector3(0f, -10f, 0f);
                Move(0f, 0f, 0f, 0f);
            }
        }