Player_Stats.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Player_Stats.cs
  2. * author: Yannic Seidler
  3. */
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. using Valve.VR.InteractionSystem;
  9. using RosSharp.RosBridgeClient;
  10. // Class to display player/ robot information
  11. // Attached to PlayerStats (Scene: Simulation)
  12. public class Player_Stats : MonoBehaviour
  13. {
  14. public Text player_text;
  15. public Text hmd_text;
  16. public Text robot_pose;
  17. Player player;
  18. PoseStampedSubscriber poseStampedSubscriber;
  19. Vector3 player_pos;
  20. Vector3 hmd_Camera_pos;
  21. // Start is called before the first frame update.
  22. void Start()
  23. {
  24. poseStampedSubscriber = GameObject.Find("RosBridge").GetComponent<PoseStampedSubscriber>();
  25. player = Player.instance;
  26. }
  27. // Updates the players/ robots status once per frame.
  28. void Update()
  29. {
  30. player_pos = player.trackingOriginTransform.position;
  31. hmd_Camera_pos = player.hmdTransform.position;
  32. player_text.text = player_text.name + " \tpose: " + player_pos.ToString();
  33. hmd_text.text = hmd_text.name + " \tpose: " + hmd_Camera_pos.ToString();
  34. robot_pose.text = robot_pose.name + "\tpose: " + poseStampedSubscriber.position.ToString();
  35. }
  36. }