public void IKP() { //try //{ Debug.Log("IKP"); UpdateIKPParameters(); //if (IKPParams.) //{ //} _IKPResult = _hexaRequester.ReqIKP(IKPParams); Debug.Log(_IKPResult.ResState); if (_IKPResult.ResState == "OK") { UpdateIKPResults(); _hexaAnimationController.Animate(IKPParams, _IKPResult.AcuatorAngels); Infobox.text = "Time of IKP calculation: " + _IKPResult.CalcTime.ToString() + " ms."; } else if (_IKPResult.ResState == "Failed") { Infobox.text = "Cannot calculate the IKP with the input parameters."; Debug.Log("failed"); } else { Infobox.text += _IKPResult.Message; } //} //catch (System.Exception e) //{ // Infobox.text += e.Message; //} }
public List <float> ReqIKP(List <float> IKPParameters) { ForceDotNet.Force(); IKPResult result = new IKPResult(); using (RequestSocket client = new RequestSocket()) { client.Connect("tcp://localhost:5555"); IKPParameters IKPParams = new IKPParameters(); IKPParams.Type = "IKP"; IKPParams.EndEffectorPosition = new List <float>(); IKPParams.EndEffectorOrientation = new List <float>(); for (int i = 0; i < 3; i++) { IKPParams.EndEffectorPosition.Add(IKPParameters[i]); IKPParams.EndEffectorOrientation.Add(IKPParameters[i + 3]); } string reqIKP = JsonConvert.SerializeObject(IKPParams, Formatting.Indented); client.SendFrame(reqIKP); string message = null; bool gotMessage = false; while (Running) { gotMessage = client.TryReceiveFrameString(out message); // this returns true if it's successful if (gotMessage) { break; } } result = JsonConvert.DeserializeObject <IKPResult>(message); if (gotMessage) { Debug.Log("Received " + message); } } NetMQConfig.Cleanup(); return(result.AcuatorAngels); }