Skip to content

Commit

Permalink
Queueing fix client side
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelchang committed Feb 10, 2018
1 parent 3eb1850 commit 5fb5aa8
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 6 deletions.
82 changes: 76 additions & 6 deletions launch/example.launch
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
<?xml version="1.0"?>
<launch>
<arg name="host" default="raphaelchang.com" />
<arg name="host" default="wallarelvo-tower.csail.mit.edu" />
<arg name="port" default="8080"/>
<node pkg="canopy_client" type="client_node.py" name="foo_client_node" output="screen">
<param name="name" value="foo"/>
<param name="host" value="$(arg host)"/>
<param name="port" value="$(arg port)"/>
<param name="private_key" value="PsFXjmWpszr6acSKL" />
<param name="description" value="foo robot" />
<rosparam>
publishing:
- /state
- /filtered_state
- /test_string
- /test_string2
- /test_string3
types:
- geometry_msgs/Point
- geometry_msgs/PointStamped
- std_msgs/String
- std_msgs/String
- std_msgs/String
trusted:
- foo bar
- "ba[a-z]"
- ".*"
- ".*"
- ".*"
</rosparam>
</node>

<node pkg="canopy_client" type="client_node.py" name="bar_client_node" output="screen">
Expand All @@ -16,6 +36,26 @@
<param name="port" value="$(arg port)"/>
<param name="private_key" value="PsFXjmWpszr6acSKL" />
<param name="description" value="bar robot" />
<rosparam>
publishing:
- /state
- /filtered_state
- /test_string
- /test_string2
- /test_string3
types:
- geometry_msgs/Point
- geometry_msgs/PointStamped
- std_msgs/String
- std_msgs/String
- std_msgs/String
trusted:
- foo bar
- "ba[a-z]"
- ".*"
- ".*"
- ".*"
</rosparam>
</node>

<node pkg="canopy_client" type="client_node.py" name="baz_client_node" output="screen">
Expand All @@ -24,6 +64,26 @@
<param name="port" value="$(arg port)"/>
<param name="private_key" value="PsFXjmWpszr6acSKL" />
<param name="description" value="baz robot" />
<rosparam>
publishing:
- /state
- /filtered_state
- /test_string
- /test_string2
- /test_string3
types:
- geometry_msgs/Point
- geometry_msgs/PointStamped
- std_msgs/String
- std_msgs/String
- std_msgs/String
trusted:
- foo bar
- "ba[a-z]"
- ".*"
- ".*"
- ".*"
</rosparam>
</node>

<node pkg="canopy_client" type="client_node.py" name="qux_client_node" output="screen">
Expand All @@ -37,24 +97,34 @@
- /state
- /filtered_state
- /test_string
- /test_string2
- /test_string3
types:
- geometry_msgs/Point
- geometry_msgs/Point
- geometry_msgs/PointStamped
- std_msgs/String
- std_msgs/String
- std_msgs/String
trusted:
- ".*"
- foo bar
- "ba[a-z]"
- ".*"
- ".*"
- ".*"
</rosparam>

</node>

<node pkg="rostopic" type="rostopic" name="state_pub"
args="pub -r 100 /state geometry_msgs/Point '{x: 1, y: 1, z: 0}'"/>
args="pub -r 200 /state geometry_msgs/Point '{x: 1, y: 1, z: 0}'"/>
<node pkg="rostopic" type="rostopic" name="filtered_state_pub"
args="pub -r 100 /filtered_state geometry_msgs/Point '{x: 2, y: 1, z: 1}'" />
args="pub -sr 200 /filtered_state geometry_msgs/PointStamped '{header: {stamp: now, frame_id: base_link}, point: {x: 2.0, y: 1.0, z: 1.0}}'" />
<node pkg="rostopic" type="rostopic" name="string_pub"
args="pub -r 100 /test_string std_msgs/String 'test'" />
args="pub -r 200 /test_string std_msgs/String 'test'" />
<node pkg="rostopic" type="rostopic" name="string_pub2"
args="pub -r 200 /test_string2 std_msgs/String 'test2'" />
<node pkg="rostopic" type="rostopic" name="string_pub3"
args="pub -r 200 /test_string3 std_msgs/String 'test3'" />
<node pkg="tf" type="static_transform_publisher"
name="tf_test" args="1 0 0 0 0 0 1 world base_link 100" />
<!--<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
Expand Down
13 changes: 13 additions & 0 deletions src/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,26 @@ def on_message(self, payload):
self.timer.cancel()
except:
pass
elif len(payload) == 2:
self.connection.write_message(chr(1), True)
else:
decompressed = zlib.decompress(payload)
size = struct.unpack('=I', decompressed[:4])
frmt = "%ds" % size[0]
unpacked = struct.unpack('=I' + frmt, decompressed)
data = json.loads(unpacked[1])
self.values[data["Topic"]] = data
self.connection.write_message(chr(1), True)

def on_close(self):
self.connection = None
print "Server connection closed. Reconnecting..."
tornado.websocket.websocket_connect(
self.url,
self.ioloop,
callback = self.on_connected,
on_message_callback = self.on_message)


# Timeout for acknowledge packet.
def timeout(self):
Expand Down

0 comments on commit 5fb5aa8

Please sign in to comment.