0

I want to stream real-time sensor data(webcam, laser point cloud, etc.) from one robot to multiple observers.

In this use case, only the newest data is useful. For example, when a new frame of point cloud arrives, the older ones will be useless.

Redis has nice publisher/consumer support, but it has buffers according to (Redis Pubsub and Message Queueing).

So are there better alternatives? Something like ROS's publishers/subscribers. They have a message queue size parameter.

  /**
   * The subscribe() call is how you tell ROS that you want to receive messages
   * on a given topic.
   *
   * The second parameter to the subscribe() function is the size of the message
   * queue.  If messages are arriving faster than they are being processed, this
   * is the number of messages that will be buffered up before beginning to throw
   * away the oldest ones.
   */
  ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
Zhaolin Feng
  • 428
  • 4
  • 8

1 Answers1

-1

Maybe you can use redis list data structure for your purpose, like a queue. The list data structure in redis is made with linked list and adding a new item is O(1). Whenever your robot produces data it can put it in a list with LPUSH command, and when you want to get the latest item from the list use LRANGE "key-name" 0 0. This command will retrive the latest pushed item. Also if you want to not accumulate the data in queue, you may try to use LTRIM before LRANGE to maintain the latest records. For example LTRIM "key-name" 0 10 will keep the records of last 10 elements. This trim interval should be set according to your observer processing speeds. ref: https://redis.io/docs/data-types/lists/