void Start() { goalPos = new Vector3(0f, 0f, 300f); nSample = 30000; maxRange = 100f; maxAngle = 15f; for (int i = 0; i < nSample; i++) { Debug.Log("hello"); // init trainFolder = "C:/DeepDrive/train/201806/open/"; recorder.Init(carRemote, trainFolder); // sample a position pos = new Vector3(Random.Range(-maxRange, maxRange), 0f, Random.Range(-maxRange, maxRange)); //pos = new Vector3(0f, 0f, 0f); recorder.SetCarPosition(pos); // sample a angle angle = Random.Range(-maxAngle, maxAngle); //angle = -60; recorder.SetCarOrientation(Quaternion.AngleAxis(angle, transform.up)); carOrient = new Vector3(Mathf.Sin(angle * Mathf.Deg2Rad), 0, Mathf.Cos(angle * Mathf.Deg2Rad)); goalOrient = goalPos - pos; side = Mathf.Sign(Vector3.Cross(carOrient, goalOrient).y); label = Vector3.Angle(carOrient, goalOrient); // write the data recorder.WriteTrainData(label * side); } }
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; } } }
void Start() { obstCar = GameObject.FindGameObjectWithTag("obstCar"); Debug.Log("hellooo"); ///******************************* /// hardcode values ///******************************* trainPath = string.Concat("C:/DeepDrive/train/201809/test-scene/"); nTrajFrame = 0; rotationAdjust = -1; ///******************************* ///******************************* /// initialize variables positionList = new List <Vector3>(); velocityList = new List <Vector3>(); angleList = new List <float>(); positionListAgent = new List <Vector3>(); velocityListAgent = new List <Vector3>(); angleListAgent = new List <float>(); /// initialize the recorder recorder.Init(carRemote, trainPath); /// record the camera data alone a trajectory for (int i = 0; i <= nTrajFrame; i++) { string agtTrajFile = trainPath + "input/traj-agt/" + i.ToString() + "-" + 1.ToString(); LoadTraj(agtTrajFile, ref positionListAgent, ref velocityListAgent, ref angleListAgent); string egoTrajFile = trainPath + "input/traj-ego/" + i.ToString() + "-" + 5.ToString(); LoadTraj(egoTrajFile, ref positionList, ref velocityList, ref angleList); for (int k = 0; k < positionList.Count; k++) { // make sure the tag "obstCar" is applied to the obstacle car model in Unity. obstCar.transform.position = positionListAgent[k]; obstCar.transform.rotation = Quaternion.AngleAxis(-90, transform.up); 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); } } }
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; } }
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; } } } }