Skip to content

Commit

Permalink
Changed trusted name formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelchang committed Feb 6, 2016
1 parent f0b5189 commit 8d99485
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
9 changes: 9 additions & 0 deletions launch/bar.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<launch>
<node pkg="jammi" type="client_node.py" name="bar_client_node" output="screen">
<param name="name" value="bar"/>
<param name="host" value="localhost"/>
<param name="port" value="9000"/>
</node>

</launch>
15 changes: 6 additions & 9 deletions launch/example.launch
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
<param name="name" value="foo"/>
<param name="host" value="localhost"/>
<param name="port" value="9000"/>
<rosparam>
publishing:
- /state
types:
- geometry_msgs/Point
trusted:
- /bar /baz
</rosparam>
</node>

<node pkg="jammi" type="client_node.py" name="bar_client_node" output="screen">
Expand All @@ -38,14 +30,19 @@
<rosparam>
publishing:
- /state
- /filtered_state
types:
- geometry_msgs/Point
- geometry_msgs/Point
trusted:
- /foo
- foo bar baz
- foo bar
</rosparam>

</node>

<node pkg="rostopic" type="rostopic" name="state_pub"
args="pub -r 100 /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}'" />
</launch>
19 changes: 19 additions & 0 deletions launch/foo.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<launch>
<node pkg="jammi" type="client_node.py" name="foo_client_node" output="screen">
<param name="name" value="foo"/>
<param name="host" value="localhost"/>
<param name="port" value="9000"/>
<rosparam>
publishing:
- /state
types:
- geometry_msgs/Point
trusted:
- /bar /baz
</rosparam>
</node>

<node pkg="rostopic" type="rostopic" name="state_pub"
args="pub -r 100 /state geometry_msgs/Point '{x: 1, y: 1, z: 0}'"/>
</launch>
8 changes: 8 additions & 0 deletions launch/server.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<launch>
<node pkg="jammi" type="server_node.py" name="jammi_server" output="screen">
<param name="host" value="localhost"/>
<param name="port" value="9000"/>
</node>

</launch>
2 changes: 1 addition & 1 deletion src/client/client_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_subscriber(self, topic, msg_type, trusted):
def create_callback(self, topic, msg_type, trusted):
def callback(msg):
data = dict()
data["to"] = trusted
data["to"] = trusted.split(' ')
data["from"] = self.name
data["topic"] = "/{}{}".format(self.name, topic)
data["type"] = msg_type
Expand Down
9 changes: 4 additions & 5 deletions src/server/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def __init__(self):
self.lat_pubs = dict()

def onConnect(self, request):
name = request.path[0:]
name = request.path[1:]
common.add_client(name, self)
self.name_of_client = name
self.lat_pubs[name[1:]] = rospy.Publisher("/jammi" + name + "/latency", Float32, queue_size=2)
self.lat_pubs[name] = rospy.Publisher("/jammi/" + name + "/latency", Float32, queue_size=2)

def onMessage(self, payload, is_binary):
if is_binary:
Expand All @@ -32,13 +32,12 @@ def onMessage(self, payload, is_binary):
latency = Float32()
latency.data = received_time - msg["stamp"]
self.lat_pubs[msg["from"]].publish(latency)
if msg["to"] == "*":
if msg["to"][0] == "*":
for name in common.clients.keys():
if name != msg["from"]:
common.get_client(name).sendMessage(payload, True)
else:
recipients = msg["to"].split(' ')
for name in recipients:
for name in msg["to"]:
common.get_client(name).sendMessage(payload, True)
except KeyError:
pass
Expand Down

0 comments on commit 8d99485

Please sign in to comment.