コード例 #1
0
    void Start()
    {
        ///*******************************
        /// hardcode values
        ///*******************************
        trainFolder = string.Concat("C:/DeepDrive/train/201809/detect-", roadType, "/");
        trainFile   = "input/area";

        /// initialize variables
        positionList        = new List <Vector3>();
        intentDirectionList = new List <Vector3>();
        limitAngleList      = new List <Vector3>();
        multList            = new List <float>();
        leftLabelList       = new List <float>();
        rightLabelList      = new List <float>();

        /// initialize the recorder
        recorder.Init(carRemote, trainFolder);
        recorder.LoadObstacle(roadType);

        /// load the zone information
        LoadZoneInfo();

        /// main program
        eps    = 1;
        maxRot = 2.5f;
        gapRot = 0.1f;
        for (int i = 0; i < positionList.Count; i++)
        {
            /// set the car position
            recorder.SetCarPosition(positionList[i]);

            /// compute the relevant angles
            limitAngleModified     = Vector3.Angle(Vector3.right, limitAngleList[i]) + multList[i] * eps;
            angleToIntentDirection = Vector3.Angle(Vector3.right, intentDirectionList[i]);
            rightMostAngle         = angleToIntentDirection - maxRot;
            leftMostAngle          = angleToIntentDirection + maxRot;
            curAngle = rightMostAngle;

            /// generate training data
            while (curAngle <= leftMostAngle)
            {
                float angle = 90 - curAngle;
                recorder.SetCarOrientation(Quaternion.AngleAxis(angle, Vector3.up));

                // recorder.WriteTrainData(-1, leftLabelList[i], positionList[i], angle);
                if (curAngle > limitAngleModified)
                {
                    recorder.WriteTrainData(leftLabelList[i]);
                }
                else
                {
                    recorder.WriteTrainData(rightLabelList[i]);
                }


                curAngle += gapRot;
            }
        }
    }
コード例 #2
0
    void Start()
    {
        ///*******************************
        /// hardcode values
        ///*******************************
        trainFolder = string.Concat("C:/DeepDrive/train/ICRA19/detect-", roadType, "/");
        recorder.Init(carRemote, trainFolder);
        recorder.LoadObstacle(roadType);

        float minx = -3f;
        float maxx = 3f;
        float curx = minx;
        float gapx = 0.02f;

        float minz = 50f;
        float maxz = 90f;
        float curz = minz;
        float gapz = 0.5f;


        while (curz <= maxz)
        {
            while (curx <= maxx)
            {
                Vector3 pos = new Vector3(curx, 0f, curz);
                recorder.SetCarPosition(pos);

                if (curx >= -1.2)
                {
                    recorder.WriteTrainData(1);
                }
                else
                {
                    recorder.WriteTrainData(0);
                }

                curx += gapx;
            }

            curx  = minx;
            curz += gapz;
        }
    }
コード例 #3
0
    void Start()
    {
        ///*******************************
        /// hardcode values
        ///*******************************
        trainFolder = string.Concat("C:/DeepDrive/train/201809/avoid-", roadType, "/");

        /// initialize variables
        positionList = new List <Vector3>();
        velocityList = new List <Vector3>();
        angleList    = new List <float>();

        /// set some variable values
        switch (roadType)
        {
        case "straight":
            nTrajFrame     = 73;
            rotationAdjust = -1;
            break;

        case "curved":
            Debug.Log("helloo-curved");
            nTrajFrame     = 23;
            rotationAdjust = 1;
            break;

        default:
            throw new Exception("The road type is not specified, enter either straight or curve!");
        }

        /// initialize the recorder
        recorder.Init(carRemote, trainFolder);
        recorder.LoadObstacle(roadType);
        trainFolder = trainFolder + "input/traj/";

        /// record the camera data alone a trajectory
        for (int i = 0; i <= nTrajFrame; i++)
        {
            string trajName = trainFolder + i.ToString() + "-" + 5.ToString();
            LoadTraj(trajName);

            for (int k = 0; k < positionList.Count; k++)
            {
                float   angle  = angleList[k];
                Vector3 pos    = positionList[k];
                float   orient = rotationAdjust * Vector3.Angle(Vector3.forward, velocityList[k]);
                recorder.SetCarPosition(pos);
                recorder.SetCarOrientation(Quaternion.AngleAxis(orient, transform.up));
                recorder.WriteTrainData(i, angle, pos, orient);
            }
        }


        /// record the camera data by conducting extra manipulations at each position of a trajectory
        if (false)
        {
            for (int j = 0; j < positionList.Count; j++)
            {
                // horizontal shift
                float startShift = -0.3f;
                float endShift   = 0.3f;
                float curShift   = startShift;
                float gapShift   = 0.1f;
                while (curShift <= endShift)
                {
                    Vector3 pos = positionList[j];
                    pos.x += curShift;
                    recorder.SetCarPosition(pos);

                    // left-to-right rotation
                    float startAngle = -5f;
                    float endAngle   = 5f;
                    float curAngle   = startAngle;
                    float gapAngle   = 1f;
                    while (curAngle <= endAngle)
                    {
                        recorder.SetCarOrientation(Quaternion.AngleAxis(curAngle, Vector3.up));
                        //recorder.WriteTrainData(-1, angleList[j], pos, curAngle);
                        curAngle += gapAngle;
                    }
                    curShift += gapShift;
                }
            }
        }
    }