CameraServiceSubscriber.cs 1021 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * author: Jana-Sophie Schönfeld
  3. */
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. // Attached to GameObject RosConnector in the hierachy.
  8. namespace RosSharp.RosBridgeClient
  9. {
  10. [RequireComponent(typeof(RosConnector))]
  11. public class CameraServiceSubscriber: UnityServiceSubscriber<MessageTypes.Rosapi.TopicsForTypeRequest, MessageTypes.Rosapi.TopicsForTypeResponse>
  12. {
  13. public string[] topics;
  14. // Start is called before the first frame update.
  15. // Calls rosapi service.
  16. void Start()
  17. {
  18. base.Start("/rosapi/topics_for_type", new MessageTypes.Rosapi.TopicsForTypeRequest("sensor_msgs/CompressedImage"));
  19. }
  20. // Gets answer from service and saves all topics for compressed images.
  21. protected override void ServiceResponseHandler(MessageTypes.Rosapi.TopicsForTypeResponse topicsMessage)
  22. {
  23. topics = topicsMessage.topics;
  24. Debug.Log("Got the topics");
  25. }
  26. }
  27. }