Skip to content

Commit

Permalink
Laurie/topic list (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurieCheers-unity authored Mar 12, 2021
1 parent 2011e57 commit 97bb44e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROS_IP: 127.0.0.1
4 changes: 4 additions & 0 deletions launch/endpoint.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<launch>
<rosparam file="$(find ros_tcp_endpoint)/config/params.yaml" command="load"/>
<node name="server_endpoint" pkg="ros_tcp_endpoint" type="default_server_endpoint.py" args="--wait" output="screen" respawn="true" />
</launch>
7 changes: 6 additions & 1 deletion src/ros_tcp_endpoint/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def read_message(conn):

data += packet

if not data:
if full_message_size > 0 and not data:
print("No data for a message size of {}, breaking!".format(full_message_size))
return

Expand Down Expand Up @@ -164,6 +164,11 @@ def run(self):
response_message = self.serialize_message(destination, response)
self.conn.send(response_message)
return
elif destination == '__topic_list':
response = self.tcp_server.topic_list(data)
response_message = self.serialize_message(destination, response)
self.conn.send(response_message)
return
elif destination not in self.tcp_server.source_destination_dict.keys():
error_msg = "Topic/service destination '{}' is not defined! Known topics are: {} "\
.format(destination, self.tcp_server.source_destination_dict.keys())
Expand Down
4 changes: 4 additions & 0 deletions src/ros_tcp_endpoint/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .subscriber import RosSubscriber
from .publisher import RosPublisher
from ros_tcp_endpoint.msg import RosUnitySysCommand
from ros_tcp_endpoint.srv import RosUnityTopicListResponse

class TcpServer:
"""
Expand Down Expand Up @@ -96,6 +97,9 @@ def send_unity_message(self, topic, message):
def send_unity_service(self, topic, service_class, request):
return self.unity_tcp_sender.send_unity_service(topic, service_class, request)

def topic_list(self, data):
return RosUnityTopicListResponse(self.source_destination_dict.keys())

def handle_syscommand(self, data):
message = RosUnitySysCommand().deserialize(data)
function = getattr(self.syscommands, message.command)
Expand Down
2 changes: 2 additions & 0 deletions srv/RosUnityTopicList.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
string[] topics

0 comments on commit 97bb44e

Please sign in to comment.