void OnNewHandMsg(ROSBridgeLib.simple_unity_bot.HandState handMsg) { if (handMsg.name == "LeftHand") { leftGrasp = handMsg.grasp; leftUse = handMsg.use; SetButtonStates(Player.LeftHand); } else if (handMsg.name == "RightHand") { rightGrasp = handMsg.grasp; rightUse = handMsg.use; SetButtonStates(Player.RightHand); } else { Debug.LogWarning("Received hand state for unknown object: '" + handMsg.name + "' [" + handMsg.grasp + ", " + handMsg.use + "]"); } }
void FixedUpdate() { // send new poses for target's hands & head SimplePoseArray poses = new SimplePoseArray(new ROSBridgeLib.std_msgs.Header(42, new ROSBridgeLib.msg_helpers.Time(1, 2), "body"), null); poses.poses = new System.Collections.Generic.List <SimplePose> { new SimplePose("LeftHand", target.LeftHand.transform.localPosition, target.LeftHand.transform.localRotation), new SimplePose("RightHand", target.RightHand.transform.localPosition, target.RightHand.transform.localRotation), new SimplePose("Head", target.Head.transform.localPosition, target.Head.transform.localRotation) }; ros.Publish(pose_pub, poses); // send hand input states for target ROSBridgeLib.simple_unity_bot.HandState LeftHandMsg = new ROSBridgeLib.simple_unity_bot.HandState("LeftHand", target.LeftHand.Inputs[NVRButtonID.HoldButton].SingleAxis, target.LeftHand.Inputs[NVRButtonID.UseButton].IsPressed ? 1.0f : 0.0f); ROSBridgeLib.simple_unity_bot.HandState RightHandMsg = new ROSBridgeLib.simple_unity_bot.HandState("RightHand", target.RightHand.Inputs[NVRButtonID.HoldButton].SingleAxis, target.RightHand.Inputs[NVRButtonID.UseButton].IsPressed ? 1.0f : 0.0f); ros.Publish(hand_pub, LeftHandMsg); ros.Publish(hand_pub, RightHandMsg); ros.Render(); }