static void GenFs() { for (int l = 0; l < 4; l++) { for (int r = 0; r < 4; r++) { for (int lm = 0; lm < 3; lm++) { for (int rm = 0; rm < 3; rm++) { for (int f = 0; f < 2; f++) { for (int w = 0; w < 2; w++) { var fs = new FootState { Facing = f, L = l, R = r, LMode = lm, RMode = rm, Weight = w }; Code[fs] = FootStates.Count; FootStates.Add(fs); } } } } } } }
void Start() { #region MYO_INIT myoState = MyoState.NONE; myoController = GetComponent <MyoWebClient>(); myoBaseObject = GameObject.Find("BaseData"); #endregion #region WALKING_INIT walkingController = GetComponent <SensorWebClient>(); leftFootState = FootState.UNKNOWN; rightFootState = FootState.UNKNOWN; targetPosFlag = false; #endregion keyFlag = false; }
private void ReceiveCallback(IAsyncResult AR) { //Check how much bytes are recieved and call EndRecieve to finalize handshake int recieved = _clientSocket.EndReceive(AR); if (recieved <= 0) { return; } //Copy the recieved data into new buffer , to avoid null bytes byte[] recData = new byte[recieved]; Buffer.BlockCopy(_recieveBuffer, 0, recData, 0, recieved); var rawReceiveData = System.Text.Encoding.Default.GetString(recData); if (rawReceiveData.Contains("\r\n")) { recString = rawReceiveData.Substring(0, rawReceiveData.IndexOf("\r\n")); } try { string[] foot_reading = recString.Split(','); if (foot_reading.Length == 2) { tempLeftFoot = (foot_reading[0] == FOOT_LOW) ? FootState.LAND : FootState.WALK; tempRightFoot = (foot_reading[1] == FOOT_LOW) ? FootState.LAND : FootState.WALK; } } catch (Exception ex) { Debug.Log(ex.Message); } //Start receiving again _clientSocket.BeginReceive(_recieveBuffer, 0, _recieveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null); }
private void Start() { footState = FootState.onStart; }
void WalkingControl() { if (leftFootPrevious != walkingController.tempLeftFoot && leftFootPrevious != FootState.UNKNOWN) { if (walkingController.tempLeftFoot == FootState.LAND) { leftFootWalkCnt = 0; } else if (walkingController.tempLeftFoot == FootState.WALK) { leftFootLandCnt = 0; } targetPosFlag = false; } else if (leftFootPrevious == walkingController.tempLeftFoot && leftFootPrevious != FootState.UNKNOWN) { if (walkingController.tempLeftFoot == FootState.LAND) { leftFootLandCnt++; } else if (walkingController.tempLeftFoot == FootState.WALK) { leftFootWalkCnt++; } } if (rightFootprevious != walkingController.tempRightFoot && rightFootprevious != FootState.UNKNOWN) { if (walkingController.tempRightFoot == FootState.LAND) { rightFootWalkCnt = 0; } else if (walkingController.tempRightFoot == FootState.WALK) { rightFootLandCnt = 0; } targetPosFlag = false; } else if (rightFootprevious == walkingController.tempRightFoot && rightFootprevious != FootState.UNKNOWN) { if (walkingController.tempRightFoot == FootState.LAND) { rightFootLandCnt++; } else if (walkingController.tempRightFoot == FootState.WALK) { rightFootWalkCnt++; } } if (leftFootWalkCnt > THRESHOLD_CNT) { leftFootState = FootState.WALK; } if (leftFootLandCnt > THRESHOLD_CNT) { leftFootState = FootState.LAND; } if (rightFootWalkCnt > THRESHOLD_CNT) { rightFootState = FootState.WALK; } if (rightFootLandCnt > THRESHOLD_CNT) { rightFootState = FootState.LAND; } //leftFootState = (leftFootWalkCnt > THRESHOLD_CNT) ? FootState.WALK : FootState.LAND; //rightFootState = (rightFootWalkCnt > THRESHOLD_CNT) ? FootState.WALK : FootState.LAND; //leftFootState = (leftFootLandCnt > THRESHOLD_CNT) ? FootState.LAND : FootState.WALK; //rightFootState = (rightFootLandCnt > THRESHOLD_CNT) ? FootState.LAND : FootState.WALK; if (!targetPosFlag) { Vector3 directionVector = Camera.main.transform.forward.normalized; if (directionVector.y > cardboardController.transform.position.y) { directionVector.y = 0; } targetPos = cardboardController.transform.position + (Camera.main.transform.forward.normalized); } leftFootPrevious = walkingController.tempLeftFoot; rightFootprevious = walkingController.tempRightFoot; }