private void Update() { switch (state) { case robotState.hablando: e_i.material = rojo; e_d.material = rojo; count += Time.deltaTime; if (!RobotMgr.instance.speechManager.audioSource.isPlaying && count > 2) { if (activo) { state = robotState.escuchando; } else { state = robotState.Inactivo; } } break; case robotState.escuchando: e_i.material = verde; e_d.material = verde; RobotMgr.instance.microphoneManager.StartCapturingAudio(); break; default: e_i.material = normal; e_d.material = normal; break; } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { while (running) { //code is needed here: using pointcloud to receive the data from the transform using (Image transformedDepth = new Image(ImageFormat.Depth16, colorWidth, colorHeight, colorWidth * sizeof(UInt16))) using (Capture capture = await Task.Run(() => { return(this.kinect.GetCapture()); })) using (Image colorImage = transform.ColorImageToDepthCamera(capture)) using (Image xyzImage = transform.DepthImageToPointCloud(capture.Depth)) { this.transform.DepthImageToColorCamera(capture, transformedDepth); this.StatusText = "Received Capture: " + capture.Depth.DeviceTimestamp; var color = capture.Color; var depth = capture.Depth; MaskColor(color, transformedDepth); //for display on the screen if (flag == true) { state = primaryInt.getRobotState(); try { info.Text = "please wait for a while ..."; GetPointcloud(colorImage, depth, xyzImage, state); } catch (Exception) { info.Text = "error existing when getting the pointcloud data!"; } } //for getting the point coordinates } } }
// Update is called once per frame void Update() { switch (bobState) { case robotState.Roaming: if (this.gameObject.transform.position == robotNav.destination) { if (Random.Range(0, 10) <= 5) { reTarget(false); } else { reTarget(true); bobState = robotState.Targetting; } } break; case robotState.Targetting: if (lightOn()) { robotNav.destination = new Vector3(-1.75f, 0.5f, 14.0f); } else { if (this.gameObject.transform.position == robotNav.destination) { if (Random.Range(0, 10) <= 8) { reTarget(false); } else { reTarget(true); bobState = robotState.Targetting; } } } break; case robotState.Attacking: break; case robotState.InSight: break; } }
public void DictationProcess(string dic) { if (activo) { string texto_out = dic.ToLower(); if (!conversationStarted) { conversationStarted = true; texto_out = "Hola. Soy Robochachi. Puedes hablar conmigo, pero solo te escucharé cuando tenga los ojitos verdes"; } else { if (dic.Contains("desconecta")) { texto_out = "Muy bien. Hasta luego machote"; activo = false; conversationStarted = false; } else { if (dic.Contains("tiempo") && dic.Contains("mañana")) { texto_out = "Creo que mañana va a llover. Eso no es bueno para mis circuitos."; } else if (dic.Contains("realidad") && dic.Contains("mixta")) { texto_out = "Sin duda la realidad mixta es el futuro... por la cuenta que me trae."; } else if (dic.Contains("xxxxx")) { texto_out = "Apagando sistema...."; activo = false; conversationStarted = false; } else if (dic.Contains("repite conmigo")) { texto_out = "Has dicho... " + texto_out; } else { int r = Random.Range(0, 6); switch (r) { case 1: texto_out = "¿que tiempo hará mañana?... eso si es una pregunta interesante."; break; case 2: texto_out = "No se que quieres decir. Pero si te sirve de algo, mi color favorito es el azul."; break; case 3: texto_out = "La vida de un robot es dura. Aveces no entiendo a los humanos."; break; case 4: texto_out = "Porque no me preguntas sobre la realidad mixta... por ejemplo."; break; case 5: texto_out = "También se repetir tus palabras... si me lo pides."; break; default: texto_out = "En realidad no soy tan listo aún. Dame un poco de tiempo."; break; } } } } RobotMgr.instance.speechManager.Speak(texto_out); count = 0; state = robotState.hablando; } }
private void GetPointcloud(Image colorImage, Image depth, Image xyzImage, robotState state) { flag = false; times++; //make sure this program has been processed once //give out the tcp value and the tranformation matrix if (state.cartesianInfo != null) { tcp = new Vector6 <double>(); ROT = new rot(); tcp = state.cartesianInfo.tcp; ROT.Rx = state.cartesianInfo.tcp.Rx; ROT.Ry = state.cartesianInfo.tcp.Ry; ROT.Rz = state.cartesianInfo.tcp.Rz; matrix_R = RobMath.RotVec2Matrix(ROT); matrix_T_tcp2base.SetSubMatrix(0, 3, 0, 3, matrix_R); matrix_T_tcp2base[3, 0] = 0; matrix_T_tcp2base[3, 1] = 0; matrix_T_tcp2base[3, 2] = 0; matrix_T_tcp2base[3, 3] = 1; matrix_T_tcp2base[0, 3] = tcp.X; matrix_T_tcp2base[1, 3] = tcp.Y; matrix_T_tcp2base[2, 3] = tcp.Z; matrix_T = (DenseMatrix)(matrix_T_tcp2base * matrix_T_tool2tcp); //info.Text = tcp.ToString(); //info.Text = matrix_T_tcp2base.ToString(); BGRA[] colorArray = colorImage.GetPixels <BGRA>().ToArray(); Short3[] xyzArray = xyzImage.GetPixels <Short3>().ToArray(); MathNet.Numerics.LinearAlgebra.Double.Matrix matrix_P1 = new DenseMatrix(4, 1); MathNet.Numerics.LinearAlgebra.Double.Matrix matrix_P0 = new DenseMatrix(4, 1); Vector3[] vertices = new Vector3[num]; Color32[] colors = new Color32[num]; //indices = new int[num]; //描画する点の配列番号を記録。(全ての点を描画) //for (int i = 0; i < num; i++) //{ // indices[i] = i; //} for (int i = 0; i < num; i++) { //頂点座標の代入 vertices[i].x = xyzArray[i].X * 0.001f; vertices[i].y = xyzArray[i].Y * 0.001f; vertices[i].z = xyzArray[i].Z * 0.001f; //色の代入 colors[i].b = colorArray[i].B; colors[i].g = colorArray[i].G; colors[i].r = colorArray[i].R; colors[i].a = 255; ////for each point-1 , use the T-matrix to tansform it to point-0 matrix_P1[0, 0] = vertices[i].x; matrix_P1[1, 0] = vertices[i].y; matrix_P1[2, 0] = vertices[i].z; matrix_P1[3, 0] = 1; matrix_P0 = (DenseMatrix)(matrix_T * matrix_P1); //according to the position of the arm to save the pointcloud data switch (position) { case 1: { vertices_0_b1[i].x = (float)matrix_P0[0, 0]; vertices_0_b1[i].y = (float)matrix_P0[1, 0]; vertices_0_b1[i].z = (float)matrix_P0[2, 0]; colors_0_b1[i] = colors[i]; } break; case 2: { vertices_0_b2[i].x = (float)matrix_P0[0, 0]; vertices_0_b2[i].y = (float)matrix_P0[1, 0]; vertices_0_b2[i].z = (float)matrix_P0[2, 0]; colors_0_b2[i] = colors[i]; } break; case 3: { vertices_0_b3[i].x = (float)matrix_P0[0, 0]; vertices_0_b3[i].y = (float)matrix_P0[1, 0]; vertices_0_b3[i].z = (float)matrix_P0[2, 0]; colors_0_b1[i] = colors[i]; colors_0_b3[i] = colors[i]; } break; case 4: { vertices_0_b4[i].x = (float)matrix_P0[0, 0]; vertices_0_b4[i].y = (float)matrix_P0[1, 0]; vertices_0_b4[i].z = (float)matrix_P0[2, 0]; colors_0_b4[i] = colors[i]; } break; case 5: { vertices_0_b5[i].x = (float)matrix_P0[0, 0]; vertices_0_b5[i].y = (float)matrix_P0[1, 0]; vertices_0_b5[i].z = (float)matrix_P0[2, 0]; colors_0_b5[i] = colors[i]; } break; } } info.Text = "times:" + times.ToString() + "," + "position:" + position.ToString() + "," + "scanning and processing done!"; } else { info.Text = "times:" + times.ToString() + "state.cartesianInfo is null!"; } }
// Use this for initialization void Start() { bobState = robotState.Roaming; robotNav = GetComponent <NavMeshAgent>(); }