From 83e6fc5e8f6e036f534782b1b63283d5fdf9ef2e Mon Sep 17 00:00:00 2001
From: Sebastian Gomez-Gonzalez <sebastian@robot-learning.de>
Date: Tue, 8 Sep 2020 13:34:20 +0200
Subject: [PATCH] Improving the documentation

---
 README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/README.md b/README.md
index 0ef4cbe..ccf3efc 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,50 @@ in world coordinates of the ball to all its subscribers
 
 Both services use configuration files (JSON). You can see examples in the example folder.
 
+### Client (Subscriber) Example
+
+* The client can be written in any programming language
+* Can also be executed in a separate machine as the vision system
+* Assuming the server runs in a machine called "Rodau" in the TCP port 7660, see 
+the following example written in Python:
+
+```
+import sys
+import zmq
+import json
+
+url = "tcp://rodau:7660"
+context = zmq.Context()
+socket = context.socket(zmq.SUB)
+
+print "Connecting to {0}".format(url)
+socket.connect(url)
+
+topicfilter = ""
+socket.setsockopt(zmq.SUBSCRIBE, topicfilter)
+
+num_obs = 1000
+obs = []
+ball_in_scene = False
+null_warn = 10
+while (len(obs) < num_obs):
+    #topic = socket.recv()
+    body = socket.recv()
+    msg = json.loads(body)
+    if msg['obs'] is None and null_warn>0:
+        print "Observing null"
+        null_warn-=1
+    if msg['obs'] is not None and not ball_in_scene:
+        ball_in_scene = True
+        print "First ball observed"
+    if ball_in_scene:
+        obs.append(msg)
+        print msg
+```
+
+* The example fills the list **obs** with all the 3D observations returned by the vision system until
+1000 are read
+* If there is no ball in the scene, the server returns **null**.
 
 ## Installation
 
-- 
GitLab