public void InjectHandUpdate(NewtonVR.NVRHand hand, LogData log, float time) { if (!Ready()) { return; } ROSBridgeLib.ontology_msgs.HandUpdate msg = new ROSBridgeLib.ontology_msgs.HandUpdate(); msg.grasp = hand.HoldButtonAxis; msg.use = hand.UseButtonAxis; if (hand.CurrentlyInteracting != null) { msg.obj_inHand = hand.CurrentlyInteracting.gameObject.name; } else { msg.obj_inHand = "NONE"; } msg.handState = new ROSBridgeLib.ontology_msgs.ObjUpdate(); msg.handState.timestamp = new ROSBridgeLib.msg_helpers.Time(time); msg.handState.position = hand.transform.position; msg.handState.orientation = hand.transform.rotation; msg.handState.velocity = new Vector3(log.velocity[0], log.velocity[1], log.velocity[2]); msg.handState.name = hand.gameObject.name; if (msg.handState.name.Contains("left")) { l_hand_pub.Publish(msg); } else { r_hand_pub.Publish(msg); } }
void FixedUpdate() { if (!Ready() || nohands) //ros == null || !ros.connected) { return; } ROSBridgeLib.ontology_msgs.HandUpdate left = new ROSBridgeLib.ontology_msgs.HandUpdate(); left.grasp = LeftHand.HoldButtonAxis; left.use = LeftHand.UseButtonAxis; if (LeftHand.CurrentlyInteracting != null) { left.obj_inHand = LeftHand.CurrentlyInteracting.gameObject.name; } else { left.obj_inHand = "NONE"; } left.handState = new ROSBridgeLib.ontology_msgs.ObjUpdate(); left.handState.timestamp = new ROSBridgeLib.msg_helpers.Time(ScenarioLogManager.Instance.GetLogTime()); left.handState.position = LeftHand.transform.position; left.handState.orientation = LeftHand.transform.rotation; left.handState.velocity = LeftHand.GetVelocityEstimation(); left.handState.name = LeftHand.gameObject.name; l_hand_pub.Publish(left); ROSBridgeLib.ontology_msgs.HandUpdate right = new ROSBridgeLib.ontology_msgs.HandUpdate(); right.grasp = RightHand.HoldButtonAxis; right.use = RightHand.UseButtonAxis; if (RightHand.CurrentlyInteracting != null) { right.obj_inHand = RightHand.CurrentlyInteracting.gameObject.name; } else { right.obj_inHand = "NONE"; } right.handState = new ROSBridgeLib.ontology_msgs.ObjUpdate(); right.handState.timestamp = new ROSBridgeLib.msg_helpers.Time(ScenarioLogManager.Instance.GetLogTime()); right.handState.position = RightHand.transform.position; right.handState.orientation = RightHand.transform.rotation; right.handState.velocity = RightHand.GetVelocityEstimation(); right.handState.name = RightHand.gameObject.name; r_hand_pub.Publish(right); }